From 1b1dce4bae760248a1fc3e29548a72c446e77270 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 25 Jun 2007 01:11:14 +0100 Subject: Teach rebase an interactive mode Don't you just hate the fact sometimes, that git-rebase just applies the patches, without any possibility to edit them, or rearrange them? With "--interactive", git-rebase now lets you edit the list of patches, so that you can reorder, edit and delete patches. Such a list will typically look like this: pick deadbee The oneline of this commit pick fa1afe1 The oneline of the next commit ... By replacing the command "pick" with the command "edit", you can amend that patch and/or its commit message, and by replacing it with "squash" you can tell rebase to fold that patch into the patch before that. It is derived from the script sent to the list in Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 163 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100755 t/t3404-rebase-interactive.sh (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh new file mode 100755 index 0000000000..48aa8ea814 --- /dev/null +++ b/t/t3404-rebase-interactive.sh @@ -0,0 +1,163 @@ +#!/bin/sh +# +# Copyright (c) 2007 Johannes E. Schindelin +# + +test_description='git rebase interactive + +This test runs git rebase "interactively", by faking an edit, and verifies +that the result still makes sense. +' +. ./test-lib.sh + +# set up two branches like this: +# +# A - B - C - D - E +# \ +# F - G - H +# \ +# I +# +# where B, D and G touch the same file. + +test_expect_success 'setup' ' + : > file1 && + git add file1 && + test_tick && + git commit -m A && + git tag A && + echo 1 > file1 && + test_tick && + git commit -m B file1 && + : > file2 && + git add file2 && + test_tick && + git commit -m C && + echo 2 > file1 && + test_tick && + git commit -m D file1 && + : > file3 && + git add file3 && + test_tick && + git commit -m E && + git checkout -b branch1 A && + : > file4 && + git add file4 && + test_tick && + git commit -m F && + git tag F && + echo 3 > file1 && + test_tick && + git commit -m G file1 && + : > file5 && + git add file5 && + test_tick && + git commit -m H && + git checkout -b branch2 F && + : > file6 && + git add file6 && + test_tick && + git commit -m I && + git tag I +' + +cat > fake-editor.sh << EOF +#!/bin/sh +test "\$1" = .git/COMMIT_EDITMSG && exit +test -z "\$FAKE_LINES" && exit +grep -v "^#" < "\$1" > "\$1".tmp +rm "\$1" +cat "\$1".tmp +action=pick +for line in \$FAKE_LINES; do + case \$line in + squash) + action="\$line";; + *) + echo sed -n "\${line}s/^pick/\$action/p" + sed -n "\${line}p" < "\$1".tmp + sed -n "\${line}s/^pick/\$action/p" < "\$1".tmp >> "\$1" + action=pick;; + esac +done +EOF + +chmod a+x fake-editor.sh +VISUAL="$(pwd)/fake-editor.sh" +export VISUAL + +test_expect_success 'no changes are a nop' ' + git rebase -i F && + test $(git rev-parse I) = $(git rev-parse HEAD) +' + +test_expect_success 'rebase on top of a non-conflicting commit' ' + git checkout branch1 && + git tag original-branch1 && + git rebase -i branch2 && + test file6 = $(git diff --name-only original-branch1) && + test $(git rev-parse I) = $(git rev-parse HEAD~2) +' + +test_expect_success 'exchange two commits' ' + FAKE_LINES="2 1" git rebase -i HEAD~2 && + test H = $(git cat-file commit HEAD^ | tail -n 1) && + test G = $(git cat-file commit HEAD | tail -n 1) +' + +cat > expect << EOF +diff --git a/file1 b/file1 +index e69de29..00750ed 100644 +--- a/file1 ++++ b/file1 +@@ -0,0 +1 @@ ++3 +EOF + +cat > expect2 << EOF +<<<<<<< HEAD:file1 +2 +======= +3 +>>>>>>> b7ca976... G:file1 +EOF + +test_expect_success 'stop on conflicting pick' ' + git tag new-branch1 && + ! git rebase -i master && + diff -u expect .git/.dotest-merge/patch && + diff -u expect2 file1 && + test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) && + test 0 = $(grep -v "^#" < .git/.dotest-merge/todo | wc -l) +' + +test_expect_success 'abort' ' + git rebase --abort && + test $(git rev-parse new-branch1) = $(git rev-parse HEAD) && + ! test -d .git/.dotest-merge +' + +test_expect_success 'retain authorship' ' + echo A > file7 && + git add file7 && + GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" && + git tag twerp && + git rebase -i --onto master HEAD^ && + git show HEAD | grep "^Author: Twerp Snog" +' + +test_expect_success 'squash' ' + git reset --hard twerp && + echo B > file7 && + GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 && + echo "******************************" && + FAKE_LINES="1 squash 2" git rebase -i --onto master HEAD~2 && + test B = $(cat file7) && + test $(git rev-parse HEAD^) = $(git rev-parse master) +' + +test_expect_success 'retain authorship when squashing' ' + git show HEAD | grep "^Author: Nitfol" +' + +test_done -- cgit v1.2.3 From c54b7817f4f6bf422ea532d81217c28f63c259c5 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 25 Jun 2007 18:56:55 +0100 Subject: rebase -i: several cleanups Support "--verbose" in addition to "-v", show short names in the list comment, clean up if there is nothing to do, and add several "test_ticks" in the test script. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 48aa8ea814..19a3a8e813 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -140,6 +140,7 @@ test_expect_success 'abort' ' test_expect_success 'retain authorship' ' echo A > file7 && git add file7 && + test_tick && GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" && git tag twerp && git rebase -i --onto master HEAD^ && @@ -149,6 +150,7 @@ test_expect_success 'retain authorship' ' test_expect_success 'squash' ' git reset --hard twerp && echo B > file7 && + test_tick && GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 && echo "******************************" && FAKE_LINES="1 squash 2" git rebase -i --onto master HEAD~2 && -- cgit v1.2.3 From 68a163c9b483ae352fcfee8c4505d113213daa73 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 25 Jun 2007 18:58:28 +0100 Subject: rebase -i: provide reasonable reflog for the rebased branch If your rebase succeeded, the HEAD's reflog will still show the whole mess, but "@{1}" now shows the state _before_ the rebase, so that you can reset (or compare) the original and the rebased revisions more easily. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 19a3a8e813..9f12bb9321 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -99,6 +99,10 @@ test_expect_success 'rebase on top of a non-conflicting commit' ' test $(git rev-parse I) = $(git rev-parse HEAD~2) ' +test_expect_success 'reflog for the branch shows state before rebase' ' + test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1) +' + test_expect_success 'exchange two commits' ' FAKE_LINES="2 1" git rebase -i HEAD~2 && test H = $(git cat-file commit HEAD^ | tail -n 1) && -- cgit v1.2.3 From f09c9b8c5ff9d8a15499b09ccd6c3e7b3c76af77 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 25 Jun 2007 18:59:43 +0100 Subject: Teach rebase -i about --preserve-merges The option "-p" (or long "--preserve-merges") makes it possible to rebase side branches including merges, without straightening the history. Example: X \ A---M---B / ---o---O---P---Q When the current HEAD is "B", "git rebase -i -p --onto Q O" will yield X \ ---o---O---P---Q---A'---M'---B' Note that this will - _not_ touch X [*1*], it does - _not_ work without the --interactive flag [*2*], it does - _not_ guess the type of the merge, but blindly uses recursive or whatever strategy you provided with "-s " for all merges it has to redo, and it does - _not_ make use of the original merge commit via git-rerere. *1*: only commits which reach a merge base between and HEAD are reapplied. The others are kept as-are. *2*: git-rebase without --interactive is inherently patch based (at least at the moment), and therefore merges cannot be preserved. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 9f12bb9321..883cf29595 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -166,4 +166,26 @@ test_expect_success 'retain authorship when squashing' ' git show HEAD | grep "^Author: Nitfol" ' +test_expect_success 'preserve merges with -p' ' + git checkout -b to-be-preserved master^ && + : > unrelated-file && + git add unrelated-file && + test_tick && + git commit -m "unrelated" && + git checkout -b to-be-rebased master && + echo B > file1 && + test_tick && + git commit -m J file1 && + test_tick && + git merge to-be-preserved && + echo C > file1 && + test_tick && + git commit -m K file1 && + git rebase -i -p --onto branch1 master && + test $(git rev-parse HEAD^^2) = $(git rev-parse to-be-preserved) && + test $(git rev-parse HEAD~3) = $(git rev-parse branch1) && + test $(git show HEAD:file1) = C && + test $(git show HEAD~2:file1) = B +' + test_done -- cgit v1.2.3 From 18640d991bde7e081fb851cea5114c09472b188f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 8 Jul 2007 03:01:29 +0100 Subject: rebase -i: handle --continue more like non-interactive rebase Non-interactive rebase requires the working tree to be clean, but applies what is in the index without requiring the user to do it herself. Imitate that, but (since we are interactive, after all) fire up an editor with the commit message. It also fixes a subtle bug: a forgotten "continue" was removed, which led to an infinite loop when continuing without remaining patches. Both issues noticed by Frank Lichtenheld. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 883cf29595..c25133699a 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -63,7 +63,10 @@ test_expect_success 'setup' ' cat > fake-editor.sh << EOF #!/bin/sh -test "\$1" = .git/COMMIT_EDITMSG && exit +test "\$1" = .git/COMMIT_EDITMSG && { + test -z "\$FAKE_COMMIT_MESSAGE" || echo "\$FAKE_COMMIT_MESSAGE" > "\$1" + exit +} test -z "\$FAKE_LINES" && exit grep -v "^#" < "\$1" > "\$1".tmp rm "\$1" @@ -181,6 +184,7 @@ test_expect_success 'preserve merges with -p' ' echo C > file1 && test_tick && git commit -m K file1 && + test_tick && git rebase -i -p --onto branch1 master && test $(git rev-parse HEAD^^2) = $(git rev-parse to-be-preserved) && test $(git rev-parse HEAD~3) = $(git rev-parse branch1) && @@ -188,4 +192,14 @@ test_expect_success 'preserve merges with -p' ' test $(git show HEAD~2:file1) = B ' +test_expect_success '--continue tries to commit' ' + test_tick && + ! git rebase -i --onto new-branch1 HEAD^ && + echo resolved > file1 && + git add file1 && + FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue && + test $(git rev-parse HEAD^) = $(git rev-parse new-branch1) && + git show HEAD | grep chouette +' + test_done -- cgit v1.2.3 From 8e4a91bd780b89c7337f281a8601f2e0cae108fc Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 8 Jul 2007 03:02:47 +0100 Subject: rebase -i: remember the settings of -v, -s and -p when interrupted After interruption, be that an edit, or a conflicting commit, reset the variables VERBOSE, STRATEGY and PRESERVE_MERGES, so that the user does not have to respecify them with "rebase --continue". Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index c25133699a..43a6675caa 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -202,4 +202,14 @@ test_expect_success '--continue tries to commit' ' git show HEAD | grep chouette ' +test_expect_success 'verbose flag is heeded, even after --continue' ' + git reset --hard HEAD@{1} && + test_tick && + ! git rebase -v -i --onto new-branch1 HEAD^ && + echo resolved > file1 && + git add file1 && + git rebase --continue > output && + grep "^ file1 | 2 +-$" output +' + test_done -- cgit v1.2.3 From 6368f3f8e701cb080b83ceb8ee622636046c514c Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 21 Jul 2007 18:09:41 +0100 Subject: rebase -i: call editor just once for a multi-squash Sometimes you want to squash more than two commits. Before this patch, the editor was fired up for each squash command. Now the editor is started only with the last squash command. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 43a6675caa..8206436cc7 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -65,6 +65,7 @@ cat > fake-editor.sh << EOF #!/bin/sh test "\$1" = .git/COMMIT_EDITMSG && { test -z "\$FAKE_COMMIT_MESSAGE" || echo "\$FAKE_COMMIT_MESSAGE" > "\$1" + test -z "\$FAKE_COMMIT_AMEND" || echo "\$FAKE_COMMIT_AMEND" >> "\$1" exit } test -z "\$FAKE_LINES" && exit @@ -212,4 +213,12 @@ test_expect_success 'verbose flag is heeded, even after --continue' ' grep "^ file1 | 2 +-$" output ' +test_expect_success 'multi-squash only fires up editor once' ' + base=$(git rev-parse HEAD~4) && + FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 squash 2 squash 3 squash 4" \ + git rebase -i $base && + test $base = $(git rev-parse HEAD^) && + test 1 = $(git show | grep ONCE | wc -l) +' + test_done -- cgit v1.2.3 From fb47cfbd59b12ea67e1a5c6a9d0bd665fcae4581 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 24 Jul 2007 21:43:09 +0100 Subject: rebase -i: fix interrupted squashing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a squashing merge failed, the first commit would not be replaced, due to "git reset --soft" being called with an unmerged index. Noticed by Uwe Kleine-König. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 8206436cc7..817f614cde 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -221,4 +221,34 @@ test_expect_success 'multi-squash only fires up editor once' ' test 1 = $(git show | grep ONCE | wc -l) ' +test_expect_success 'squash works as expected' ' + for n in one two three four + do + echo $n >> file$n && + git add file$n && + git commit -m $n + done && + one=$(git rev-parse HEAD~3) && + FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 && + test $one = $(git rev-parse HEAD~2) +' + +test_expect_success 'interrupted squash works as expected' ' + for n in one two three four + do + echo $n >> conflict && + git add conflict && + git commit -m $n + done && + one=$(git rev-parse HEAD~3) && + ! FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 && + (echo one; echo two; echo four) > conflict && + git add conflict && + ! git rebase --continue && + echo resolved > conflict && + git add conflict && + git rebase --continue && + test $one = $(git rev-parse HEAD~2) +' + test_done -- cgit v1.2.3 From 96ffe892e307ea512abbc633f822558c568cece1 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 1 Aug 2007 15:59:35 +0100 Subject: rebase -i: ignore patches that are already in the upstream Non-interactive rebase had this from the beginning -- match it by using --cherry-pick option to rev-list. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 817f614cde..dc436d768e 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -68,6 +68,9 @@ test "\$1" = .git/COMMIT_EDITMSG && { test -z "\$FAKE_COMMIT_AMEND" || echo "\$FAKE_COMMIT_AMEND" >> "\$1" exit } +test -z "\$EXPECT_COUNT" || + test "\$EXPECT_COUNT" = \$(grep -ve "^#" -e "^$" < "\$1" | wc -l) || + exit test -z "\$FAKE_LINES" && exit grep -v "^#" < "\$1" > "\$1".tmp rm "\$1" @@ -251,4 +254,16 @@ test_expect_success 'interrupted squash works as expected' ' test $one = $(git rev-parse HEAD~2) ' +test_expect_success 'ignore patch if in upstream' ' + HEAD=$(git rev-parse HEAD) && + git checkout -b has-cherry-picked HEAD^ && + echo unrelated > file7 && + git add file7 && + test_tick && + git commit -m "unrelated change" && + git cherry-pick $HEAD && + EXPECT_COUNT=1 git rebase -i $HEAD && + test $HEAD = $(git rev-parse HEAD^) +' + test_done -- cgit v1.2.3 From c9e6589288b09f4e631c7f12f0f9a77c29851632 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 1 Aug 2007 23:31:03 +0100 Subject: rebase -i: fix for optional [branch] parameter When calling "git rebase -i ", git should switch to first. This worked before, but I broke it by my "Shut git rebase -i up" patch. Fix that, and add a test to make sure that it does not break again. Signed-off-by: Johannes Schindelin Acked-by: Alex Riesen Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index dc436d768e..a9b552ff08 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -98,6 +98,14 @@ test_expect_success 'no changes are a nop' ' test $(git rev-parse I) = $(git rev-parse HEAD) ' +test_expect_success 'test the [branch] option' ' + git checkout -b dead-end && + git rm file6 && + git commit -m "stop here" && + git rebase -i F branch2 && + test $(git rev-parse I) = $(git rev-parse HEAD) +' + test_expect_success 'rebase on top of a non-conflicting commit' ' git checkout branch1 && git tag original-branch1 && -- cgit v1.2.3 From 77b258f436874bdd1caecd4b3c9c63e3d49bd147 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 11 Aug 2007 14:08:20 -0700 Subject: t3404: fix "fake-editor" Here-text to create fake-editor did not use <<\EOF but < --- t/t3404-rebase-interactive.sh | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index a9b552ff08..40d6799ed6 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -61,29 +61,31 @@ test_expect_success 'setup' ' git tag I ' -cat > fake-editor.sh << EOF +cat > fake-editor.sh <<\EOF #!/bin/sh -test "\$1" = .git/COMMIT_EDITMSG && { - test -z "\$FAKE_COMMIT_MESSAGE" || echo "\$FAKE_COMMIT_MESSAGE" > "\$1" - test -z "\$FAKE_COMMIT_AMEND" || echo "\$FAKE_COMMIT_AMEND" >> "\$1" +case "$1" in +*/COMMIT_EDITMSG) + test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1" + test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1" exit -} -test -z "\$EXPECT_COUNT" || - test "\$EXPECT_COUNT" = \$(grep -ve "^#" -e "^$" < "\$1" | wc -l) || + ;; +esac +test -z "$EXPECT_COUNT" || + test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) || exit -test -z "\$FAKE_LINES" && exit -grep -v "^#" < "\$1" > "\$1".tmp -rm "\$1" -cat "\$1".tmp +test -z "$FAKE_LINES" && exit +grep -v '^#' < "$1" > "$1".tmp +rm -f "$1" +cat "$1".tmp action=pick -for line in \$FAKE_LINES; do - case \$line in +for line in $FAKE_LINES; do + case $line in squash) - action="\$line";; + action="$line";; *) - echo sed -n "\${line}s/^pick/\$action/p" - sed -n "\${line}p" < "\$1".tmp - sed -n "\${line}s/^pick/\$action/p" < "\$1".tmp >> "\$1" + echo sed -n "${line}s/^pick/$action/p" + sed -n "${line}p" < "$1".tmp + sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1" action=pick;; esac done -- cgit v1.2.3 From 1d25c8cf82eead72e11287d574ef72d3ebec0db1 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 23 Aug 2007 09:55:41 +0100 Subject: rebase -i: fix squashing corner case When squashing, rebase -i did not prevent fast forwards. This could happen when picking some other commit than the first one, and then squashing the first commit. So do not allow fast forwards when squashing. Noticed by Johannes Sixt. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 40d6799ed6..718c9c1fa3 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -264,6 +264,27 @@ test_expect_success 'interrupted squash works as expected' ' test $one = $(git rev-parse HEAD~2) ' +test_expect_success 'interrupted squash works as expected (case 2)' ' + for n in one two three four + do + echo $n >> conflict && + git add conflict && + git commit -m $n + done && + one=$(git rev-parse HEAD~3) && + ! FAKE_LINES="3 squash 1 2" git rebase -i HEAD~3 && + (echo one; echo four) > conflict && + git add conflict && + ! git rebase --continue && + (echo one; echo two; echo four) > conflict && + git add conflict && + ! git rebase --continue && + echo resolved > conflict && + git add conflict && + git rebase --continue && + test $one = $(git rev-parse HEAD~2) +' + test_expect_success 'ignore patch if in upstream' ' HEAD=$(git rev-parse HEAD) && git checkout -b has-cherry-picked HEAD^ && -- cgit v1.2.3 From be6ff208d8248c3f282df14fdf3c08db57e92007 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Sep 2007 16:42:36 +0100 Subject: rebase -i: commit when continuing after "edit" When doing an "edit" on a commit, editing and git-adding some files, "git rebase -i" complained about a missing "author-script". The idea was that the user would call "git commit --amend" herself. But we can be nice and do that for the user. Noticed by Dmitry Potapov. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 718c9c1fa3..1af73a47c6 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -80,7 +80,7 @@ cat "$1".tmp action=pick for line in $FAKE_LINES; do case $line in - squash) + squash|edit) action="$line";; *) echo sed -n "${line}s/^pick/$action/p" @@ -297,4 +297,16 @@ test_expect_success 'ignore patch if in upstream' ' test $HEAD = $(git rev-parse HEAD^) ' +test_expect_success '--continue tries to commit, even for "edit"' ' + parent=$(git rev-parse HEAD^) && + test_tick && + FAKE_LINES="edit 1" git rebase -i HEAD^ && + echo edited > file7 && + git add file7 && + FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue && + test edited = $(git show HEAD:file7) && + git show HEAD | grep chouette && + test $parent = $(git rev-parse HEAD^) +' + test_done -- cgit v1.2.3 From 73697a0b572f7f216d8355d83bf69e9b42e9a077 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Sep 2007 16:43:15 +0100 Subject: rebase -i: work on a detached HEAD Earlier, rebase -i refused to rebase a detached HEAD. Now it no longer does. Incidentally, this fixes "git gc --auto" shadowing the true exit status. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 1af73a47c6..f2214dd0fa 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -309,4 +309,12 @@ test_expect_success '--continue tries to commit, even for "edit"' ' test $parent = $(git rev-parse HEAD^) ' +test_expect_success 'rebase a detached HEAD' ' + grandparent=$(git rev-parse HEAD~2) && + git checkout $(git rev-parse HEAD) && + test_tick && + FAKE_LINES="2 1" git rebase -i HEAD~2 && + test $grandparent = $(git rev-parse HEAD~2) +' + test_done -- cgit v1.2.3 From 81ab1cb43a872fc527b26388bc7e781c816d723b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 30 Sep 2007 00:34:23 +0100 Subject: rebase -i: squash should retain the authorship of the _first_ commit 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 Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 718c9c1fa3..6c92d61192 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' ' -- cgit v1.2.3 From aac5bf0b48c5f23cf482ca7958fa6815fe6502ed Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Nov 2007 13:05:50 -0800 Subject: t/t3404: fix test for a bogus todo file. The test wants to see if there are still remaining tasks, but checked a wrong file. Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 6c92d61192..984146b5c2 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -149,7 +149,7 @@ test_expect_success 'stop on conflicting pick' ' diff -u expect .git/.dotest-merge/patch && diff -u expect2 file1 && test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) && - test 0 = $(grep -v "^#" < .git/.dotest-merge/todo | wc -l) + test 0 = $(grep -v "^#" < .git/.dotest-merge/git-rebase-todo | wc -l) ' test_expect_success 'abort' ' -- cgit v1.2.3 From 6047a234c5a6aef58c72a35feba326484f07660d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 22 Nov 2007 12:30:10 +0000 Subject: rebase -i: move help to end of todo file [PATCH] rebase -i: move help to end of todo file Many editors start in the first line, so the 9-line help text was an annoyance. So move it to the end. Requested by Junio. While at it, add a hint how to abort the rebase. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index f1039d1a21..907c7f9f6b 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -149,7 +149,8 @@ test_expect_success 'stop on conflicting pick' ' diff -u expect .git/.dotest-merge/patch && diff -u expect2 file1 && test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) && - test 0 = $(grep -v "^#" < .git/.dotest-merge/git-rebase-todo | wc -l) + test 0 = $(grep -ve "^#" -e "^$" < .git/.dotest-merge/git-rebase-todo | + wc -l) ' test_expect_success 'abort' ' -- cgit v1.2.3 From 34454e858d2a648b0a6ce56acd9def84bd2a8712 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 17 Dec 2007 21:01:25 +0000 Subject: rebase -p -i: handle "no changes" gracefully Since commit 376ccb8cbb453343998e734d8a1ce79f57a4e092 (rebase -i: style fixes and minor cleanups), unchanged SHA-1s are no longer mapped via $REWRITTEN. But the updating phase was not prepared for the old head not being rewritten. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 907c7f9f6b..74a7eb30f8 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -184,6 +184,12 @@ test_expect_success 'retain authorship when squashing' ' git show HEAD | grep "^Author: Twerp Snog" ' +test_expect_success '-p handles "no changes" gracefully' ' + HEAD=$(git rev-parse HEAD) && + git rebase -i -p HEAD^ && + test $HEAD = $(git rev-parse HEAD) +' + test_expect_success 'preserve merges with -p' ' git checkout -b to-be-preserved master^ && : > unrelated-file && -- cgit v1.2.3 From 752527f51396886c4ca11a14bfcecf2167ed4c40 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 28 Jan 2008 16:33:28 +0000 Subject: Add test for rebase -i with commits that do not pass pre-commit This accompanies c5b09feb786f6a2456ec3d8203d0f4d67f09f043 (Avoid update hook during git-rebase --interactive) to make sure that any regression to make Debian's Bug#458782 (git-core: git-rebase doesn't work when trying to squash changes into commits created with --no-verify) resurface will be caught. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 74a7eb30f8..e33ea4e9f4 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -324,4 +324,20 @@ test_expect_success 'rebase a detached HEAD' ' test $grandparent = $(git rev-parse HEAD~2) ' +test_expect_success 'rebase a commit violating pre-commit' ' + + mkdir -p .git/hooks && + PRE_COMMIT=.git/hooks/pre-commit && + echo "#!/bin/sh" > $PRE_COMMIT && + echo "test -z \"\$(git diff --cached --check)\"" >> $PRE_COMMIT && + chmod a+x $PRE_COMMIT && + echo "monde! " >> file1 && + test_tick && + ! git commit -m doesnt-verify file1 && + git commit -m doesnt-verify --no-verify file1 && + test_tick && + FAKE_LINES=2 git rebase -i HEAD~2 + +' + test_done -- cgit v1.2.3 From 077b725f0bbe2b6ca2deb569c22a6f0d7a374dd3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 13 Feb 2008 13:13:21 -0800 Subject: Protect get_author_ident_from_commit() from filenames in work tree We used to use "cat-file commit $commit" to extract the original author information from existing commit, but an earlier commit 5ac2715 (Consistent message encoding while reusing log from an existing commit) changed it to use "git show -s $commit". If you have a file in your work tree that can be interpreted as a valid object name (e.g. "HEAD"), this conversion will not work. Disambiguate by marking the end of revision parameter on the comand line with an explicit "--" to fix this. This breakage is most visible with rebase when a file called "HEAD" exists in the worktree. Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index e33ea4e9f4..e5ed74545b 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -340,4 +340,26 @@ test_expect_success 'rebase a commit violating pre-commit' ' ' +test_expect_success 'rebase with a file named HEAD in worktree' ' + + rm -fr .git/hooks && + git reset --hard && + git checkout -b branch3 A && + + ( + GIT_AUTHOR_NAME="Squashed Away" && + export GIT_AUTHOR_NAME && + >HEAD && + git add HEAD && + git commit -m "Add head" && + >BODY && + git add BODY && + git commit -m "Add body" + ) && + + FAKE_LINES="1 squash 2" git rebase -i to-be-rebased && + test "$(git show -s --pretty=format:%an)" = "Squashed Away" + +' + test_done -- cgit v1.2.3 From 1bd38e8dcca03e318d6000d62cf74c541945a8ba Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 20 Feb 2008 19:00:44 -0500 Subject: t3404: use configured shell instead of /bin/sh The fake-editor shell script invoked /bin/sh; normally this is fine, unless the /bin/sh doesn't meet our compatibility requirements, as is the case with Solaris. Specifically, the $() syntax used by fake-editor is not understood. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index e5ed74545b..62e65d704b 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -61,8 +61,8 @@ test_expect_success 'setup' ' git tag I ' -cat > fake-editor.sh <<\EOF -#!/bin/sh +echo "#!$SHELL" >fake-editor +cat >> fake-editor.sh <<\EOF case "$1" in */COMMIT_EDITMSG) test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1" -- cgit v1.2.3 From 7cf7f54a65aa1c70e21fe73753f6b0671d129adf Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sun, 24 Feb 2008 14:40:45 -0500 Subject: use build-time SHELL_PATH in test scripts The top-level Makefile now creates a GIT-BUILD-OPTIONS file which stores any options selected by the make process that may be of use to further parts of the build process. Specifically, we store the SHELL_PATH so that it can be used by tests to construct shell scripts on the fly. The format of the GIT-BUILD-OPTIONS file is Bourne shell, and it is sourced by test-lib.sh; all tests can rely on just having $SHELL_PATH correctly set in the environment. The GIT-BUILD-OPTIONS file is written every time the toplevel 'make' is invoked. Since the only users right now are the test scripts, there's no drawback to updating its timestamp. If something build-related depends on this, we can do a trick similar to the one used by GIT-CFLAGS. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 62e65d704b..049aa37538 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -61,7 +61,7 @@ test_expect_success 'setup' ' git tag I ' -echo "#!$SHELL" >fake-editor +echo "#!$SHELL_PATH" >fake-editor.sh cat >> fake-editor.sh <<\EOF case "$1" in */COMMIT_EDITMSG) -- cgit v1.2.3 From aadbe44f883859536c5320e0ac1d6ed122c45671 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 12 Mar 2008 17:32:17 -0400 Subject: grep portability fix: don't use "-e" or "-q" System V versions of grep (such as Solaris /usr/bin/grep) don't understand either of these options. git's usage of "grep -e pattern" fell into one of two categories: 1. equivalent to "grep pattern". -e is only useful here if the pattern begins with a "-", but all of the patterns are hardcoded and do not begin with a dash. 2. stripping comments and blank lines with grep -v -e "^$" -e "^#" We can fortunately do this in the affirmative as grep '^[^#]' Uses of "-q" can be replaced with redirection to /dev/null. In many tests, however, "grep -q" is used as "if this string is in the expected output, we are OK". In this case, it is fine to just remove the "-q" entirely; it simply makes the "verbose" mode of the test slightly more verbose. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 049aa37538..f09823106f 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -149,8 +149,7 @@ test_expect_success 'stop on conflicting pick' ' diff -u expect .git/.dotest-merge/patch && diff -u expect2 file1 && test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) && - test 0 = $(grep -ve "^#" -e "^$" < .git/.dotest-merge/git-rebase-todo | - wc -l) + test 0 = $(grep -c "^[^#]" < .git/.dotest-merge/git-rebase-todo) ' test_expect_success 'abort' ' -- cgit v1.2.3 From b4ce54fc61e7c76e2d7f47c34733f0f0bbb6c4cd Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 12 Mar 2008 17:34:34 -0400 Subject: remove use of "tail -n 1" and "tail -1" The "-n" syntax is not supported by System V versions of tail (which prefer "tail -1"). Unfortunately "tail -1" is not actually POSIX. We had some of both forms in our scripts. Since neither form works everywhere, this patch replaces both with the equivalent sed invocation: sed -ne '$p' Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index f09823106f..9c0acc5a7e 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -122,8 +122,8 @@ test_expect_success 'reflog for the branch shows state before rebase' ' test_expect_success 'exchange two commits' ' FAKE_LINES="2 1" git rebase -i HEAD~2 && - test H = $(git cat-file commit HEAD^ | tail -n 1) && - test G = $(git cat-file commit HEAD | tail -n 1) + test H = $(git cat-file commit HEAD^ | sed -ne \$p) && + test G = $(git cat-file commit HEAD | sed -ne \$p) ' cat > expect << EOF -- cgit v1.2.3 From 82ebb0b6ec7470cab96a013d3d719c109003ef83 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 12 Mar 2008 17:36:36 -0400 Subject: add test_cmp function for test scripts Many scripts compare actual and expected output using "diff -u". This is nicer than "cmp" because the output shows how the two differ. However, not all versions of diff understand -u, leading to unnecessary test failure. This adds a test_cmp function to the test scripts and switches all "diff -u" invocations to use it. The function uses the contents of "$GIT_TEST_CMP" to compare its arguments; the default is "diff -u". On systems with a less-capable diff, you can do: GIT_TEST_CMP=cmp make test Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 9c0acc5a7e..9cf873f7eb 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -146,8 +146,8 @@ EOF test_expect_success 'stop on conflicting pick' ' git tag new-branch1 && ! git rebase -i master && - diff -u expect .git/.dotest-merge/patch && - diff -u expect2 file1 && + test_cmp expect .git/.dotest-merge/patch && + test_cmp expect2 file1 && test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) && test 0 = $(grep -c "^[^#]" < .git/.dotest-merge/git-rebase-todo) ' -- cgit v1.2.3 From f69e836fab2b634281d92a0d304de4d768e479cc Mon Sep 17 00:00:00 2001 From: Bryan Donlan Date: Sun, 4 May 2008 01:37:59 -0400 Subject: Fix tests breaking when checkout path contains shell metacharacters This fixes the remainder of the issues where the test script itself is at fault for failing when the git checkout path contains whitespace or other shell metacharacters. The majority of git svn tests used the idiom test_expect_success "title" "test script using $svnrepo" These were changed to have the test script in single-quotes: test_expect_success "title" 'test script using "$svnrepo"' which unfortunately makes the patch appear larger than it really is. One consequence of this change is that in the verbose test output the value of $svnrepo (and in some cases other variables, too) is no longer expanded, i.e. previously we saw * expecting success: test script using /path/to/git/t/trash/svnrepo but now it is: * expecting success: test script using "$svnrepo" Signed-off-by: Bryan Donlan Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 9cf873f7eb..b9e3dbd242 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -91,9 +91,8 @@ for line in $FAKE_LINES; do done EOF +test_set_editor "$(pwd)/fake-editor.sh" chmod a+x fake-editor.sh -VISUAL="$(pwd)/fake-editor.sh" -export VISUAL test_expect_success 'no changes are a nop' ' git rebase -i F && -- cgit v1.2.3 From ab7367929f69c8b0f2f59d89225f211253ff57ef Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Sun, 22 Jun 2008 01:55:50 +0200 Subject: t3404: stricter tests for git-rebase--interactive Signed-off-by: Stephan Beyer Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index b9e3dbd242..1c80148dd5 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -96,6 +96,7 @@ chmod a+x fake-editor.sh test_expect_success 'no changes are a nop' ' git rebase -i F && + test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" && test $(git rev-parse I) = $(git rev-parse HEAD) ' @@ -104,14 +105,26 @@ test_expect_success 'test the [branch] option' ' git rm file6 && git commit -m "stop here" && git rebase -i F branch2 && + test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" && + test $(git rev-parse I) = $(git rev-parse branch2) && test $(git rev-parse I) = $(git rev-parse HEAD) ' +test_expect_success 'test --onto ' ' + git checkout -b test-onto branch2 && + git rebase -i --onto branch1 F && + test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" && + test $(git rev-parse HEAD^) = $(git rev-parse branch1) && + test $(git rev-parse I) = $(git rev-parse branch2) +' + test_expect_success 'rebase on top of a non-conflicting commit' ' git checkout branch1 && git tag original-branch1 && git rebase -i branch2 && test file6 = $(git diff --name-only original-branch1) && + test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" && + test $(git rev-parse I) = $(git rev-parse branch2) && test $(git rev-parse I) = $(git rev-parse HEAD~2) ' @@ -144,9 +157,12 @@ EOF test_expect_success 'stop on conflicting pick' ' git tag new-branch1 && - ! git rebase -i master && + test_must_fail git rebase -i master && + test "$(git rev-parse HEAD~3)" = "$(git rev-parse master)" && test_cmp expect .git/.dotest-merge/patch && test_cmp expect2 file1 && + test "$(git-diff --name-status | + sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 && test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) && test 0 = $(grep -c "^[^#]" < .git/.dotest-merge/git-rebase-todo) ' @@ -154,6 +170,7 @@ test_expect_success 'stop on conflicting pick' ' test_expect_success 'abort' ' git rebase --abort && test $(git rev-parse new-branch1) = $(git rev-parse HEAD) && + test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" && ! test -d .git/.dotest-merge ' @@ -213,7 +230,7 @@ test_expect_success 'preserve merges with -p' ' test_expect_success '--continue tries to commit' ' test_tick && - ! git rebase -i --onto new-branch1 HEAD^ && + test_must_fail git rebase -i --onto new-branch1 HEAD^ && echo resolved > file1 && git add file1 && FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue && @@ -224,7 +241,7 @@ test_expect_success '--continue tries to commit' ' test_expect_success 'verbose flag is heeded, even after --continue' ' git reset --hard HEAD@{1} && test_tick && - ! git rebase -v -i --onto new-branch1 HEAD^ && + test_must_fail git rebase -v -i --onto new-branch1 HEAD^ && echo resolved > file1 && git add file1 && git rebase --continue > output && @@ -259,10 +276,14 @@ test_expect_success 'interrupted squash works as expected' ' git commit -m $n done && one=$(git rev-parse HEAD~3) && - ! FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 && + ( + FAKE_LINES="1 squash 3 2" && + export FAKE_LINES && + test_must_fail git rebase -i HEAD~3 + ) && (echo one; echo two; echo four) > conflict && git add conflict && - ! git rebase --continue && + test_must_fail git rebase --continue && echo resolved > conflict && git add conflict && git rebase --continue && @@ -277,13 +298,17 @@ test_expect_success 'interrupted squash works as expected (case 2)' ' git commit -m $n done && one=$(git rev-parse HEAD~3) && - ! FAKE_LINES="3 squash 1 2" git rebase -i HEAD~3 && + ( + FAKE_LINES="3 squash 1 2" && + export FAKE_LINES && + test_must_fail git rebase -i HEAD~3 + ) && (echo one; echo four) > conflict && git add conflict && - ! git rebase --continue && + test_must_fail git rebase --continue && (echo one; echo two; echo four) > conflict && git add conflict && - ! git rebase --continue && + test_must_fail git rebase --continue && echo resolved > conflict && git add conflict && git rebase --continue && @@ -331,7 +356,7 @@ test_expect_success 'rebase a commit violating pre-commit' ' chmod a+x $PRE_COMMIT && echo "monde! " >> file1 && test_tick && - ! git commit -m doesnt-verify file1 && + test_must_fail git commit -m doesnt-verify file1 && git commit -m doesnt-verify --no-verify file1 && test_tick && FAKE_LINES=2 git rebase -i HEAD~2 -- cgit v1.2.3 From 5352a82bab7422fea53679d56fdef878d51b7968 Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Sat, 12 Jul 2008 17:47:31 +0200 Subject: t3404: test two "preserve merges with -p" cases There are two cases for preserving merges: 1. The merge base is outside the trunk that is to be rebased. Then commits of those other parents must not be picked. 2. The merge base is inside the trunk that is to be rebased. Then all the commits related to that merge must be picked and the merge must be redone. The "preserve merges with -p" test case tested for case 1 only. This patch adds case 2. Signed-off-by: Stephan Beyer Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 1c80148dd5..092aa26573 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -211,7 +211,7 @@ test_expect_success 'preserve merges with -p' ' git add unrelated-file && test_tick && git commit -m "unrelated" && - git checkout -b to-be-rebased master && + git checkout -b another-branch master && echo B > file1 && test_tick && git commit -m J file1 && @@ -220,12 +220,28 @@ test_expect_success 'preserve merges with -p' ' echo C > file1 && test_tick && git commit -m K file1 && + echo D > file1 && + test_tick && + git commit -m L1 file1 && + git checkout HEAD^ && + echo 1 > unrelated-file && + test_tick && + git commit -m L2 unrelated-file && + test_tick && + git merge another-branch && + echo E > file1 && + test_tick && + git commit -m M file1 && + git checkout -b to-be-rebased && test_tick && git rebase -i -p --onto branch1 master && - test $(git rev-parse HEAD^^2) = $(git rev-parse to-be-preserved) && - test $(git rev-parse HEAD~3) = $(git rev-parse branch1) && - test $(git show HEAD:file1) = C && - test $(git show HEAD~2:file1) = B + test $(git rev-parse HEAD~6) = $(git rev-parse branch1) && + test $(git rev-parse HEAD~4^2) = $(git rev-parse to-be-preserved) && + test $(git rev-parse HEAD^^2^) = $(git rev-parse HEAD^^^) && + test $(git show HEAD~5:file1) = B && + test $(git show HEAD~3:file1) = C && + test $(git show HEAD:file1) = E && + test $(git show HEAD:unrelated-file) = 1 ' test_expect_success '--continue tries to commit' ' -- cgit v1.2.3 From 28ed6e7b321bee3dd7e4aa9c0ff7da64844136f6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 16 Jul 2008 03:33:44 +0200 Subject: Rename ".dotest/" to ".git/rebase" and ".dotest-merge" to "rebase-merge" Since the files generated and used during a rebase are never to be tracked, they should live in $GIT_DIR. While at it, avoid the rather meaningless term "dotest" to "rebase", and unhide ".dotest-merge". This was wished for on the mailing list, but so far unimplemented. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 092aa26573..ffe3dd97b7 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -159,19 +159,19 @@ test_expect_success 'stop on conflicting pick' ' git tag new-branch1 && test_must_fail git rebase -i master && test "$(git rev-parse HEAD~3)" = "$(git rev-parse master)" && - test_cmp expect .git/.dotest-merge/patch && + test_cmp expect .git/rebase-merge/patch && test_cmp expect2 file1 && test "$(git-diff --name-status | sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 && - test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) && - test 0 = $(grep -c "^[^#]" < .git/.dotest-merge/git-rebase-todo) + test 4 = $(grep -v "^#" < .git/rebase-merge/done | wc -l) && + test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo) ' test_expect_success 'abort' ' git rebase --abort && test $(git rev-parse new-branch1) = $(git rev-parse HEAD) && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" && - ! test -d .git/.dotest-merge + ! test -d .git/rebase-merge ' test_expect_success 'retain authorship' ' -- cgit v1.2.3 From 71d9451e061841ed5acb576652e09df32c700b86 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Wed, 13 Aug 2008 23:41:23 +0200 Subject: rebase -i -p: handle index and workdir correctly 'git rebase -i -p' forgot to update the index and working directory during fast forwards. Fix this. Makes 'GIT_EDITOR=true rebase -i -p ' a no-op again. Also, it attempted to do a fast forward even if it was instructed not to commit (via -n). Fall back to the cherry-pick code path and let that handle the issue for us. Signed-off-by: Thomas Rast --- t/t3404-rebase-interactive.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index ffe3dd97b7..4d62b9af83 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -202,6 +202,9 @@ test_expect_success 'retain authorship when squashing' ' test_expect_success '-p handles "no changes" gracefully' ' HEAD=$(git rev-parse HEAD) && git rebase -i -p HEAD^ && + git update-index --refresh && + git diff-files --quiet && + git diff-index --quiet --cached HEAD -- && test $HEAD = $(git rev-parse HEAD) ' @@ -235,6 +238,9 @@ test_expect_success 'preserve merges with -p' ' git checkout -b to-be-rebased && test_tick && git rebase -i -p --onto branch1 master && + git update-index --refresh && + git diff-files --quiet && + git diff-index --quiet --cached HEAD -- && test $(git rev-parse HEAD~6) = $(git rev-parse branch1) && test $(git rev-parse HEAD~4^2) = $(git rev-parse to-be-preserved) && test $(git rev-parse HEAD^^2^) = $(git rev-parse HEAD^^^) && -- cgit v1.2.3 From a96dc01e21603849cb454a311f18780c2e839f29 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Wed, 13 Aug 2008 23:41:24 +0200 Subject: rebase -i -p: fix parent rewriting The existing parent rewriting did not handle the case where a previous commit was amended (via edit or squash). Fix by always putting the new sha1 of the last commit into the $REWRITTEN map. Signed-off-by: Thomas Rast --- t/t3404-rebase-interactive.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 4d62b9af83..5aa487ac02 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -250,6 +250,18 @@ test_expect_success 'preserve merges with -p' ' test $(git show HEAD:unrelated-file) = 1 ' +test_expect_success 'edit ancestor with -p' ' + FAKE_LINES="1 edit 2 3 4" git rebase -i -p HEAD~3 && + echo 2 > unrelated-file && + test_tick && + git commit -m L2-modified --amend unrelated-file && + git rebase --continue && + git update-index --refresh && + git diff-files --quiet && + git diff-index --quiet --cached HEAD -- && + test $(git show HEAD:unrelated-file) = 2 +' + test_expect_success '--continue tries to commit' ' test_tick && test_must_fail git rebase -i --onto new-branch1 HEAD^ && -- cgit v1.2.3 From 0cb0e143ffa7d66b7feea0a967b3ac9ae6cd62b0 Mon Sep 17 00:00:00 2001 From: Nanako Shiraishi Date: Wed, 3 Sep 2008 17:59:27 +0900 Subject: tests: use "git xyzzy" form (t0000 - t3599) Converts tests between t0050-t3903. Signed-off-by: Nanako Shiraishi Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 5aa487ac02..e0ded197ec 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -161,7 +161,7 @@ test_expect_success 'stop on conflicting pick' ' test "$(git rev-parse HEAD~3)" = "$(git rev-parse master)" && test_cmp expect .git/rebase-merge/patch && test_cmp expect2 file1 && - test "$(git-diff --name-status | + test "$(git diff --name-status | sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 && test 4 = $(grep -v "^#" < .git/rebase-merge/done | wc -l) && test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo) -- cgit v1.2.3 From ff74126c03a8dfd04e7533573a5c420f2a7112ac Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 10 Oct 2008 13:42:12 +0200 Subject: rebase -i: do not fail when there is no commit to cherry-pick In case there is no commit to apply (for example because you rebase to upstream and all your local patches have been applied there), do not fail. The non-interactive rebase already behaves that way. Do this by introducing a new command, "noop", which is substituted for an empty commit list, so that deleting the commit list can still abort as before. Signed-off-by: Johannes Schindelin Signed-off-by: Shawn O. Pearce --- t/t3404-rebase-interactive.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index e0ded197ec..7d10a27f1d 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -419,4 +419,15 @@ test_expect_success 'rebase with a file named HEAD in worktree' ' ' +test_expect_success 'do "noop" when there is nothing to cherry-pick' ' + + git checkout -b branch4 HEAD && + GIT_EDITOR=: git commit --amend \ + --author="Somebody else " + test $(git rev-parse branch3) != $(git rev-parse branch4) && + git rebase -i branch3 && + test $(git rev-parse branch3) = $(git rev-parse branch4) + +' + test_done -- cgit v1.2.3 From dc7f55cbe9a544ba7af981c00c52efb2d0283a8f Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Thu, 15 Jan 2009 13:56:15 +0100 Subject: t3404: Add test case for aborted --continue after "edit" Add a test case for the bugfix introduced by commit 8beb1f33d "git-rebase-interactive: do not squash commits on abort". Signed-off-by: Stephan Beyer Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 7d10a27f1d..1182b4615b 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -373,6 +373,21 @@ test_expect_success '--continue tries to commit, even for "edit"' ' test $parent = $(git rev-parse HEAD^) ' +test_expect_success 'aborted --continue does not squash commits after "edit"' ' + old=$(git rev-parse HEAD) && + test_tick && + FAKE_LINES="edit 1" git rebase -i HEAD^ && + echo "edited again" > file7 && + git add file7 && + ( + FAKE_COMMIT_MESSAGE=" " && + export FAKE_COMMIT_MESSAGE && + test_must_fail git rebase --continue + ) && + test $old = $(git rev-parse HEAD) && + git rebase --abort +' + test_expect_success 'rebase a detached HEAD' ' grandparent=$(git rev-parse HEAD~2) && git checkout $(git rev-parse HEAD) && -- cgit v1.2.3 From f8aa1b6902d7a77c26b0ef615c9070bbed4be5c4 Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Thu, 15 Jan 2009 13:56:16 +0100 Subject: t3404: Add test case for auto-amending only edited commits after "edit" Add a test case for the bugfix introduced by commit c14c3c82d "git-rebase--interactive: auto amend only edited commit". Signed-off-by: Stephan Beyer Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 1182b4615b..2cc8e7abe1 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -388,6 +388,23 @@ test_expect_success 'aborted --continue does not squash commits after "edit"' ' git rebase --abort ' +test_expect_success 'auto-amend only edited commits after "edit"' ' + test_tick && + FAKE_LINES="edit 1" git rebase -i HEAD^ && + echo "edited again" > file7 && + git add file7 && + FAKE_COMMIT_MESSAGE="edited file7 again" git commit && + echo "and again" > file7 && + git add file7 && + test_tick && + ( + FAKE_COMMIT_MESSAGE="and again" && + export FAKE_COMMIT_MESSAGE && + test_must_fail git rebase --continue + ) && + git rebase --abort +' + test_expect_success 'rebase a detached HEAD' ' grandparent=$(git rev-parse HEAD~2) && git checkout $(git rev-parse HEAD) && -- cgit v1.2.3 From 967476966513564e9c28847f7a974b8af5093493 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 27 Jan 2009 01:07:31 -0800 Subject: rebase -i squashes submodule changes into unrelated commit Attempting to rebase three-commit series (two regular changes, followed by one commit that changes what commit is bound for a submodule path) to squash the first two results in a failure; not just the first two commits squashed, but the change to the submodule is also included in the result. This failure causes the subsequent step to "pick" the change that actually changes the submodule to be applied, because there is no change left to be applied. Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 2cc8e7abe1..6ffb9ad794 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -462,4 +462,30 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' ' ' +test_expect_success 'submodule rebase setup' ' + git checkout A && + mkdir sub && + ( + cd sub && git init && >elif && + git add elif && git commit -m "submodule initial" + ) && + echo 1 >file1 && + git add file1 sub + test_tick && + git commit -m "One" && + echo 2 >file1 && + test_tick && + git commit -a -m "Two" && + ( + cd sub && echo 3 >elif && + git commit -a -m "submodule second" + ) && + test_tick && + git commit -a -m "Three changes submodule" +' + +test_expect_failure 'submodule rebase -i' ' + FAKE_LINES="1 squash 2 3" git rebase -i A +' + test_done -- cgit v1.2.3 From 94c88edef7a69299e12248b910752f1fc26f12d6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 27 Jan 2009 12:42:31 +0100 Subject: Fix submodule squashing into unrelated commit Actually, I think the issue is pretty independent of submodules; when "git commit" gets an empty parameter, it misinterprets it as a file. So avoid passing an empty parameter to "git commit". Actually, this is a nice cleanup, as MSG_FILE and EDIT_COMMIT were mutually exclusive; use one variable instead Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 6ffb9ad794..4becc5513d 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -484,7 +484,7 @@ test_expect_success 'submodule rebase setup' ' git commit -a -m "Three changes submodule" ' -test_expect_failure 'submodule rebase -i' ' +test_expect_success 'submodule rebase -i' ' FAKE_LINES="1 squash 2 3" git rebase -i A ' -- cgit v1.2.3 From 29a03348a336f28025c824436a713cb9cb01b7a6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 27 Jan 2009 23:34:29 +0100 Subject: t3404 & t3411: undo copy&paste Rather than copying and pasting, which is prone to lead to fixes missing in one version, move the fake-editor generator to t/t3404/. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 2cc8e7abe1..3592403af7 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -10,6 +10,10 @@ that the result still makes sense. ' . ./test-lib.sh +. ../lib-rebase.sh + +set_fake_editor + # set up two branches like this: # # A - B - C - D - E @@ -61,39 +65,6 @@ test_expect_success 'setup' ' git tag I ' -echo "#!$SHELL_PATH" >fake-editor.sh -cat >> fake-editor.sh <<\EOF -case "$1" in -*/COMMIT_EDITMSG) - test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1" - test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1" - exit - ;; -esac -test -z "$EXPECT_COUNT" || - test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) || - exit -test -z "$FAKE_LINES" && exit -grep -v '^#' < "$1" > "$1".tmp -rm -f "$1" -cat "$1".tmp -action=pick -for line in $FAKE_LINES; do - case $line in - squash|edit) - action="$line";; - *) - echo sed -n "${line}s/^pick/$action/p" - sed -n "${line}p" < "$1".tmp - sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1" - action=pick;; - esac -done -EOF - -test_set_editor "$(pwd)/fake-editor.sh" -chmod a+x fake-editor.sh - test_expect_success 'no changes are a nop' ' git rebase -i F && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" && -- cgit v1.2.3 From 0e757e30c726d9d8ae82bd9989be3cff5d230288 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 3 Mar 2009 10:55:31 +0100 Subject: rebase -i: avoid 'git reset' when possible When picking commits whose parents have not changed, we do not need to rewrite the commit. We do not need to reset the working directory to the parent's state, either. Requested by Sverre Rabbelier. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 603b003edf..c32ff6682b 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -459,4 +459,15 @@ test_expect_success 'submodule rebase -i' ' FAKE_LINES="1 squash 2 3" git rebase -i A ' +test_expect_success 'avoid unnecessary reset' ' + git checkout master && + test-chmtime =123456789 file3 && + git update-index --refresh && + HEAD=$(git rev-parse HEAD) && + git rebase -i HEAD~4 && + test $HEAD = $(git rev-parse HEAD) && + MTIME=$(test-chmtime -v +0 file3 | sed 's/[^0-9].*$//') && + test 123456789 = $MTIME +' + test_done -- cgit v1.2.3 From 606475f3178784e5a6b3a01dce1a54314345cf43 Mon Sep 17 00:00:00 2001 From: Martin Renold Date: Wed, 1 Jul 2009 22:18:04 +0200 Subject: Remove filename from conflict markers Put filenames into the conflict markers only when they are different. Otherwise they are redundant information clutter. Print the filename explicitely when warning about a binary conflict. Signed-off-by: Martin Renold Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t3404-rebase-interactive.sh') diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index c32ff6682b..a973628e8e 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -119,11 +119,11 @@ index e69de29..00750ed 100644 EOF cat > expect2 << EOF -<<<<<<< HEAD:file1 +<<<<<<< HEAD 2 ======= 3 ->>>>>>> b7ca976... G:file1 +>>>>>>> b7ca976... G EOF test_expect_success 'stop on conflicting pick' ' -- cgit v1.2.3