threads / rfc / 49149

RFC patchcommit: add short option for --amend

Subject: [PATCH/RFC] commit: add short option for --amend

## tl;dr

9 messages between Aug 16, 2018 and Aug 18, 2018. Diffs are folded; open one to read it.

replies: 8people: 5as markdown or json

Nguyễn Thái Ngọc Duy· Aug 16, 2018, 18:31 UTC · lore

I just realized how often I type "git ci --amend". Looking back at my ~/.bash_history (only 10k lines) this is the second most often git command I type which may justify a short option for it (assuming that other people use this option often too, of course).

The short option space for 'git commit' is really crowded with acCeFhimnopqsStuvz already taken. So it could be '-M' or '-A' but I'd prefer not to hold shift, so I chose '-j' even though it's not strictly related to "amend" (or perhaps we can thinking of amending as joining commits).

Thoughts?
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/commit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to builtin/commit.c +1 −1
diff --git a/builtin/commit.c b/builtin/commit.c
index 213fca2d8e..78f125ba1f 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1489,7 +1489,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 			    STATUS_FORMAT_LONG),
 		OPT_BOOL('z', "null", &s.null_termination,
 			 N_("terminate entries with NUL")),
-		OPT_BOOL(0, "amend", &amend, N_("amend previous commit")),
+		OPT_BOOL('j', "amend", &amend, N_("amend previous commit")),
 		OPT_BOOL(0, "no-post-rewrite", &no_post_rewrite, N_("bypass post-rewrite hook")),
 		{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, N_("mode"), N_("show untracked files, optional modes: all, normal, no. (Default: all)"), PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
 		/* end commit contents options */
-- 
2.18.0.1004.g6639190530
Jeff King· Aug 16, 2018, 18:39 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: [PATCH/RFC] commit: add short option for --amend

On Thu, Aug 16, 2018 at 08:31:17PM +0200, Nguyễn Thái Ngọc Duy wrote:
Show 12 quoted lines
> I just realized how often I type "git ci --amend". Looking back at my
> ~/.bash_history (only 10k lines) this is the second most often git
> command I type which may justify a short option for it (assuming that
> other people use this option often too, of course).
> 
> The short option space for 'git commit' is really crowded with
> acCeFhimnopqsStuvz already taken. So it could be '-M' or '-A' but I'd
> prefer not to hold shift, so I chose '-j' even though it's not
> strictly related to "amend" (or perhaps we can thinking of amending as
> joining commits).
> 
> Thoughts?
I also used to type it a lot. So I did:
  $ type a
  a is aliased to `git commit --amend'
I don't know if that argues for or against a short option.
-Peff
Duy Nguyen· Aug 16, 2018, 18:46 UTC · re: Jeff King · lore

Re: [PATCH/RFC] commit: add short option for --amend

On Thu, Aug 16, 2018 at 8:39 PM Jeff King <peff@peff.net> wrote:
Show 22 quoted lines
>
> On Thu, Aug 16, 2018 at 08:31:17PM +0200, Nguyễn Thái Ngọc Duy wrote:
>
> > I just realized how often I type "git ci --amend". Looking back at my
> > ~/.bash_history (only 10k lines) this is the second most often git
> > command I type which may justify a short option for it (assuming that
> > other people use this option often too, of course).
> >
> > The short option space for 'git commit' is really crowded with
> > acCeFhimnopqsStuvz already taken. So it could be '-M' or '-A' but I'd
> > prefer not to hold shift, so I chose '-j' even though it's not
> > strictly related to "amend" (or perhaps we can thinking of amending as
> > joining commits).
> >
> > Thoughts?
>
> I also used to type it a lot. So I did:
>
>   $ type a
>   a is aliased to `git commit --amend'
>
> I don't know if that argues for or against a short option.
It's a "for" for me because I won't have my aliases on other people's machines.
-- 
Duy
Jonathan Nieder· Aug 17, 2018, 06:47 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: [PATCH/RFC] commit: add short option for --amend

Nguyễn Thái Ngọc Duy wrote:
Show 8 quoted lines
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1489,7 +1489,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>  			    STATUS_FORMAT_LONG),
>  		OPT_BOOL('z', "null", &s.null_termination,
>  			 N_("terminate entries with NUL")),
> -		OPT_BOOL(0, "amend", &amend, N_("amend previous commit")),
> +		OPT_BOOL('j', "amend", &amend, N_("amend previous commit")),
[...]
> Thoughts?

