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

[RFC/PATCH] add diffstat information to rebase

From
Stefan Beller <sbeller@google.com>
Date
Dec 22, 2016, 18:56 UTC
Message-ID
<20161222185609.21139-1-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---

When working on a large feature consisting of lots of commits, my development workflow is to create a lot of very small commits and then reshuffle these via interactive rebase.

Sometimes the commit message titles for these very small commits are not as good as I thought they would, such that the interactive rebase session needs to be accompanied by extensive use of gitk in my case.

This is a small hack that adds the diffstat to the interactive rebase helping me a bit during the rebase, such that:

    $ git rebase -i HEAD^^
    pick 2eaa3f532c Third batch for 2.12
    # Documentation/RelNotes/2.12.0.txt | 40 +++++++++++++++++++++++++++++++++++++++
    # 1 file changed, 40 insertions(+)
    pick 3170a3a57b add information to rebase
    # git-rebase--interactive.sh | 2 ++
    # 1 file changed, 2 insertions(+)
    
    # Rebase 2eaa3f532c..3170a3a57b onto 2eaa3f532c (1 command)
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending

I am not completely satisfied with the result, as I initially wished these information would just appear in line after the commit subject, but this comes close. Maybe the last line also needs to be dropped.

This is not a patch meant for inclusion, as for that we'd want to hide this feature behind an option I'd guess.

Stefan
 git-rebase--interactive.sh | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 41fd374c72..db73c69674 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -1220,6 +1220,7 @@ do
 	if test t != "$preserve_merges"
 	then
 		printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo"
+		git diff --stat $sha1^..$sha1 |sed s/^/"$comment_char"/ >>"$todo"
 	else
 		if test -z "$rebase_root"
 		then
@@ -1238,6 +1239,7 @@ do
 		then
 			touch "$rewritten"/$sha1
 			printf '%s\n' "${comment_out}pick $sha1 $rest" >>"$todo"
+			git diff --stat $sha1^..$sha1 |sed s/^/"$comment_char"/ >>"$todo"
 		fi
 	fi
 done
-- 
2.11.0.193.g3170a3a57b
Next: Johannes Schindelin
Message 1 of 7 in “add diffstat information to rebase”
  1. add diffstat information to rebaseStefan Beller, Dec 22, 2016
  2. Johannes SchindelinDec 22, 2016
  3. Stefan BellerDec 22, 2016
  4. Johannes SchindelinDec 22, 2016
  5. Duy NguyenDec 25, 2016
  6. Junio C HamanoDec 22, 2016
  7. Jacob KellerDec 23, 2016

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.