Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For instance, I have a file with poor indentation (at least incoherant with the rest of the project).

If I correct the indentation and commit, there will be a serious change in the file at a certain point in time, causing the diffs between versions before and after that serious change to be hard to read.

How do you handle that king of minor logical modification causing major diffs ?

share|improve this question
Many diff tools offer an option to ignore changes in whitespace. – FrustratedWithFormsDesigner Feb 23 '12 at 17:12
Indentation problem is an example of "minor logical modification causing major diffs". – BenjaminB Feb 23 '12 at 19:57
up vote 2 down vote accepted

I will handle it in this way:

  1. Make one commit ONLY involving the indentation correction
  2. Define a label to categorize this kind of "minor logical modification causing major diffs" behaviors (e.g. [CodingStandard]), and include such label in the comment on that commit (e.g. [CodingStandard] Correct the indentation)

Item 2 is for your convenience when you want to quickly browse the log of the commits. Item 1 makes it easier to verify whether the commit does exactly what the comment suggests.

Now, let's say you have 5 commits for this file:

 X1 <--- X2 <--- X3 <--- X4 <--- X5

It doesn't help you if you intend to diff X1 and X5. However, it gives you a chance to isolate diff(X2,X3) out that you just need to study diff(X1,X2) and diff(X3,X5).

share|improve this answer

You need to do it, so do it.

However, isolate it to that commit. Make one commit fixing the whitespace and making no other changes to the code. That will be easiest to work with later if you need to revise the repo history or bisect, etc.

share|improve this answer
+1 for pointing out that if it's the right thing to do, then you just do it. – Stephen Gross Feb 23 '12 at 18:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.