* [BUG?] rebase -i -p leaves index changed
@ 2008-08-12 9:16 Thomas Rast
2008-08-13 10:04 ` [PATCH 1/2] rebase -i -p: handle index and workdir correctly Thomas Rast
2008-08-13 20:51 ` [BUG?] rebase -i -p leaves index changed Stephan Beyer
0 siblings, 2 replies; 10+ messages in thread
From: Thomas Rast @ 2008-08-12 9:16 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin
[-- Attachment #1: Type: text/plain, Size: 1519 bytes --]
Hi,
'rebase -i -p' appears to be a bit confused about what it is doing.
Try a history like this:
O -- A -- M -- B
\ /
\- C -/
built by:
git init
touch foo
git add foo
git ci -m initial
git tag root
git co -b side
echo blah > other
git add other
git ci -m other
git co master
echo a >> foo
git add foo
git ci -m a
git add foo
git merge side
echo b >> foo
git add foo
git ci -m 'b: depends on side'
First try this:
GIT_EDITOR=true git rebase -i -p root
git diff --cached
resulting in
diff --git a/foo b/foo
index 422c2b7..e69de29 100644
--- a/foo
+++ b/foo
@@ -1,2 +0,0 @@
-a
-b
diff --git a/other b/other
deleted file mode 100644
index 907b308..0000000
--- a/other
+++ /dev/null
@@ -1 +0,0 @@
-blah
Second, 'edit' is also a bit suspicious:
git reset --hard
GIT_EDITOR='perl -i -pe "s/pick 096/edit 096/"' git rebase -i -p root
Despite claiming "Stopped at 096[...] a", a quick 'git show' tells us
that it is actually stuck at 'initial'. (At least 'git rebase
--continue' then ends up with the same result as the first test.)
Granted, I'm not entirely sure what it _should_ do. In my use case
(relating to the filter-branch topic), C was a commit from elsewhere
that B depended on. So I kind of hoped 'rebase -i -p' would let me
edit A, then rebuild M and B on top, while leaving C alone.
- Thomas
--
Thomas Rast
trast@student.ethz.ch
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] rebase -i -p: handle index and workdir correctly
2008-08-12 9:16 [BUG?] rebase -i -p leaves index changed Thomas Rast
@ 2008-08-13 10:04 ` Thomas Rast
2008-08-13 10:04 ` [PATCH 2/2] rebase -i -p: fix parent rewriting Thomas Rast
2008-08-13 10:07 ` [PATCH 1/2] rebase -i -p: handle index and workdir correctly Thomas Rast
2008-08-13 20:51 ` [BUG?] rebase -i -p leaves index changed Stephan Beyer
1 sibling, 2 replies; 10+ messages in thread
From: Thomas Rast @ 2008-08-13 10:04 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Junio C Hamano
'git rebase -i -p' forgot to update the index and working directory
during fast forwards. Fix this. Restores plain 'git rebase -i -p' to
be a no-op.
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 <trast@student.ethz.ch>
---
git-rebase--interactive.sh | 14 ++++++++++++--
t/t3404-rebase-interactive.sh | 6 ++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 4e334ba..51a6147 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -145,7 +145,16 @@ pick_one () {
}
pick_one_preserving_merges () {
- case "$1" in -n) sha1=$2 ;; *) sha1=$1 ;; esac
+ fast_forward=t
+ case "$1" in
+ -n)
+ fast_forward=f
+ sha1=$2
+ ;;
+ *)
+ sha1=$1
+ ;;
+ esac
sha1=$(git rev-parse $sha1)
if test -f "$DOTEST"/current-commit
@@ -181,7 +190,8 @@ pick_one_preserving_merges () {
case $fast_forward in
t)
output warn "Fast forward to $sha1"
- test $preserve = f || echo $sha1 > "$REWRITTEN"/$sha1
+ output git reset --hard $sha1 ||
+ die "Cannot fast forward to $sha1"
;;
f)
test "a$1" = a-n && die "Refusing to squash a merge: $sha1"
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index ffe3dd9..4d62b9a 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^^^) &&
--
1.6.0.rc2.38.g33ece.dirty
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] rebase -i -p: fix parent rewriting
2008-08-13 10:04 ` [PATCH 1/2] rebase -i -p: handle index and workdir correctly Thomas Rast
@ 2008-08-13 10:04 ` Thomas Rast
2008-08-13 10:07 ` [PATCH 1/2] rebase -i -p: handle index and workdir correctly Thomas Rast
1 sibling, 0 replies; 10+ messages in thread
From: Thomas Rast @ 2008-08-13 10:04 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Junio C Hamano
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 <trast@student.ethz.ch>
---
git-rebase--interactive.sh | 6 ++----
t/t3404-rebase-interactive.sh | 12 ++++++++++++
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 51a6147..929d681 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -165,15 +165,14 @@ pick_one_preserving_merges () {
die "Cannot write current commit's replacement sha1"
fi
+ echo $sha1 > "$DOTEST"/current-commit
+
# rewrite parents; if none were rewritten, we can fast-forward.
- fast_forward=t
- preserve=t
new_parents=
for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
do
if test -f "$REWRITTEN"/$p
then
- preserve=f
new_p=$(cat "$REWRITTEN"/$p)
test $p != $new_p && fast_forward=f
case "$new_parents" in
@@ -201,7 +200,6 @@ pick_one_preserving_merges () {
output git checkout $first_parent 2> /dev/null ||
die "Cannot move HEAD to $first_parent"
- echo $sha1 > "$DOTEST"/current-commit
case "$new_parents" in
' '*' '*)
# redo merge
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 4d62b9a..5aa487a 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^ &&
--
1.6.0.rc2.38.g33ece.dirty
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] rebase -i -p: handle index and workdir correctly
2008-08-13 10:04 ` [PATCH 1/2] rebase -i -p: handle index and workdir correctly Thomas Rast
2008-08-13 10:04 ` [PATCH 2/2] rebase -i -p: fix parent rewriting Thomas Rast
@ 2008-08-13 10:07 ` Thomas Rast
2008-08-13 11:56 ` [PATCH v2 " Thomas Rast
1 sibling, 1 reply; 10+ messages in thread
From: Thomas Rast @ 2008-08-13 10:07 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Junio C Hamano
[-- Attachment #1: Type: text/plain, Size: 330 bytes --]
Thomas Rast wrote:
> - test $preserve = f || echo $sha1 > "$REWRITTEN"/$sha1
> + output git reset --hard $sha1 ||
> + die "Cannot fast forward to $sha1"
Doh. I obviously shouldn't try to split patches before lunch.
Please disregard, I'll fix and resend when I get back.
--
Thomas Rast
trast@student.ethz.ch
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/2] rebase -i -p: handle index and workdir correctly
2008-08-13 10:07 ` [PATCH 1/2] rebase -i -p: handle index and workdir correctly Thomas Rast
@ 2008-08-13 11:56 ` Thomas Rast
2008-08-13 11:57 ` [PATCH v2 2/2] rebase -i -p: fix parent rewriting Thomas Rast
2008-08-13 20:58 ` [PATCH v2 1/2] rebase -i -p: handle index and workdir correctly Stephan Beyer
0 siblings, 2 replies; 10+ messages in thread
From: Thomas Rast @ 2008-08-13 11:56 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Junio C Hamano
'git rebase -i -p' forgot to update the index and working directory
during fast forwards. Fix this. Makes 'GIT_EDITOR=true rebase -i -p
<ancestor>' 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 <trast@student.ethz.ch>
---
git-rebase--interactive.sh | 13 ++++++++++++-
t/t3404-rebase-interactive.sh | 6 ++++++
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 4e334ba..1dc24b1 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -145,7 +145,16 @@ pick_one () {
}
pick_one_preserving_merges () {
- case "$1" in -n) sha1=$2 ;; *) sha1=$1 ;; esac
+ fast_forward=t
+ case "$1" in
+ -n)
+ fast_forward=f
+ sha1=$2
+ ;;
+ *)
+ sha1=$1
+ ;;
+ esac
sha1=$(git rev-parse $sha1)
if test -f "$DOTEST"/current-commit
@@ -182,6 +191,8 @@ pick_one_preserving_merges () {
t)
output warn "Fast forward to $sha1"
test $preserve = f || echo $sha1 > "$REWRITTEN"/$sha1
+ output git reset --hard $sha1 ||
+ die "Cannot fast forward to $sha1"
;;
f)
test "a$1" = a-n && die "Refusing to squash a merge: $sha1"
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index ffe3dd9..4d62b9a 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^^^) &&
--
1.6.0.rc2.36.g234a
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/2] rebase -i -p: fix parent rewriting
2008-08-13 11:56 ` [PATCH v2 " Thomas Rast
@ 2008-08-13 11:57 ` Thomas Rast
2008-08-13 20:58 ` [PATCH v2 1/2] rebase -i -p: handle index and workdir correctly Stephan Beyer
1 sibling, 0 replies; 10+ messages in thread
From: Thomas Rast @ 2008-08-13 11:57 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Junio C Hamano
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 <trast@student.ethz.ch>
---
git-rebase--interactive.sh | 7 ++-----
t/t3404-rebase-interactive.sh | 12 ++++++++++++
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 1dc24b1..929d681 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -165,15 +165,14 @@ pick_one_preserving_merges () {
die "Cannot write current commit's replacement sha1"
fi
+ echo $sha1 > "$DOTEST"/current-commit
+
# rewrite parents; if none were rewritten, we can fast-forward.
- fast_forward=t
- preserve=t
new_parents=
for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
do
if test -f "$REWRITTEN"/$p
then
- preserve=f
new_p=$(cat "$REWRITTEN"/$p)
test $p != $new_p && fast_forward=f
case "$new_parents" in
@@ -190,7 +189,6 @@ pick_one_preserving_merges () {
case $fast_forward in
t)
output warn "Fast forward to $sha1"
- test $preserve = f || echo $sha1 > "$REWRITTEN"/$sha1
output git reset --hard $sha1 ||
die "Cannot fast forward to $sha1"
;;
@@ -202,7 +200,6 @@ pick_one_preserving_merges () {
output git checkout $first_parent 2> /dev/null ||
die "Cannot move HEAD to $first_parent"
- echo $sha1 > "$DOTEST"/current-commit
case "$new_parents" in
' '*' '*)
# redo merge
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 4d62b9a..5aa487a 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^ &&
--
1.6.0.rc2.36.g234a
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [BUG?] rebase -i -p leaves index changed
2008-08-12 9:16 [BUG?] rebase -i -p leaves index changed Thomas Rast
2008-08-13 10:04 ` [PATCH 1/2] rebase -i -p: handle index and workdir correctly Thomas Rast
@ 2008-08-13 20:51 ` Stephan Beyer
1 sibling, 0 replies; 10+ messages in thread
From: Stephan Beyer @ 2008-08-13 20:51 UTC (permalink / raw)
To: Thomas Rast; +Cc: git, Johannes Schindelin
[-- Attachment #1: Type: text/plain, Size: 1748 bytes --]
Hi,
Thomas Rast wrote:
> 'rebase -i -p' appears to be a bit confused about what it is doing.
> Try a history like this:
>
> O -- A -- M -- B
> \ /
> \- C -/
>
> built by:
>
> git init
> touch foo
> git add foo
> git ci -m initial
> git tag root
> git co -b side
Puh, it is nice that you provide a sequence how you generated your test
case, but "ci" and "co" are no git commands. Ok, because of the
sequence it was clear to me that you mean "commit" and "checkout",
but I couldn't just c&p it into my xterm :(
;-)
> Second, 'edit' is also a bit suspicious:
>
> git reset --hard
> GIT_EDITOR='perl -i -pe "s/pick 096/edit 096/"' git rebase -i -p root
This perl expression does nothing if your commit is not prefixed with 096 ;)
But I tested by changing the line of commit "a" to "edit".
> Despite claiming "Stopped at 096[...] a", a quick 'git show' tells us
> that it is actually stuck at 'initial'. (At least 'git rebase
> --continue' then ends up with the same result as the first test.)
Regarding your [BUG?]: this is a bug, definitely.
> Granted, I'm not entirely sure what it _should_ do. In my use case
> (relating to the filter-branch topic), C was a commit from elsewhere
> that B depended on. So I kind of hoped 'rebase -i -p' would let me
> edit A, then rebuild M and B on top, while leaving C alone.
I think your hope is right. So this is also a bug.
I tested this with my sequencer-based rebase -i -p first and it worked
as you hope. I tested it with your v2 patches and it works, too. ;)
So I'm having a deeper look at your patches in some minutes...
Regards,
Stephan
--
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] rebase -i -p: handle index and workdir correctly
2008-08-13 11:56 ` [PATCH v2 " Thomas Rast
2008-08-13 11:57 ` [PATCH v2 2/2] rebase -i -p: fix parent rewriting Thomas Rast
@ 2008-08-13 20:58 ` Stephan Beyer
2008-08-13 21:41 ` [PATCH v3 " Thomas Rast
1 sibling, 1 reply; 10+ messages in thread
From: Stephan Beyer @ 2008-08-13 20:58 UTC (permalink / raw)
To: Thomas Rast; +Cc: git, Johannes Schindelin, Junio C Hamano
Hi,
Thomas Rast wrote:
> 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 <trast@student.ethz.ch>
> ---
> git-rebase--interactive.sh | 13 ++++++++++++-
> t/t3404-rebase-interactive.sh | 6 ++++++
> 2 files changed, 18 insertions(+), 1 deletions(-)
>
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 4e334ba..1dc24b1 100755
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -145,7 +145,16 @@ pick_one () {
> }
>
> pick_one_preserving_merges () {
> - case "$1" in -n) sha1=$2 ;; *) sha1=$1 ;; esac
> + fast_forward=t
> + case "$1" in
> + -n)
> + fast_forward=f
> + sha1=$2
The intention of setting fast_forward=f is clear, but it is overwritten
later on line 169 that is not shown in this patch:
168: # rewrite parents; if none were rewritten, we can fast-forward.
169: fast_forward=t
Clearly, this is due to your patch split, because after the second
patch, this is fixed.
The rest of this patch seems to be ok to me.
Regards.
--
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 1/2] rebase -i -p: handle index and workdir correctly
2008-08-13 20:58 ` [PATCH v2 1/2] rebase -i -p: handle index and workdir correctly Stephan Beyer
@ 2008-08-13 21:41 ` Thomas Rast
2008-08-13 21:41 ` [PATCH v3 2/2] rebase -i -p: fix parent rewriting Thomas Rast
0 siblings, 1 reply; 10+ messages in thread
From: Thomas Rast @ 2008-08-13 21:41 UTC (permalink / raw)
To: git; +Cc: gitster, Johannes Schindelin
'git rebase -i -p' forgot to update the index and working directory
during fast forwards. Fix this. Makes 'GIT_EDITOR=true rebase -i -p
<ancestor>' 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 <trast@student.ethz.ch>
---
Stephan Beyer <s-beyer@gmx.net> wrote:
>
> The intention of setting fast_forward=f is clear, but it is overwritten
> later on line 169 that is not shown in this patch:
[...]
> Clearly, this is due to your patch split, because after the second
> patch, this is fixed.
Indeed, thanks for catching this.
git-rebase--interactive.sh | 14 ++++++++++++--
t/t3404-rebase-interactive.sh | 6 ++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 4e334ba..58126bd 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -145,7 +145,16 @@ pick_one () {
}
pick_one_preserving_merges () {
- case "$1" in -n) sha1=$2 ;; *) sha1=$1 ;; esac
+ fast_forward=t
+ case "$1" in
+ -n)
+ fast_forward=f
+ sha1=$2
+ ;;
+ *)
+ sha1=$1
+ ;;
+ esac
sha1=$(git rev-parse $sha1)
if test -f "$DOTEST"/current-commit
@@ -157,7 +166,6 @@ pick_one_preserving_merges () {
fi
# rewrite parents; if none were rewritten, we can fast-forward.
- fast_forward=t
preserve=t
new_parents=
for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
@@ -182,6 +190,8 @@ pick_one_preserving_merges () {
t)
output warn "Fast forward to $sha1"
test $preserve = f || echo $sha1 > "$REWRITTEN"/$sha1
+ output git reset --hard $sha1 ||
+ die "Cannot fast forward to $sha1"
;;
f)
test "a$1" = a-n && die "Refusing to squash a merge: $sha1"
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index ffe3dd9..4d62b9a 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^^^) &&
--
1.6.0.rc2.69.g29dd9
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 2/2] rebase -i -p: fix parent rewriting
2008-08-13 21:41 ` [PATCH v3 " Thomas Rast
@ 2008-08-13 21:41 ` Thomas Rast
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Rast @ 2008-08-13 21:41 UTC (permalink / raw)
To: git; +Cc: gitster, Johannes Schindelin
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 <trast@student.ethz.ch>
---
git-rebase--interactive.sh | 6 ++----
t/t3404-rebase-interactive.sh | 12 ++++++++++++
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 58126bd..929d681 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -165,14 +165,14 @@ pick_one_preserving_merges () {
die "Cannot write current commit's replacement sha1"
fi
+ echo $sha1 > "$DOTEST"/current-commit
+
# rewrite parents; if none were rewritten, we can fast-forward.
- preserve=t
new_parents=
for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
do
if test -f "$REWRITTEN"/$p
then
- preserve=f
new_p=$(cat "$REWRITTEN"/$p)
test $p != $new_p && fast_forward=f
case "$new_parents" in
@@ -189,7 +189,6 @@ pick_one_preserving_merges () {
case $fast_forward in
t)
output warn "Fast forward to $sha1"
- test $preserve = f || echo $sha1 > "$REWRITTEN"/$sha1
output git reset --hard $sha1 ||
die "Cannot fast forward to $sha1"
;;
@@ -201,7 +200,6 @@ pick_one_preserving_merges () {
output git checkout $first_parent 2> /dev/null ||
die "Cannot move HEAD to $first_parent"
- echo $sha1 > "$DOTEST"/current-commit
case "$new_parents" in
' '*' '*)
# redo merge
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 4d62b9a..5aa487a 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^ &&
--
1.6.0.rc2.69.g29dd9
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-08-13 21:42 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-12 9:16 [BUG?] rebase -i -p leaves index changed Thomas Rast
2008-08-13 10:04 ` [PATCH 1/2] rebase -i -p: handle index and workdir correctly Thomas Rast
2008-08-13 10:04 ` [PATCH 2/2] rebase -i -p: fix parent rewriting Thomas Rast
2008-08-13 10:07 ` [PATCH 1/2] rebase -i -p: handle index and workdir correctly Thomas Rast
2008-08-13 11:56 ` [PATCH v2 " Thomas Rast
2008-08-13 11:57 ` [PATCH v2 2/2] rebase -i -p: fix parent rewriting Thomas Rast
2008-08-13 20:58 ` [PATCH v2 1/2] rebase -i -p: handle index and workdir correctly Stephan Beyer
2008-08-13 21:41 ` [PATCH v3 " Thomas Rast
2008-08-13 21:41 ` [PATCH v3 2/2] rebase -i -p: fix parent rewriting Thomas Rast
2008-08-13 20:51 ` [BUG?] rebase -i -p leaves index changed Stephan Beyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).