2

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 ?

2
  • 4
    Many diff tools offer an option to ignore changes in whitespace. Feb 23, 2012 at 17:12
  • Indentation problem is an example of "minor logical modification causing major diffs".
    – BenjaminB
    Feb 23, 2012 at 19:57

2 Answers 2

2

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:

            [CodingStandard]
                 |
                 V
 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).

6

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.

1
  • +1 for pointing out that if it's the right thing to do, then you just do it. Feb 23, 2012 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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