All of lore.kernel.org
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Christian Neukirchen <chneukirchen@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: git commit -p with file arguments
Date: Fri, 9 Sep 2016 17:54:30 +0700	[thread overview]
Message-ID: <CACsJy8DOqoW8quz-6qSVR2+3aJau2V=qXCx_SoZvBpmU+9+Oxw@mail.gmail.com> (raw)
In-Reply-To: <87zinmhx68.fsf@juno.home.vuxu.org>

On Tue, Sep 6, 2016 at 4:08 AM, Christian Neukirchen
<chneukirchen@gmail.com> wrote:
> Hi,
>
> I noticed the following suprising behavior:
>
> % git --version
> git version 2.10.0
>
> % git add bar
> % git status -s
> A  bar
>  M foo
>
> % git commit -p foo
> [stage a hunk]
> ...
> # Explicit paths specified without -i or -o; assuming --only paths...
> # On branch master
> # Changes to be committed:
> #       new file:   bar
> #       modified:   foo
> #
>
> So why does it want to commit bar too, when I explicitly wanted to
> commit foo only?
>
> This is not how "git commit files..." works, and the man page says
>
>             3.by listing files as arguments to the commit command, in which
>            case the commit will ignore changes staged in the index, and
>            instead record the current content of the listed files (which must
>            already be known to Git);
>
> I'd expect "git commit -p files..." to work like
> "git add -p files... && git commit files...".

The paths after '-p' could mean two things, either as a filter (e.g.
like in "git add -p") to help save your time going through all changed
files, or as "git commit files...". I think the paths were meant to be
filter when '-p' was added. There's a separate bullet point git-commit
man page, number 5, in about --patch, so that paragraph you quoted is
probably _not_ about --patch. Either way changing its behavior now
might surprise users used to it.

At the least I think we should clarify this in the document. Maybe we
could add --patch-only as well, which commits just what you select in
--patch mode, ignoring anything in existing index.
-- 
Duy

  reply	other threads:[~2016-09-09 10:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05 21:08 git commit -p with file arguments Christian Neukirchen
2016-09-09 10:54 ` Duy Nguyen [this message]
2016-10-05 10:26   ` Duy Nguyen
2016-10-05 11:38     ` Christian Neukirchen
2016-10-05 17:16     ` Junio C Hamano
2016-09-09 16:57 ` Jacob Keller
2016-09-09 17:05   ` Christian Neukirchen
2016-09-09 18:03   ` Junio C Hamano
2016-09-09 20:39     ` Jakub Narębski
2016-09-09 20:52       ` Christian Neukirchen
2016-09-10  9:52         ` Jakub Narębski
2016-09-11 21:50           ` Junio C Hamano
2016-09-11 22:05             ` Jacob Keller
2016-09-12  1:57               ` Junio C Hamano
2016-09-12  4:56                 ` Jacob Keller
2016-09-12 21:14                 ` Jakub Narębski

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

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

  git send-email \
    --in-reply-to='CACsJy8DOqoW8quz-6qSVR2+3aJau2V=qXCx_SoZvBpmU+9+Oxw@mail.gmail.com' \
    --to=pclouds@gmail.com \
    --cc=chneukirchen@gmail.com \
    --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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.