git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Feature request - discard hunk in add --patch mode

From
MAMina Almasry <almasry.mina@hotmail.com>
Date
Aug 15, 2012, 20:58 UTC
Message-ID
<BLU0-SMTP112EF6B9308C55734C4F10293B60@phx.gbl>
In-Reply-To
<7vmx1w56z1.fsf@alter.siamese.dyndns.org>
On 12-08-15 02:46 PM, Junio C Hamano wrote:
Show 20 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Thomas Rast <trast@student.ethz.ch> writes:
>>
>>> This has come up before, and actually led to the introduction of
>>> 'checkout -p' and 'reset -p':
>>>
>>>    http://thread.gmane.org/gmane.comp.version-control.git/123854
>> That is a blast from the past.
>>
>> Why is saying "git checkout ." too much work, after "add -p" that
>> you excluded the debugging cruft?
> Please forget this question.  A better way in the form of "stash -p"
> was suggested in the old thread to get rid of debug cruft in the
> tree before an "add -p" session (or during a series of "add -p"
> sessions).
>
> So is this still an issue?
>
>
I read most of the thread, and I do think it still is. Here are my 2 cents:
1. The alternative commands aren't nearly as time efficient:
     - git checkout . is fast and awesome, but you can't use it if, for 
example, you have to maintain a dirty         working tree
     - git (stash|reset|checkout) -p make you go through (all|most) of 
the hunks you have to hunt down             those 2 lines that say "echo 
'This line is runningantoeuhaoeuaoae'"
2. All of the safety concerns can be alleviated with the right 
interface. I am glad the u option mentioned in the thread did not go 
through since I agree it is not ideal. However, if the command is:
     (a) something with a '!', then no one will hit it by mistake, and
     (b) the prompt makes it clear that work is lost
then I think it would be fine

The advantages of a command like this are pretty huge IMO. I can see this being a big time saver.

How about adding this to the git add -p prompt:
     r! - remove this hunk. The hunk is discarded from the working tree, 
and is irrevocably lost.
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 7 in “Feature request - discard hunk in add --patch mode”
  1. Mina AlmasryAug 15, 2012
  2. Thomas RastAug 15, 2012
  3. Junio C HamanoAug 15, 2012
  4. Junio C HamanoAug 15, 2012
  5. Mina AlmasryAug 15, 2012
  6. Junio C HamanoAug 15, 2012
  7. Mina AlmasryAug 23, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.