All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Sven Strickroth <sven@cs-ware.de>, git@vger.kernel.org
Subject: Re: RFC: git status --amend
Date: Tue, 31 Mar 2015 11:35:17 -0700	[thread overview]
Message-ID: <xmqqvbhhqal6.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20150331180414.GB19206@peff.net> (Jeff King's message of "Tue, 31 Mar 2015 14:04:14 -0400")

Jeff King <peff@peff.net> writes:

> On Tue, Mar 31, 2015 at 04:59:27PM +0200, Sven Strickroth wrote:
>
>> for frontends or scripts it would be helpful to be able to use "git
>> status" for getting the repository status compared to HEAD~1 instead of
>> only HEAD (as provided by "git commit --amend" in the pre-filled commit
>> message).
>> 
>> Thus, I'm suggesting to add a "--amend" parameter (or a parameter with a
>> better naming) to "git status".
>> 
>> What do you think of this idea?
>
> Once upon a time "git status" really was just "git commit --dry-run".
> These days it has diverged a bit. But I think you could get what you
> want with:
>
>   git commit --dry-run --amend
>
> It even supports alternate styles like --short.

I think everything you said is correct, but your "diverged a bit"
may hide one difference that could be crucial depending on the use
case: pathspec.

What "git commit --dry-run [--other-options] <pathspec>" does, and
what "git status [--other-options] <pathspec>" does, are different.

With or without --dry-run, to "git commit", <pathspec> tells the
command to update the index at the paths specified by it from the
working tree contents before proceeding (the contents recorded for
the other paths depend on the use of -o or -i option).  But ever
since "git status" departed from being "git commit -n", a pathspec
given to the command means completely different thing.

After working on various parts of the tree, planning to conclude the
current work with "commit", "git status directory/" is a good way to
see what you did in that directory without seeing what you did
outside (which will be included in the commit, too).

But what you get from "git commit --no-edit --dry-run directory/"
would be different; it would show all the changes in the working
tree inside directory/, including the ones that you deliberately
left out of the index, as paths to be committed.

Having said all that, I am a bit torn on this topic.  Just like "git
status" is a way to ask "I've worked so far, planning to conclude
this with 'git commit'; tell me what I have achieved so far that are
in the index and in the working tree, possibly limiting to these
paths?", I think it is a reasonable thing to ask the same question
with "s/git commit/git commit --amend/".

One workaround might be to

    git reset --soft HEAD^
    git status [<pathspec>]
    ...
    git commit -c @{1}

but that is simply too error prone and ugly.  I would say it would
be better if "status" knows how to answer that "I am planning to
conclude with 'git commit --amend'" question.

The reason why I am torn is because I do not think "status --amend"
is a sensible name for that option.  "status" is not about amending
anything.

If the normal "status" is "give me status for the next commit", this
new mode would be "give me status for the 'commit --amend'".  Naming
it "git status --for-amend" crossed my mind, but it does not sound
great to me, either.

So...

  reply	other threads:[~2015-03-31 18:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-31 14:59 RFC: git status --amend Sven Strickroth
2015-03-31 18:04 ` Jeff King
2015-03-31 18:35   ` Junio C Hamano [this message]
2015-04-01  8:43     ` David Aguilar
2015-04-01 17:16       ` Junio C Hamano
2015-04-03 21:57         ` David Aguilar
2015-04-03 22:05           ` Jeff King

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=xmqqvbhhqal6.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=sven@cs-ware.de \
    /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.