git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] rebase -i: add config to abbreviate command-names

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 25, 2017, 20:08 UTC
Message-ID
<alpine.DEB.2.20.1704252148400.3480@virtualbox>
In-Reply-To
<20170425044320.17840-1-liambeguin@gmail.com>
Hi Liam,
On Tue, 25 Apr 2017, Liam Beguin wrote:
Show 15 quoted lines
> Add 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.
> 
> Signed-off-by: Liam Beguin <liambeguin@gmail.com>

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:
Show 9 quoted lines
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 475e874d5155..8b1877f2df91 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -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

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

Show 11 quoted lines
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 2c9c0165b5ab..9f3e82b79615 100644
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -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

Previous: liam BEGUINNext: liam Beguin
Message 20 of 28 in “rebase -i: add config to abbreviate command name”
  1. rebase -i: add config to abbreviate command nameLiam Beguin, Apr 24, 2017
  2. Johannes SchindelinApr 24, 2017
  3. liam BEGUINApr 24, 2017
  4. liam BEGUINApr 25, 2017
  5. Johannes SchindelinApr 25, 2017
  6. liam BEGUINApr 25, 2017
  7. Jeff KingApr 24, 2017
  8. rebase -i: add config to abbreviate command-namesLiam Beguin, Apr 25, 2017
  9. Junio C HamanoApr 25, 2017
  10. Jacob KellerApr 25, 2017
  11. liam BeguinApr 25, 2017
  12. Junio C HamanoApr 26, 2017
  13. Andreas SchwabApr 25, 2017
  14. Mike RappazzoApr 25, 2017
  15. Philip OakleyApr 25, 2017
  16. rebase -i: add config to abbreviate command-namesLiam Beguin, Apr 25, 2017
  17. Andreas SchwabApr 25, 2017
  18. Johannes SchindelinApr 25, 2017
  19. liam BEGUINApr 25, 2017
  20. Johannes SchindelinApr 25, 2017
  21. liam BeguinApr 26, 2017
  22. Jeff KingApr 26, 2017
  23. Junio C HamanoApr 26, 2017
  24. Johannes SchindelinApr 26, 2017
  25. Junio C HamanoApr 27, 2017
  26. Johannes SchindelinApr 26, 2017
  27. Ævar Arnfjörð BjarmasonApr 26, 2017
  28. liam BeguinApr 27, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.