I'm not a fan. I would have trouble remembering what the short option name means, and it matches the common --jobs option for parallelism that many commands use. "git commit --am" works today already and doesn't run into those problems.

I'm sympathetic to the goal of saving typing, but I'm more sympathetic to the goal of making user support easier, which is what makes me end up there.

That said, I've been looking recently at Mercurial's "hg evolve" extension[1] and I wouldn't be against a well thought out new command (e.g. "git amend") that does the equivalent of "git commit --amend" with some related features. So I think there are some paths forward that involve abbreviating.

Thanks, Jonathan

[1] https://www.mercurial-scm.org/wiki/EvolveExtension
Duy Nguyen· Aug 17, 2018, 14:33 UTC · re: Jonathan Nieder · lore

Re: [PATCH/RFC] commit: add short option for --amend

On Fri, Aug 17, 2018 at 8:47 AM Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 18 quoted lines
>
> Nguyễn Thái Ngọc Duy wrote:
>
> > --- a/builtin/commit.c
> > +++ b/builtin/commit.c
> > @@ -1489,7 +1489,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
> >                           STATUS_FORMAT_LONG),
> >               OPT_BOOL('z', "null", &s.null_termination,
> >                        N_("terminate entries with NUL")),
> > -             OPT_BOOL(0, "amend", &amend, N_("amend previous commit")),
> > +             OPT_BOOL('j', "amend", &amend, N_("amend previous commit")),
> [...]
> > Thoughts?
>
> I'm not a fan.  I would have trouble remembering what the short option
> name means, and it matches the common --jobs option for parallelism
> that many commands use.  "git commit --am" works today already and
> doesn't run into those problems.

The alternative is -A or -M which may be easier associated with --amend. That "--am" also would break the moment somebody adds --amsomething.

Show 9 quoted lines
> I'm sympathetic to the goal of saving typing, but I'm more sympathetic
> to the goal of making user support easier, which is what makes me end
> up there.
>
> That said, I've been looking recently at Mercurial's "hg evolve"
> extension[1] and I wouldn't be against a well thought out new command
> (e.g. "git amend") that does the equivalent of "git commit --amend"
> with some related features.  So I think there are some paths forward
> that involve abbreviating.

I'm not opposed to a new command like this, but I don't think it should stop us from adding short options.

-- 
Duy
Jeff King· Aug 17, 2018, 15:26 UTC · re: Duy Nguyen · lore

Re: [PATCH/RFC] commit: add short option for --amend

On Fri, Aug 17, 2018 at 04:33:30PM +0200, Duy Nguyen wrote:
Show 23 quoted lines
> On Fri, Aug 17, 2018 at 8:47 AM Jonathan Nieder <jrnieder@gmail.com> wrote:
> >
> > Nguyễn Thái Ngọc Duy wrote:
> >
> > > --- a/builtin/commit.c
> > > +++ b/builtin/commit.c
> > > @@ -1489,7 +1489,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
> > >                           STATUS_FORMAT_LONG),
> > >               OPT_BOOL('z', "null", &s.null_termination,
> > >                        N_("terminate entries with NUL")),
> > > -             OPT_BOOL(0, "amend", &amend, N_("amend previous commit")),
> > > +             OPT_BOOL('j', "amend", &amend, N_("amend previous commit")),
> > [...]
> > > Thoughts?
> >
> > I'm not a fan.  I would have trouble remembering what the short option
> > name means, and it matches the common --jobs option for parallelism
> > that many commands use.  "git commit --am" works today already and
> > doesn't run into those problems.
> 
> The alternative is -A or -M which may be easier associated with
> --amend. That "--am" also would break the moment somebody adds
> --amsomething.

