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

[PATCH v3 2/6] rebase -i: add abbreviate_commands function

From
Liam Beguin <liambeguin@gmail.com>
Date
May 2, 2017, 04:00 UTC
Message-ID
<20170502040048.9065-3-liambeguin@gmail.com>
In-Reply-To
<20170502040048.9065-1-liambeguin@gmail.com>

Once the rest of the processing is done, the `abbreviate_commands` function is called. If the 'rebase.abbreviateCommands' option is set to true, the function will replace each command-name by its abbreviated form.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
---
 git-rebase--interactive.sh | 16 ++++++++++++++++
 1 file changed, 17 insertions(+)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 9b8a030ff045..4fa621062cdf 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -884,6 +884,20 @@ add_exec_commands () {
 	mv "$1.new" "$1"
 }
 
+abbreviate_commands () {
+	test "$(git config --bool rebase.abbreviateCommands)" = true || return
+
+	while read -r command rest
+	do
+		case $command in
+		x|exec) command=x ;;
+		*)      command=${command%${command#?}} ;;
+		esac
+		printf "%s\n" "$command $rest"
+	done <"$1" >"$1.new" &&
+	mv -f "$1.new" "$1"
+}
+
 # Check if the SHA-1 passed as an argument is a
 # correct one, if not then print $2 in "$todo".badsha
 # $1: the SHA-1 to test
@@ -1143,6 +1158,7 @@ edit-todo)
 	git stripspace --strip-comments <"$todo" >"$todo".new
 	mv -f "$todo".new "$todo"
 	collapse_todo_ids
+	abbreviate_commands "$todo"
 	append_todo_help
 	gettext "
 You are editing the todo file of an ongoing interactive rebase.
@@ -1281,6 +1297,7 @@ fi
 test -s "$todo" || echo noop >> "$todo"
 test -n "$autosquash" && rearrange_squash "$todo"
 test -n "$cmd" && add_exec_commands "$todo"
+abbreviate_commands "$todo"
 
 todocount=$(git stripspace --strip-comments <"$todo" | wc -l)
 todocount=${todocount##* }
-- 
2.9.3
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 4 of 21 in “rebase -i: add config to abbreviate command-names”
  1. 0/6 rebase -i: add config to abbreviate command-namesLiam Beguin, May 2, 2017
  2. 1/6 rebase -i: add abbreviated command-names handlingLiam Beguin, May 2, 2017
  3. Johannes SchindelinMay 2, 2017
  4. 2/6 rebase -i: add abbreviate_commands functionLiam Beguin, May 2, 2017
  5. Johannes SchindelinMay 2, 2017
  6. 3/6 rebase -i: add short command-name in --autosquashLiam Beguin, May 2, 2017
  7. Johannes SchindelinMay 2, 2017
  8. Liam BeguinMay 2, 2017
  9. 6/6 Documentation: document the rebase.abbreviateCommands optionLiam Beguin, May 2, 2017
  10. 4/6 Documentation: move rebase.* config variables to a separate rebase-config.txtLiam Beguin, May 2, 2017
  11. Johannes SchindelinMay 2, 2017
  12. 5/6 Documentation: use preferred name for the 'todo list' scriptLiam Beguin, May 2, 2017
  13. Ævar Arnfjörð BjarmasonMay 2, 2017
  14. Johannes SchindelinMay 2, 2017
  15. Johannes SchindelinMay 2, 2017
  16. Liam BeguinMay 2, 2017
  17. Johannes SchindelinMay 3, 2017
  18. Junio C HamanoMay 4, 2017
  19. Liam BeguinMay 7, 2017
  20. Junio C HamanoMay 8, 2017
  21. Liam BeguinMay 8, 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.