git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Maarten de Vries <maarten@de-vri.es>
To: git mailing list <git@vger.kernel.org>
Subject: Re: Bug report: reset -p HEAD
Date: Fri, 25 Oct 2013 01:16:55 +0200	[thread overview]
Message-ID: <CAPWpf+zkA68pzR3qx5xma8BNiONwt5o8iNba0x8fmmiDAWpHuw@mail.gmail.com> (raw)
In-Reply-To: <CAPWpf+x5KUjD2K81pJAsV_XuPkd=BT06qPjvr8s7tEe5YqBt=w@mail.gmail.com>

Some more info: It used to work as intended. Using a bisect shows it
has been broken by commit 166ec2e9.

Kinds regards,
Maarten de Vries

On 25 October 2013 01:05, Maarten de Vries <maarten@de-vri.es> wrote:
> Hi,
>
> I noticed that reset -p HEAD is inconsistent with checkout -p HEAD.
> When running checkout -p you are asked to discard hunks from the index
> and worktree, but when running reset -p you are asked to apply hunks
> to the index. It would make more sense if reset -p asked to discard
> (reversed) hunks from the index.
>
> Digging a bit further, it looks like reset -p is actually intended to
> show hunks to discard when resetting to HEAD. The
> git-add--interactive.perl script has different cases for resetting to
> the head and for resetting to anything else. However, builtin/reset.c
> always passes a hash to run_add_interactive, even if HEAD is provided
> explicitly on the command line or no revision is given. As a result,
> the special case for resetting to the HEAD is never triggered and
> git-add--interactive.perl always asks to apply hunks rather than
> discard the reverse hunks.
>
> The offending part in builtin/reset.c is on line 307. It's the bit
> with sha1_to_hex(sha1):
>>     if (patch_mode) {
>>         if (reset_type != NONE)
>>             die(_("--patch is incompatible with --{hard,mixed,soft}"));
>>         return run_add_interactive(sha1_to_hex(sha1), "--patch=reset", &pathspec);
>>     }
>
> I'm not familiar enough with the git source, but it's probably a
> fairly trivial fix for someone who is.
>
>
> Kind regards,
> Maarten de Vries
>
>
> P.S.
>
> This bit in git-add--interactive.perl convinced me that resetting to
> HEAD interactively should be handled separately:
>>     'reset_head' => {
>>         DIFF => 'diff-index -p --cached',
>>         APPLY => sub { apply_patch 'apply -R --cached', @_; },
>>         APPLY_CHECK => 'apply -R --cached',
>>         VERB => 'Unstage',
>>         TARGET => '',
>>         PARTICIPLE => 'unstaging',
>>         FILTER => 'index-only',
>>         IS_REVERSE => 1,
>>     },
>>     'reset_nothead' => {
>>         DIFF => 'diff-index -R -p --cached',
>>         APPLY => sub { apply_patch 'apply --cached', @_; },
>>         APPLY_CHECK => 'apply --cached',
>>         VERB => 'Apply',
>>         TARGET => ' to index',
>>         PARTICIPLE => 'applying',
>>         FILTER => 'index-only',
>>         IS_REVERSE => 0,
>>     },

  reply	other threads:[~2013-10-24 23:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAPWpf+wi0zH2sOnuqiZuKkf+kC0RMug_ASb-J-TGGLd2RFT1wg@mail.gmail.com>
     [not found] ` <CAPWpf+xqutvhq1jyVkxr6LyKsANTCS6M=vj5XY=EgUfiS3Z8xg@mail.gmail.com>
2013-10-24 23:05   ` Fwd: Bug report: reset -p HEAD Maarten de Vries
2013-10-24 23:16     ` Maarten de Vries [this message]
2013-10-25  3:40       ` Re* " Junio C Hamano
2013-10-25  4:24         ` Jeff King
2013-10-25  5:42           ` Martin von Zweigbergk
2013-10-25  6:51             ` [PATCH 0/2] reset -p and unborn branches Jeff King
2013-10-25  6:52               ` [PATCH 1/2] add-interactive: handle unborn branch in patch mode Jeff King
2013-10-25  6:54               ` [PATCH 2/2] reset: pass real rev name to add--interactive Jeff King
2013-10-25 16:54           ` Re* Bug report: reset -p HEAD Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPWpf+zkA68pzR3qx5xma8BNiONwt5o8iNba0x8fmmiDAWpHuw@mail.gmail.com \
    --to=maarten@de-vri.es \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).