git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git add without whitespace
@ 2016-05-30 15:26 Robert Dailey
  2016-05-30 19:06 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Dailey @ 2016-05-30 15:26 UTC (permalink / raw)
  To: Git

I think it would be useful to have a '-w' option for 'git add' that
completely ignores whitespace changes, the same way that 'git diff -w'
does.

Real life scenario:

Sometimes developers will use tooling that does not properly strip
trailing whitespace in source files. Next time I edit those files for
a simple 1-line code change, my tooling will strip whitespace from the
whole file. I *do* want these changes, however I want 2 commits: 1
commit with the bugfix, and a supplementary commit with just the
whitespace changes.

At the moment, there is no way for me to conveniently add the source
file to the index without whitespace. The only way to accomplish this
today that I'm aware of is via this command:

$ git diff -U0 -w --no-color | git apply --cached --ignore-whitespace
--unidiff-zero

This command explicitly leaves out context because it can sometimes
cause the patch to fail to apply, I think due to whitespace being in
it, but I'm not completely sure myself.

It would be useful to be able to do this instead:

$ git add -w

This would effectively function the same as my workaround command
shown earlier. It should also be valid to use -w with -i and -p. In
the -p case, it just won't show hunks containing whitespace changes.
For -i, it would assume '-w' as part of any command run during the
interactive session.

Does this idea sound good? I have some free time on my hands so I
wouldn't mind implementing this. Maybe there isn't a huge audience for
this kind of thing, or maybe I'm just going about this the wrong way.
Thoughts would be much appreciated.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-05-31 16:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-30 15:26 git add without whitespace Robert Dailey
2016-05-30 19:06 ` Junio C Hamano
2016-05-30 19:50   ` Robert Dailey
2016-05-30 22:00     ` Junio C Hamano
2016-05-31 15:03       ` Robert Dailey
2016-05-31 16:16         ` Junio C Hamano
2016-05-31 15:59   ` Christian Neukirchen
2016-05-31 16:27   ` demerphq

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).