Skip to contentSkip to conversation

commit: add short option for --amend

PATCH/RFC Nguyễn Thái Ngọc Duy 5 participants 9 messages Aug 16, 2018 – Aug 18, 2018

lore
Share & tools
lore
#0 lore raw

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?

---
 builtin/commit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
builtin/commit.c +1 -1
index 213fca2d8e..78f125ba1f 100644
@@ -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 */
Signature · 1 line
2.18.0.1004.g6639190530
#1 lore raw
Quoted 5 lines · Nguyễn Thái Ngọc Duy

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).

Quoted 7 lines

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

author
#2 lore raw
Quoted 14 lines · Jeff King
Quoted 11 lines · Nguyễn Thái Ngọc Duy

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).

Quoted 8 lines
Quoted 1 line

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.

Signature · 1 line
Duy
#3 lore raw
In reply to Nguyễn Thái Ngọc Duy
Quoted 8 lines · Nguyễn Thái Ngọc Duy
builtin/commit.c +1 -1
@@ -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")),

[...]

Quoted 1 line

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

author
#4 lore raw
Quoted 12 lines · Jonathan Nieder
Quoted 8 lines · Nguyễn Thái Ngọc Duy
builtin/commit.c +1 -1
@@ -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")),

[...]

Quoted 6 lines
Quoted 1 line

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.

Quoted 9 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.

Signature · 1 line
Duy
#5 lore raw
Quoted 15 lines · Duy Nguyen
Quoted 14 lines · Jonathan Nieder
Quoted 8 lines · Nguyễn Thái Ngọc Duy
builtin/commit.c +1 -1
@@ -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")),

[...]

Quoted 1 line

Thoughts?

Quoted 8 lines
Quoted 4 lines

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

#7 lore raw
In reply to Duy Nguyen
Quoted 2 lines · Duy Nguyen

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.

author
#6 lore raw
In reply to Jeff King
Quoted 33 lines · Jeff King
Quoted 15 lines · Duy Nguyen
Quoted 14 lines · Jonathan Nieder
Quoted 8 lines · Nguyễn Thái Ngọc Duy
builtin/commit.c +1 -1
@@ -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")),

[...]

Quoted 1 line

Thoughts?

Quoted 8 lines
Quoted 4 lines

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.

Quoted 4 lines

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.

Signature · 1 line
Duy
#8 lore raw
In reply to Nguyễn Thái Ngọc Duy
Quoted 4 lines · Nguyễn Thái Ngọc Duy

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

Signature · 3 lines
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9