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

[PATCH] rebase -i: squash should retain the authorship of the _first_ commit

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Sep 29, 2007, 23:34 UTC
Message-ID
<Pine.LNX.4.64.0709300032520.28395@racer.site>
In-Reply-To
<7vzlz5jfa1.fsf@gitster.siamese.dyndns.org>

It was determined on the mailing list, that it makes more sense for a "squash" to keep the author of the first commit as the author for the result of the squash.

Make it so.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Sat, 29 Sep 2007, Junio C Hamano wrote:
	> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
	> 
	> > On Sat, 29 Sep 2007, Avi Kivity wrote:
	> >
	> >> > > Can we make "amend" like squash, except that it keeps the 
	> >> > > first commit's authorship instead of the second?  I often 
	> >> > > merge a commit with some minor fix that comes later, and 
	> >> > > usually want to keep the original author record.
	> >
	> > Thinking about this again... Maybe it is a better semantics 
	> > anyway? What do others think?
	> 
	> I never thought about whose commit the squashed ones become
	> before this thread, but making squash quack as if "commit
	> --amend" was done after running "cherry-pick -n" the second and
	> later ones feels like the most natural semantics to me.
	Here you are.
 Documentation/git-rebase.txt  |    2 +-
 git-rebase--interactive.sh    |    2 +-
 t/t3404-rebase-interactive.sh |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 0858fa8..e8e7579 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -298,7 +298,7 @@ rebasing.
 If you want to fold two or more commits into one, replace the command
 "pick" with "squash" for the second and subsequent commit.  If the
 commits had different authors, it will attribute the squashed commit to
-the author of the last commit.
+the author of the first commit.
 
 In both cases, or when a "pick" does not succeed (because of merge
 errors), the loop will stop to let you fix things, and you can continue
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 7a5aaa5..050140d 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -276,9 +276,9 @@ do_next () {
 		esac
 
 		failed=f
+		author_script=$(get_author_ident_from_commit HEAD)
 		output git reset --soft HEAD^
 		pick_one -n $sha1 || failed=t
-		author_script=$(get_author_ident_from_commit $sha1)
 		echo "$author_script" > "$DOTEST"/author-script
 		case $failed in
 		f)
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index f2214dd..1113904 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -180,7 +180,7 @@ test_expect_success 'squash' '
 '
 
 test_expect_success 'retain authorship when squashing' '
-	git show HEAD | grep "^Author: Nitfol"
+	git show HEAD | grep "^Author: Twerp Snog"
 '
 
 test_expect_success 'preserve merges with -p' '
-- 
1.5.3.2.1102.g9487
Previous: Junio C Hamano
Message 9 of 9 in “rebase -i: support single-letter abbreviations for the actions”
  1. rebase -i: support single-letter abbreviations for the actionsJohannes Schindelin, Sep 29, 2007
  2. Junio C HamanoSep 29, 2007
  3. rebase -i: support single-letter abbreviations for the actionsJohannes Schindelin, Sep 29, 2007
  4. Avi KivitySep 29, 2007
  5. Johannes SchindelinSep 29, 2007
  6. Avi KivitySep 29, 2007
  7. Johannes SchindelinSep 29, 2007
  8. Junio C HamanoSep 29, 2007
  9. rebase -i: squash should retain the authorship of the _first_ commitJohannes Schindelin, Sep 29, 2007

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.