Question

I recently posted a diff to review board at work. I didn't really check the diff until after and I noticed that whitespace at the end of lines was removed by my editor. I'd like to split those whitespace changes out into a separate commit. How can I do this?

Afterward, I think the easiest way to update the diff would be to actually just upload the diff. There have been a bunch of commits since my commit and I've rebased since (we always pull --rebase here) so just updating review board using the guess features might not work out really.

Note: I've already pushed.

Was it helpful?

Solution

I'm not familiar with "review board," but here's a general git strategy for answering this part of the question:

I'd like to split those whitespace changes out into a separate commit. What would be the easiest way to do this.

git checkout whitespace-fix
git reset --hard <sha of commit you posted diff of>
git reset HEAD~1
git add --patch .

Now stage the hunks that correspond to the whitespace issues (tip: use "s" to split presented hunks into smaller hunks). After you're done, commit and rebase and your fresh commit is ready.

git commit -m 'Remove whitespace at end of lines'
git rebase master

OTHER TIPS

I believe, to solve the current situation, meaning - getting to have in Review Board the diff containing only your relevant changes (and not the space changes) - the easiest thing to do would be this:

  1. re-create the diff based on the revision numbers you got after pushing (like this, you ensure you have no relative paths issues when uploading the diff again to Review Board);
  2. clean the diff by editing it and keep only the relevant changes (depending on the size of the diff, you have a few choices to go with - simple select/remove or smart search & replace, reg. exp., etc);
  3. upload your diff again (if you want to use the same review request, use the Update Diff feature, otherwise, simply create a new review request).

These should fix the trouble.

On the other hand...

I guess you should solve the part with getting those spaces in the diff files you are creating - this makes a pain to review changes when you're looking at the history of code modifications.
Here, you could have quite a few things check, like the diff command that you are using.

I hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top