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

[PATCH] rebase -i: add config to abbreviate command name

From
Liam Beguin <liambeguin@gmail.com>
Date
Apr 24, 2017, 03:23 UTC
Message-ID
<20170424032347.10878-1-liambeguin@gmail.com>

Add the 'rebase.abbrevCmd' boolean config option to allow the user to abbreviate the default command name while editing the 'git-rebase-todo' file.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
---
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(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 475e874d5155..59b64832aeb4 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -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
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 67d48e688315..0c423d903625 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -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>::
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
+
 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
-- 
2.9.3
Next: Johannes Schindelin
Message 1 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.