rebase -i: add config to abbreviate command name
PATCH 1/1 rebase -i: add config to abbreviate command name
Add the 'rebase.abbrevCmd' boolean config option to allow the user to abbreviate the default command name while editing the 'git-rebase-todo' file.
---
Notes:
* This allows the lines to remain aligned when using single letter commands.
Documentation/config.txt | 3 +++ Documentation/git-rebase.txt | 3 +++ git-rebase--interactive.sh | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-)
Documentation/config.txt +3 -0
@@ -2614,6 +2614,9 @@ rebase.instructionFormat:: the instruction list during an interactive rebase. The format will automatically have the long commit hash prepended to the format. +rebase.abbrevCmd:: + If set to true, abbreviate command name in interactive mode. + receive.advertiseAtomic:: By default, git-receive-pack will advertise the atomic push capability to its clients. If you don't want to advertise this
Documentation/git-rebase.txt +3 -0
@@ -222,6 +222,9 @@ rebase.missingCommitsCheck:: rebase.instructionFormat:: Custom commit list format to use during an `--interactive` rebase. +rebase.abbrevCmd:: + If set to true, abbreviate command name in interactive mode. + OPTIONS ------- --onto <newbase>::
git-rebase--interactive.sh +6 -2
@@ -1210,6 +1210,10 @@ else revisions=$onto...$orig_head shortrevisions=$shorthead fi + +rebasecmd=pick +test "$(git config --bool --get rebase.abbrevCmd)" = true && rebasecmd=p + format=$(git config --get rebase.instructionFormat) # the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse git rev-list $merges_option --format="%m%H ${format:-%s}" \
@@ -1228,7 +1232,7 @@ do if test t != "$preserve_merges" then - printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" else if test -z "$rebase_root" then
@@ -1246,7 +1250,7 @@ do if test f = "$preserve" then touch "$rewritten"/$sha1 - printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" fi fi done
Signature · 1 line
2.9.3
Hi Liam,
Quoted 3 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow the user to abbreviate the default command name while editing the 'git-rebase-todo' file.
This patch does not handle the git rebase --edit-todo subcommand. Intentional?
Ciao,
Johannes
Hi,
Quoted 10 lines · Johannes Schindelin
Hi Liam,
Quoted 3 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow the user to abbreviate the default command name while editing the 'git-rebase-todo' file.
This patch does not handle the
git rebase --edit-todosubcommand. Intentional?
no, this is not intentional, I'll make the changes.
Quoted 3 lines
Ciao,
Johannes
Thanks,
Liam
Quoted 3 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow the user to abbreviate the default command name while editing the 'git-rebase-todo' file.
Just reading this, I was confused about what the patch actually did. Reading the code, I figured it out, but perhaps an example would make sense. Like:
This means that we will print:
p 1234abcd subject line
in the todo file rather than:
pick 1234abcd subject line
And then of course that left me wondering why somebody would want to do that. I understand wanting to _type_ the abbreviated version, but surely it's not too much work to read the full word?
Then I saw:
Quoted 5 lines
---
Notes:* This allows the lines to remain aligned when using single letter commands.
That makes some sense. it should probably be part of the commit message, so that future readers of "git log" understand why the change was made.
Documentation/config.txt rebase.instructionFormat:: · line 2618
Quoted 10 lines
Documentation/config.txt +2
-0@@ -2614,6 +2614,9 @@ rebase.instructionFormat:: the instruction list during an interactive rebase. The format will automatically have the long commit hash prepended to the format. +rebase.abbrevCmd:: + If set to true, abbreviate command name in interactive mode.
Similar to the commit message, this might need to go into more detail. It was not immediately obvious to me that "command name" means the command-names in the instruction list.
-Peff
Hi Johannes,
Quoted 10 lines · Johannes Schindelin
Hi Liam,
Quoted 3 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow the user to abbreviate the default command name while editing the 'git-rebase-todo' file.
This patch does not handle the
git rebase --edit-todosubcommand. Intentional?
After a little more investigation, I'm not sure what should be added for the git rebase --edit-todo subcommand. It seems like it uses the same text that was added the first time (with git rebase -i).
Do you have a bit more information about what you meant?
I don't use this subcommand very often, I'm most likely missing something.
Quoted 3 lines
Ciao,
Johannes
Thanks,
Liam
PATCH v2 1/1 rebase -i: add config to abbreviate command-names
In reply to Liam BeguinAdd the 'rebase.abbrevCmd' boolean config option to allow git rebase -i to abbreviate the command-names in the instruction list.
This means that git rebase -i would print:
p deadbee The oneline of this commit
...
instead of:
pick deadbee The oneline of this commit
...
Using a single character command-name allows the lines to remain aligned, making the whole set more readable.
---
Changes since v1:
- Improve Documentation and commit message
Documentation/config.txt | 19 +++++++++++++++++++ Documentation/git-rebase.txt | 19 +++++++++++++++++++ git-rebase--interactive.sh | 8 ++++++-- 3 files changed, 44 insertions(+), 2 deletions(-)
Documentation/config.txt +19 -0
@@ -2614,6 +2614,25 @@ rebase.instructionFormat:: the instruction list during an interactive rebase. The format will automatically have the long commit hash prepended to the format. +rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this, + +------------------------------------------- + pick deadbee The oneline of this commit + pick fa1afe1 The oneline of the next commit + ... +------------------------------------------- + + the list would use the short version of the command resulting in + something like this. + +------------------------------------------- + p deadbee The oneline of this commit + p fa1afe1 The oneline of the next commit + ... +------------------------------------------- + receive.advertiseAtomic:: By default, git-receive-pack will advertise the atomic push capability to its clients. If you don't want to advertise this
Documentation/git-rebase.txt +19 -0
@@ -222,6 +222,25 @@ rebase.missingCommitsCheck:: rebase.instructionFormat:: Custom commit list format to use during an `--interactive` rebase. +rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this, + +------------------------------------------- + pick deadbee The oneline of this commit + pick fa1afe1 The oneline of the next commit + ... +------------------------------------------- + + the list would use the short version of the command resulting in + something like this. + +------------------------------------------- + p deadbee The oneline of this commit + p fa1afe1 The oneline of the next commit + ... +------------------------------------------- + OPTIONS ------- --onto <newbase>::
git-rebase--interactive.sh +6 -2
@@ -1210,6 +1210,10 @@ else revisions=$onto...$orig_head shortrevisions=$shorthead fi + +rebasecmd=pick +test "$(git config --bool --get rebase.abbrevCmd)" = true && rebasecmd=p + format=$(git config --get rebase.instructionFormat) # the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse git rev-list $merges_option --format="%m%H ${format:-%s}" \
@@ -1228,7 +1232,7 @@ do if test t != "$preserve_merges" then - printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" else if test -z "$rebase_root" then
@@ -1246,7 +1250,7 @@ do if test f = "$preserve" then touch "$rewritten"/$sha1 - printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" fi fi done
Signature · 1 line
2.9.3
PATCH v2 1/1 rebase -i: add config to abbreviate command-names
In reply to Liam BeguinAdd the 'rebase.abbrevCmd' boolean config option to allow git rebase -i to abbreviate the command-names in the instruction list.
This means that git rebase -i would print:
p deadbee The oneline of this commit
...
instead of:
pick deadbee The oneline of this commit
...
Using a single character command-name allows the lines to remain aligned, making the whole set more readable.
---
Changes since v1:
- Improve Documentation and commit message
Documentation/config.txt | 19 +++++++++++++++++++ Documentation/git-rebase.txt | 19 +++++++++++++++++++ git-rebase--interactive.sh | 8 ++++++-- 3 files changed, 44 insertions(+), 2 deletions(-)
Documentation/config.txt +19 -0
@@ -2614,6 +2614,25 @@ rebase.instructionFormat:: the instruction list during an interactive rebase. The format will automatically have the long commit hash prepended to the format. +rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this, + +------------------------------------------- + pick deadbee The oneline of this commit + pick fa1afe1 The oneline of the next commit + ... +------------------------------------------- + + the list would use the short version of the command resulting in + something like this. + +------------------------------------------- + p deadbee The oneline of this commit + p fa1afe1 The oneline of the next commit + ... +------------------------------------------- + receive.advertiseAtomic:: By default, git-receive-pack will advertise the atomic push capability to its clients. If you don't want to advertise this
Documentation/git-rebase.txt +19 -0
@@ -222,6 +222,25 @@ rebase.missingCommitsCheck:: rebase.instructionFormat:: Custom commit list format to use during an `--interactive` rebase. +rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this, + +------------------------------------------- + pick deadbee The oneline of this commit + pick fa1afe1 The oneline of the next commit + ... +------------------------------------------- + + the list would use the short version of the command resulting in + something like this. + +------------------------------------------- + p deadbee The oneline of this commit + p fa1afe1 The oneline of the next commit + ... +------------------------------------------- + OPTIONS ------- --onto <newbase>::
git-rebase--interactive.sh +6 -2
@@ -1210,6 +1210,10 @@ else revisions=$onto...$orig_head shortrevisions=$shorthead fi + +rebasecmd=pick +test "$(git config --bool --get rebase.abbrevCmd)" = true && rebasecmd=p + format=$(git config --get rebase.instructionFormat) # the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse git rev-list $merges_option --format="%m%H ${format:-%s}" \
@@ -1228,7 +1232,7 @@ do if test t != "$preserve_merges" then - printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" else if test -z "$rebase_root" then
@@ -1246,7 +1250,7 @@ do if test f = "$preserve" then touch "$rewritten"/$sha1 - printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" fi fi done
Signature · 1 line
2.9.3
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Liam BeguinQuoted 10 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow
git rebase -ito abbreviate the command-names in the instruction list.This means that
git rebase -iwould print:
p deadbee The oneline of this commit
...instead of:
pick deadbee The oneline of this commit
...
Whenever I see "This means that...", my automatic reaction is "The author expects what s/he wrote previously is not understandable, and is making another try to give something more readable. As this is not a real time communication, why not rewrite the incomprehensible part before wasting the time of the readers by throwing at them what is known to the author to be unreadble, only to clarify with 'This means that...' later?"
But I think in this case, you do not even have to say "This means that". What you wrote, without "This means that", i.e.
Add the 'rebase.abbrevCommand' configuration variable to tell git rebase -i to show commands abbreviated in the instruction list, i.e.
p deadbee The oneline of this commit
...
instead of:
pick deadbee The oneline of this commit
...
is quite readable.
Quoted 2 lines
Using a single character command-name allows the lines to remain aligned, making the whole set more readable.
Hmph. I have trouble with "lines remain aligned". Depending on the object names of commits, don't you end up getting something like this that is not aligned?
p deadbee The oneline
p e2cb6ab8 Another commit
Or are you happy with only the beginning of object names aligned, without the actual titles aligned?
Personally I am happy with the beginning of each instruction line aligned, so from that point of view, this patch is a mild Meh to me, even though I do a fair amount of "rebase -i" myself. But obviously I am not the only user of Git you need to please, so...
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
Quoted 4 lines · Junio C Hamano
Personally I am happy with the beginning of each instruction line aligned, so from that point of view, this patch is a mild Meh to me, even though I do a fair amount of "rebase -i" myself. But obviously I am not the only user of Git you need to please, so...
I would instead justify this as making it easier to change the action, since you only need to rewrite a single letter, which at least in vim takes "r<letter>" to change the action, vs slightly more keystrokes such as "ct <letter" or otherwise.
Also, if you change the default commit hash length, it becomes long enough to cover most commits and you see all commits at say 12 digits commit hash and everything is nicely aligned.
Thanks,
Jake
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Liam BeguinQuoted 16 lines · Liam Beguin
Documentation/config.txt +8
-0@@ -2614,6 +2614,25 @@ rebase.instructionFormat:: the instruction list during an interactive rebase. The format will automatically have the long commit hash prepended to the format. +rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this, + +------------------------------------------- + pick deadbee The oneline of this commit + pick fa1afe1 The oneline of the next commit + ...
Documentation/config.txt rebase.instructionFormat:: · line 2634
Quoted 10 lines
Documentation/config.txt +10
-0+------------------------------------------- + + the list would use the short version of the command resulting in + something like this. + +------------------------------------------- + p deadbee The oneline of this commit + p fa1afe1 The oneline of the next commit + ... +-------------------------------------------
That doesn't explain the point of the option.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Liam BeguinQuoted 7 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow
git rebase -ito abbreviate the command-names in the instruction list.This means that
git rebase -iwould print:
p deadbee The oneline of this commit
...
Quoted 6 lines
instead of:
pick deadbee The oneline of this commit
...Using a single character command-name allows the lines to remain aligned, making the whole set more readable.
Perhaps there should rather be an option to tell rebase to align the columns?
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Liam BeguinFrom: "Liam Beguin" <[email protected]>
Quoted 35 lines
Add the 'rebase.abbrevCmd' boolean config option to allow
git rebase -ito abbreviate the command-names in the instruction list.This means that
git rebase -iwould print:
p deadbee The oneline of this commit
...instead of:
pick deadbee The oneline of this commit
...Using a single character command-name allows the lines to remain aligned, making the whole set more readable.
Signed-off-by Liam Beguin <[email protected]>---
Changes since v1:
- Improve Documentation and commit messageDocumentation/config.txt | 19 +++++++++++++++++++ Documentation/git-rebase.txt | 19 +++++++++++++++++++ git-rebase--interactive.sh | 8 ++++++-- 3 files changed, 44 insertions(+), 2 deletions(-)Documentation/config.txt +0
-0@@ -2614,6 +2614,25 @@ rebase.instructionFormat:: the instruction list during an interactive rebase. The format willautomatically
have the long commit hash prepended to the format.Documentation/config.txt +2
-0+rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the
Documentation/config.txt rebase.instructionFormat:: · line 2628
Quoted 10 lines
Documentation/config.txt +10
-0+ instruction list. This means that instead of looking like this, + +------------------------------------------- + pick deadbee The oneline of this commit + pick fa1afe1 The oneline of the next commit + ... +------------------------------------------- + + the list would use the short version of the command resulting in + something like this.
Perhaps use an example which does have rebase commands of different lengths, such as 'pick', 'squash', 'reword' to more clearly show the intent of alignment and subsequent ease of editing?
--
Philip
Quoted 77 lines
Documentation/config.txt +7
-0+ +------------------------------------------- + p deadbee The oneline of this commit + p fa1afe1 The oneline of the next commit + ... +------------------------------------------- +receive.advertiseAtomic::
By default, git-receive-pack will advertise the atomic push capability to its clients. If you don't want to advertise thisDocumentation/git-rebase.txt +0
-0@@ -222,6 +222,25 @@ rebase.missingCommitsCheck::rebase.instructionFormat::
Custom commit list format to use during an--interactiverebase.Documentation/git-rebase.txt +19
-0+rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this, + +------------------------------------------- + pick deadbee The oneline of this commit + pick fa1afe1 The oneline of the next commit + ... +------------------------------------------- + + the list would use the short version of the command resulting in + something like this. + +------------------------------------------- + p deadbee The oneline of this commit + p fa1afe1 The oneline of the next commit + ... +------------------------------------------- +OPTIONS
-------
--onto <newbase>::git-rebase--interactive.sh +0
-0@@ -1210,6 +1210,10 @@ else revisions=$onto...$orig_head shortrevisions=$shortheadfi
git-rebase--interactive.sh +4
-0+ +rebasecmd=pick +test "$(git config --bool --get rebase.abbrevCmd)" = true && rebasecmd=p +format=$(git config --get rebase.instructionFormat)
# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse git rev-list $merges_option --format="%m%H ${format:-%s}" \git-rebase--interactive.sh +2
-2@@ -1228,7 +1232,7 @@ do if test t != "$preserve_merges" then - printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" else if test -z "$rebase_root" then@@ -1246,7 +1250,7 @@ do if test f = "$preserve" then touch "$rewritten"/$sha1 - printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" fi fidone
Signature · 1 line
2.9.3
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Andreas SchwabQuoted 13 lines · Andreas Schwab
Quoted 11 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow
git rebase -ito abbreviate the command-names in the instruction list.This means that
git rebase -iwould print:
p deadbee The oneline of this commit
...instead of:
pick deadbee The oneline of this commit
...
Quoted 6 lines
Quoted 2 lines
Using a single character command-name allows the lines to remain aligned, making the whole set more readable.
Perhaps there should rather be an option to tell rebase to align the columns?
You _can_ set a custom instruction format using the config variable:rebase.instructionFormat. With this, you can align columns using the normal git log format.
For example, I personally use this as my instruction format:
[%an%<|(64)%x5d %s
While, this won't always align perfectly, it may help scratch your itch.
Hi Liam,
Quoted 8 lines · liam BEGUIN
Quoted 6 lines · Johannes Schindelin
Quoted 3 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow the user to abbreviate the default command name while editing the 'git-rebase-todo' file.
Quoted 6 lines
Quoted 2 lines
This patch does not handle the
git rebase --edit-todosubcommand. Intentional?After a little more investigation, I'm not sure what should be added for the
git rebase --edit-todosubcommand. It seems like it uses the same text that was added the first time (withgit rebase -i).
Well, it uses whatever the user may have edited. It may surprise users that their pick does not get converted to p like all the original commands.
Ciao,
Johannes
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Liam BeguinHi Liam,
Quoted 7 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow
git rebase -ito abbreviate the command-names in the instruction list.This means that
git rebase -iwould print:
p deadbee The oneline of this commit
...
Quoted 8 lines
instead of:
pick deadbee The oneline of this commit
...Using a single character command-name allows the lines to remain aligned, making the whole set more readable.
Signed-off-by Liam Beguin <[email protected]>
Apart from either abbreviating commands after --edit-todo, or documenting explicitly that the new config option only concerns the initial todo list, there is another problem that just occurred to me: --exec.
When you call git rebase -x "make DEVELOPER=1 -j15", the idea is to append an "exec make DEVELOPER=1 -j15" line after every pick line. The code in question looks like this:
add_exec_commands () {
{
first=t
while read -r insn rest
do
case $insn in
pick)
test -n "$first" ||
printf "%s" "$cmd"
;;
esac
printf "%s %s\n" "$insn" "$rest"
first=
done
printf "%s" "$cmd"
} <"$1" >"$1.new" &&
mv "$1.new" "$1"
}Obviously, the git-rebase--interactive script expects at this point that the command is spelled out, so your patch needs to change the pick) case to p|pick), I think.
In addition, since the rationale for the new option is to align the lines better, the exec would need to be replaced by x, and as multiple -x options are allowed, you would need something like this at the beginning of add_exec_commands, too:
# abbreviate `exec` if rebase.abbrevCmd is true test p != "$rebasecmd" || cmd="$(echo "$cmd" | sed 's/^exec/x/')"
Also:
Documentation/config.txt rebase.instructionFormat:: · line 2617
Quoted 9 lines
Documentation/config.txt +1
-0@@ -2614,6 +2614,25 @@ rebase.instructionFormat:: the instruction list during an interactive rebase. The format will automatically have the long commit hash prepended to the format. +rebase.abbrevCmd::
It does not fail to amuse that the term "abbrevCmd" is abbreviated heavily itself. However, I would strongly suggest to avoid that. It would be much more pleasant to call the config option rebase.abbreviateCommands
Documentation/config.txt rebase.instructionFormat:: · line 2619
Quoted 3 lines
Documentation/config.txt +3
-0+rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this,
This is by no means your fault, but it is really horrible by how many different names Git's documentation refers to the todo script, nothing short of confusing. It is the todo script (which I called it initially, maybe not a good name, but it has the merit of the longest tradition at least), the todo list, the instruction sheet, the rebase script, the instruction list... etc
However, the thing is called "todo list" elsewhere in the same file, therefore lets try to avoid even more confusion and use that term instead of "instruction list" here.
git-rebase--interactive.sh else · line 1215
Quoted 11 lines
git-rebase--interactive.sh +3
-0@@ -1210,6 +1210,10 @@ else revisions=$onto...$orig_head shortrevisions=$shorthead fi + +rebasecmd=pick +test "$(git config --bool --get rebase.abbrevCmd)" = true && rebasecmd=p
A better name would be "pickcmd", as there are more rebase commands than just pick and what we want here is really only associated with one of those commands.
Ciao,
Johannes
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Andreas SchwabHi Andreas,
Quoted 22 lines · Andreas Schwab
Quoted 20 lines · Liam Beguin
Documentation/config.txt +12
-0@@ -2614,6 +2614,25 @@ rebase.instructionFormat:: the instruction list during an interactive rebase. The format will automatically have the long commit hash prepended to the format. +rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this, + +------------------------------------------- + pick deadbee The oneline of this commit + pick fa1afe1 The oneline of the next commit + ... +------------------------------------------- + + the list would use the short version of the command resulting in + something like this.
Quoted 8 lines
Documentation/config.txt rebase.instructionFormat:: · line 2634
Quoted 6 lines
Documentation/config.txt +6
-0+ +------------------------------------------- + p deadbee The oneline of this commit + p fa1afe1 The oneline of the next commit + ... +-------------------------------------------That doesn't explain the point of the option.
And what you forgot to say in order to make this a constructive criticism
is: we probably want to add a sentence like this:
Using the one-letter abbreviations will align the lines better in case that the non-abbreviated commands have different lengths.
Speaking of commands with different lengths, I just thought of fixup and squash. I do not think those are handled by the patch, but they should be (the action in the first loop of rearrange_squash should abbreviate via test p != "$pickcmd" || action=${action%${action#?}}).
Ciao,
Johannes
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
Hi Johannes,
Quoted 39 lines · Johannes Schindelin
Hi Andreas,
Quoted 22 lines · Andreas Schwab
Quoted 20 lines · Liam Beguin
Documentation/config.txt +0
-0@@ -2614,6 +2614,25 @@ rebase.instructionFormat::the instruction list during an interactive rebase. The format will automatically have the long commit hash prepended to the format.
Documentation/config.txt +12
-0+rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this, + +------------------------------------------- + pick deadbee The oneline of this commit + pick fa1afe1 The oneline of the next commit + ... +------------------------------------------- + + the list would use the short version of the command resulting in + something like this.Quoted 8 lines
Documentation/config.txt rebase.instructionFormat:: · line 2634
Quoted 6 lines
Documentation/config.txt +6
-0+ +------------------------------------------- + p deadbee The oneline of this commit + p fa1afe1 The oneline of the next commit + ... +-------------------------------------------That doesn't explain the point of the option.
And what you forgot to say in order to make this a constructive criticism
is: we probably want to add a sentence like this:
Quoted 8 lines
Using the one-letter abbreviations will align the lines better in case that the non-abbreviated commands have different lengths.
Speaking of commands with different lengths, I just thought of fixup and squash. I do not think those are handled by the patch, but they should be (the
actionin the first loop ofrearrange_squashshould abbreviate viatest p != "$pickcmd" || action=${action%${action#?}}).
I just noticed this today, I'll make changes to handle this case.
Quoted 2 lines
Ciao,
Johannes
Thanks,
Liam
Hi Johannes,
Quoted 15 lines · Johannes Schindelin
Hi Liam,
Quoted 11 lines · liam BEGUIN
Quoted 8 lines · Johannes Schindelin
Quoted 3 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow the user to abbreviate the default command name while editing the 'git-rebase-todo' file.
This patch does not handle the
git rebase --edit-todosubcommand. Intentional?
Quoted 8 lines
Quoted 3 lines
After a little more investigation, I'm not sure what should be added for the
git rebase --edit-todosubcommand. It seems like it uses the same text that was added the first time (withgit rebase -i).Well, it uses whatever the user may have edited. It may surprise users that their
pickdoes not get converted toplike all the original commands.
It makes more sens to me now, I'll add it in next patch
Quoted 2 lines
Ciao,
Johannes
Thanks,
Liam
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Jacob KellerHi Jake,
Quoted 10 lines · Jacob Keller
Quoted 4 lines · Junio C Hamano
Personally I am happy with the beginning of each instruction line aligned, so from that point of view, this patch is a mild Meh to me, even though I do a fair amount of "rebase -i" myself. But obviously I am not the only user of Git you need to please, so...
I would instead justify this as making it easier to change the action, since you only need to rewrite a single letter, which at least in vim takes "r<letter>" to change the action, vs slightly more keystrokes such as "ct <letter" or otherwise.
It's another reason that motivated the change but I didn't think the vim shortcuts would justify the patch. Since you pointed it out, I'll probably add it.
Quoted 7 lines
Also, if you change the default commit hash length, it becomes long enough to cover most commits and you see all commits at say 12 digits commit hash and everything is nicely aligned.
Thanks,
Jake
Thanks,
Liam
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Johannes SchindelinHi Johannes,
Quoted 65 lines · Johannes Schindelin
Hi Liam,
Quoted 7 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow
git rebase -ito abbreviate the command-names in the instruction list.This means that
git rebase -iwould print:
p deadbee The oneline of this commit
...Quoted 8 lines
instead of:
pick deadbee The oneline of this commit
...Using a single character command-name allows the lines to remain aligned, making the whole set more readable.
Signed-off-by Liam Beguin <[email protected]>Apart from either abbreviating commands after --edit-todo, or documenting explicitly that the new config option only concerns the initial todo list, there is another problem that just occurred to me: --exec.
When you call
git rebase -x "make DEVELOPER=1 -j15", the idea is to append an "exec make DEVELOPER=1 -j15" line after every pick line. The code in question looks like this:
add_exec_commands() {
{
first=t
while read -r insn rest
do
case $insn in
pick)
test -n "$first" || printf "%s" "$cmd" ;;
esac
printf "%s %s\n" "$insn" "$rest" first=
done
printf "%s" "$cmd"
} <"$1" >"$1.new" &&
mv "$1.new" "$1"
}Obviously, the git-rebase--interactive script expects at this point that the command is spelled out, so your patch needs to change the
pick)case top|pick), I think.In addition, since the rationale for the new option is to align the lines better, the
execwould need to be replaced byx, and as multiple-xoptions are allowed, you would need something like this at the beginning ofadd_exec_commands, too:# abbreviate `exec` if rebase.abbrevCmd is true test p != "$rebasecmd" || cmd="$(echo "$cmd" | sed 's/^exec/x/')"Also:
Quoted 13 lines
Quoted 9 lines
Documentation/config.txt +0
-0@@ -2614,6 +2614,25 @@ rebase.instructionFormat::the instruction list during an interactive rebase. The format will automatically have the long commit hash prepended to the format.
+rebase.abbrevCmd::It does not fail to amuse that the term "abbrevCmd" is abbreviated heavily itself. However, I would strongly suggest to avoid that. It would be much more pleasant to call the config option rebase.abbreviateCommands
I tried to use something similar to the rest of the options but I guess that would be best.
Quoted 12 lines
Documentation/config.txt rebase.instructionFormat:: · line 2619
Quoted 4 lines
Documentation/config.txt +3
-0+rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this,This is by no means your fault, but it is really horrible by how many different names Git's documentation refers to the todo script, nothing short of confusing. It is the todo script (which I called it initially, maybe not a good name, but it has the merit of the longest tradition at least), the todo list, the instruction sheet, the rebase script, the instruction list... etc
Quoted 3 lines
However, the thing is called "todo list" elsewhere in the same file, therefore lets try to avoid even more confusion and use that term instead of "instruction list" here.
thanks for pointing this out, I was not quite sure what to call this list.
Quoted 16 lines
git-rebase--interactive.sh else · line 1215
Quoted 12 lines
git-rebase--interactive.sh +0
-0@@ -1210,6 +1210,10 @@ elserevisions=$onto...$orig_head
shortrevisions=$shorthead
figit-rebase--interactive.sh +3
-0+ +rebasecmd=pick +test "$(git config --bool --get rebase.abbrevCmd)" = true && rebasecmd=pA better name would be "pickcmd", as there are more rebase commands than just
pickand what we want here is really only associated with one of those commands.
Wouldn't that make it confusing when the patch starts to handle other commands? A common name across the script would limit further confusion.
I noticed that it is already called action in rearrange_squash. would that do? (even though it has no reference to 'command')
Quoted 3 lines
Ciao,
Johannes
Thanks for the detailed answer,
Liam
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
Quoted 11 lines · liam Beguin
Quoted 11 lines
Documentation/config.txt rebase.instructionFormat:: · line 2619
Quoted 3 lines
Documentation/config.txt +3
-0+rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this,This is by no means your fault, but it is really horrible by how many different names Git's documentation refers to the todo script, nothing short of confusing. It is the todo script (which I called it initially, maybe not a good name, but it has the merit of the longest tradition at least), the todo list, the instruction sheet, the rebase script, the instruction list... etc
Quoted 5 lines
Quoted 3 lines
However, the thing is called "todo list" elsewhere in the same file, therefore lets try to avoid even more confusion and use that term instead of "instruction list" here.
thanks for pointing this out, I was not quite sure what to call this list.
I think the words "instruction list" may have come from my suggestion. I used them because that is the term used in the rebase.instructionFormat documentation directly above the option you are adding.
It may be worth a follow-on patch to convert that one to "todo list" if that's the preferred name.
-Peff
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Jacob KellerQuoted 10 lines · Jacob Keller
Quoted 4 lines · Junio C Hamano
Personally I am happy with the beginning of each instruction line aligned, so from that point of view, this patch is a mild Meh to me, even though I do a fair amount of "rebase -i" myself. But obviously I am not the only user of Git you need to please, so...
I would instead justify this as making it easier to change the action, since you only need to rewrite a single letter, which at least in vim takes "r<letter>" to change the action, vs slightly more keystrokes such as "ct <letter" or otherwise.
That makes sense to me too.
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Jeff KingQuoted 6 lines · Jeff King
I think the words "instruction list" may have come from my suggestion. I used them because that is the term used in the rebase.instructionFormat documentation directly above the option you are adding.
It may be worth a follow-on patch to convert that one to "todo list" if that's the preferred name.
Running
$ git grep -i -e 'instruction [ls]' -e 'todo l'
lets us count how we call them, and we can see there is only one instance of 'instruction list'.
Running the above in v1.7.3 tree shows that it was originally called 'todo list', and we can see that an enhancement of cherry-pick in cd4093b6 ("Merge branch 'rr/revert-cherry-pick-continue'", 2011-10-05)) started calling this instruction sheet around v1.7.8.
A follow-on patch to unify all three would be nice, indeed.
Thanks.
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
Hi Junio,
Quoted 7 lines · Junio C Hamano
Running
$ git grep -i -e 'instruction [ls]' -e 'todo l'lets us count how we call them, and we can see there is only one instance of 'instruction list'.
Quoted 6 lines
Running the above in v1.7.3 tree shows that it was originally called 'todo list', and we can see that an enhancement of cherry-pick in
cd4093b6("Merge branch 'rr/revert-cherry-pick-continue'", 2011-10-05)) started calling this instruction sheet around v1.7.8.A follow-on patch to unify all three would be nice, indeed.
But we cannot unify them, as the config option's name uses "instruction" and to keep backwards-compatibility, we are simply unable to resolve the confusion.
Ciao,
Dscho
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to liam BeguinHi Liam,
Quoted 20 lines · liam Beguin
Quoted 18 lines · Johannes Schindelin
git-rebase--interactive.sh else · line 1215
Quoted 11 lines · Liam Beguin
git-rebase--interactive.sh +0
-0@@ -1210,6 +1210,10 @@ elserevisions=$onto...$orig_head
shortrevisions=$shorthead
figit-rebase--interactive.sh +3
-0+ +rebasecmd=pick +test "$(git config --bool --get rebase.abbrevCmd)" = true && rebasecmd=pA better name would be "pickcmd", as there are more rebase commands than just
pickand what we want here is really only associated with one of those commands.
Quoted 2 lines
Wouldn't that make it confusing when the patch starts to handle other commands?
Only if you use that variable to hold other values than pick or p. But you do not plan on that, right? You plan to use this variable only to hold the value pick by default and p in case the user asked for abbreviated commands. Therefore, I think it makes sense to reflect in the variable name that the purpose is really only to reflect the string used for the pick command (as opposed to any other todo command).
Ciao,
Johannes
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Liam BeguinQuoted 7 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow
git rebase -ito abbreviate the command-names in the instruction list.This means that
git rebase -iwould print:
p deadbee The oneline of this commit
...
Quoted 6 lines
instead of:
pick deadbee The oneline of this commit
...Using a single character command-name allows the lines to remain aligned, making the whole set more readable.
Aside from the existing comments about the commit message from others, you should be noting that we *already* have these abbreviations for all the todo list options, and we note this in append_todo_help.
Documentation/config.txt rebase.instructionFormat::
Quoted 9 lines
Documentation/config.txt +7
-0+rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this, + +rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this,
Better to split this out into a new *.txt file and use the include::* facility (grep for it) rather than copy/pasting this entirely across two files.
Quoted 8 lines
OPTIONS
-------
--onto <newbase>::git-rebase--interactive.sh +0
-0
git-rebase--interactive.sh else · line 1215
Quoted 6 lines
git-rebase--interactive.sh +3
-0@@ -1210,6 +1210,10 @@ else revisions=$onto...$orig_head shortrevisions=$shorthead fi + +rebasecmd=pick +test "$(git config --bool --get rebase.abbrevCmd)" = true && rebasecmd=p
Rather than hardcoding "p" here maybe it would be worthhwile to make that into a variable used both here and in append_todo_help, maybe not...
Quoted 13 lines
git-rebase--interactive.sh +1
-1format=$(git config --get rebase.instructionFormat) # the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse git rev-list $merges_option --format="%m%H ${format:-%s}" \@@ -1228,7 +1232,7 @@ do if test t != "$preserve_merges" then - printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" else if test -z "$rebase_root" then
git-rebase--interactive.sh do · line 1256
Quoted 8 lines
git-rebase--interactive.sh +1
-1@@ -1246,7 +1250,7 @@ do if test f = "$preserve" then touch "$rewritten"/$sha1 - printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" fi fi done
I haven't tried applying & running this patch, but it seems you definitely missed the case where --autosquash will add fixup or squash, that should be f or s with your patch, but you didn't change that code. See the rearrange_squash function.
Ditto for turning "exec" into "e" with --exec.
But if the motivation for this entire thing is to make sure the commands are aligned this doesn't fix that, because the sha1s can be of different lengths. So as others have pointed out maybe this entire thing should be dropped & replaced with some bool command to align the todo list, maybe turning that on by default.
Unless the real unstated reason is to make this easier to edit in vim or something, in which case this approach seems reasonable.
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Johannes SchindelinQuoted 16 lines · Johannes Schindelin
Hi Junio,
Quoted 12 lines · Junio C Hamano
Running
$ git grep -i -e 'instruction [ls]' -e 'todo l'lets us count how we call them, and we can see there is only one instance of 'instruction list'.
Running the above in v1.7.3 tree shows that it was originally called 'todo list', and we can see that an enhancement of cherry-pick in
cd4093b6("Merge branch 'rr/revert-cherry-pick-continue'", 2011-10-05)) started calling this instruction sheet around v1.7.8.
Quoted 5 lines
Quoted 1 line
A follow-on patch to unify all three would be nice, indeed.
But we cannot unify them, as the config option's name uses "instruction" and to keep backwards-compatibility, we are simply unable to resolve the confusion.
We can correct historical mistakes by introducing preferred synonym to misnamed configuration variables, clearly document why we prefer it over the misnamed one that is now deprecated, and then eventually dropping it at a major version boundary.
Re: [PATCH v2] rebase -i: add config to abbreviate command-names
In reply to Ævar Arnfjörð BjarmasonHi Ævar,
Quoted 20 lines · Ævar Arnfjörð Bjarmason
Quoted 7 lines · Liam Beguin
Add the 'rebase.abbrevCmd' boolean config option to allow
git rebase -ito abbreviate the command-names in the instruction list.This means that
git rebase -iwould print:
p deadbee The oneline of this commit
...Quoted 6 lines
instead of:
pick deadbee The oneline of this commit
...Using a single character command-name allows the lines to remain aligned, making the whole set more readable.
Aside from the existing comments about the commit message from others, you should be noting that we *already* have these abbreviations for all the todo list options, and we note this in
append_todo_help.
Quoted 14 lines
Documentation/config.txt rebase.instructionFormat::
Quoted 9 lines
Documentation/config.txt +7
-0+rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this, + +rebase.abbrevCmd:: + If set to true, `git rebase -i` will abbreviate the command-names in the + instruction list. This means that instead of looking like this,Better to split this out into a new *.txt file and use the include::* facility (grep for it) rather than copy/pasting this entirely across two files.
Thanks for pointing this out, I'll update the documentation
Quoted 10 lines
Quoted 10 lines
OPTIONS
-------
--onto <newbase>::git-rebase--interactive.sh +0
-0@@ -1210,6 +1210,10 @@ elserevisions=$onto...$orig_head
shortrevisions=$shorthead
Quoted 9 lines
git-rebase--interactive.sh else · line 1215
Quoted 4 lines
fi
git-rebase--interactive.sh +3
-0+ +rebasecmd=pick +test "$(git config --bool --get rebase.abbrevCmd)" = true && rebasecmd=pRather than hardcoding "p" here maybe it would be worthhwile to make that into a variable used both here and in
append_todo_help, maybe not...
I'm not sure I understand, do you mean that the option should also affect the message added by append_todo_help ?
Quoted 27 lines
Quoted 13 lines
format=$(git config --get rebase.instructionFormat)
# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse git rev-list $merges_option --format="%m%H ${format:-%s}" \git-rebase--interactive.sh +0
-0@@ -1228,7 +1232,7 @@ doif test t != "$preserve_merges"
then
- printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" else
if test -z "$rebase_root"
thengit-rebase--interactive.sh +0
-0@@ -1246,7 +1250,7 @@ doQuoted 8 lines
if test f = "$preserve"
then
touch "$rewritten"/$sha1
- printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo" + printf '%s\n' "${comment_out}${rebasecmd} $sha1 $rest" >>"$todo" fi
fi
doneI haven't tried applying & running this patch, but it seems you definitely missed the case where --autosquash will add fixup or squash, that should be f or s with your patch, but you didn't change that code. See the
rearrange_squashfunction.
Quoted 2 lines
Ditto for turning "exec" into "e" with --exec.
I noticed this yesterday, I'll add both cases the next iteration.
Quoted 8 lines
But if the motivation for this entire thing is to make sure the commands are aligned this doesn't fix that, because the sha1s can be of different lengths. So as others have pointed out maybe this entire thing should be dropped & replaced with some bool command to align the todo list, maybe turning that on by default.
Unless the real unstated reason is to make this easier to edit in vim or something, in which case this approach seems reasonable.
Keeping things aligned was the first motivation but the fact that it also makes changing the action faster is also nice to have. I didn't think it would help justify the patch.
The SHA1s not having the same length can easily be 'fixed' by setting a higher value for 'core.abbrev'.
Thanks,
Liam