git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFE: Discard hunks during `git add -p`
@ 2016-11-02 13:46 Jan Engelhardt
  2016-11-02 14:07 ` Konstantin Khomoutov
  2016-11-02 22:11 ` Jeff King
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Engelhardt @ 2016-11-02 13:46 UTC (permalink / raw)
  To: git


Current version: 2.10.2
Example workflow:

* I would do a global substitution across a source tree, e.g. `perl -i 
  -pe 's{OLD_FOO\(x\)}{NEW_BAR(x, 0)}' *.c`
* Using `git add -p`, I would verify each of the substitutions that they 
  make sense in their respective locations, and, based on that,
  answer "y" or "n" to the interactive prompting to stage good hunks.
* When done with add-p, I would commit the so-staged hunks,
  and then use `git reset --hard` to discard all changes that were 
  not acknowledged during add-p.

Being able to discard hunks (reset working copy to index contents) 
during add-p would alleviate the (quite broad) hard reset.

Similar approach:

* global substitution
* Using `git add -p`, some hunks may warrant some more editing, doable 
  with the "e" command. The index would be updated with the extra
  change, but the working copy be left as-is.
* When rerunning `git add -p` in such a state, a difference is shown 
  again for such edited spots, which I would like to discard (bring 
  the working copy into sync with index).

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

end of thread, other threads:[~2016-11-02 22:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-02 13:46 RFE: Discard hunks during `git add -p` Jan Engelhardt
2016-11-02 14:07 ` Konstantin Khomoutov
2016-11-02 22:11 ` Jeff King
2016-11-02 22:37   ` Jeff King

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).