I think "-A" has been considered as possibility for matching "commit -a" / "add -A" in the past, but I had trouble finding past discussion (searching for "A" in the mailing list is not very productive). It was mentioned in 3ba1f11426 (git-add --all: add all files, 2008-07-19), but that was quite a while ago.

Not necessarily a blocker, but something to consider.

Like Jonathan, I do find "-j" a little non-intuitive, but I agree that most of the intuitive ones are taken. :)

-Peff
Duy Nguyen· Aug 17, 2018, 15:31 UTC · re: Jeff King · lore

Re: [PATCH/RFC] commit: add short option for --amend

On Fri, Aug 17, 2018 at 5:26 PM Jeff King <peff@peff.net> wrote:
Show 37 quoted lines
>
> On Fri, Aug 17, 2018 at 04:33:30PM +0200, Duy Nguyen wrote:
>
> > On Fri, Aug 17, 2018 at 8:47 AM Jonathan Nieder <jrnieder@gmail.com> wrote:
> > >
> > > Nguyễn Thái Ngọc Duy wrote:
> > >
> > > > --- a/builtin/commit.c
> > > > +++ b/builtin/commit.c
> > > > @@ -1489,7 +1489,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
> > > >                           STATUS_FORMAT_LONG),
> > > >               OPT_BOOL('z', "null", &s.null_termination,
> > > >                        N_("terminate entries with NUL")),
> > > > -             OPT_BOOL(0, "amend", &amend, N_("amend previous commit")),
> > > > +             OPT_BOOL('j', "amend", &amend, N_("amend previous commit")),
> > > [...]
> > > > Thoughts?
> > >
> > > I'm not a fan.  I would have trouble remembering what the short option
> > > name means, and it matches the common --jobs option for parallelism
> > > that many commands use.  "git commit --am" works today already and
> > > doesn't run into those problems.
> >
> > The alternative is -A or -M which may be easier associated with
> > --amend. That "--am" also would break the moment somebody adds
> > --amsomething.
>
> I think "-A" has been considered as possibility for matching "commit -a"
> / "add -A" in the past, but I had trouble finding past discussion
> (searching for "A" in the mailing list is not very productive). It was
> mentioned in 3ba1f11426 (git-add --all: add all files, 2008-07-19), but
> that was quite a while ago.
>
> Not necessarily a blocker, but something to consider.
>
> Like Jonathan, I do find "-j" a little non-intuitive, but I agree that
> most of the intuitive ones are taken. :)

Oh well. Maybe next time we'll be more careful with adding short options. Consider this patch dropped.

-- 
Duy
Junio C Hamano· Aug 17, 2018, 15:31 UTC · re: Duy Nguyen · lore

Re: [PATCH/RFC] commit: add short option for --amend

Duy Nguyen <pclouds@gmail.com> writes:
> The alternative is -A or -M which may be easier associated with
> --amend.

I would be confused to mistake that "git commit -A $args" would do something similar to "git add -A && git commit $args".

I do my fair share of amends during the day, and I've never felt the need for a short-hand, but perhaps that is just me. I am wondering if "-E" (stands for 'edit', not 'A or M are out, and the next letter in amend is E') is understandable and memorable enough---after all, it is "editing" an existing commit, and the edit is done in a big and different way than the existing "commit --edit".

But perhaps that reasoning is a bit too cute.  I dunno.
Simon Ruderich· Aug 18, 2018, 07:24 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: [PATCH/RFC] commit: add short option for --amend

On Thu, Aug 16, 2018 at 08:31:17PM +0200, Nguyễn Thái Ngọc Duy wrote:
> I just realized how often I type "git ci --amend". Looking back at my
> ~/.bash_history (only 10k lines) this is the second most often git
> command I type which may justify a short option for it (assuming that
> other people use this option often too, of course).

Why not add another alias? As you're already using the ci alias, maybe cia? Personally I have the following aliases for committing:

        c   = commit --verbose
        ca  = commit --verbose --amend
        cad = commit --verbose --amend --date=now

Besides the obvious g=git alias in the shell. I really like one character aliases for often used commands/subcommands.

Regards Simon

-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

← back to recent threads