Merge branch 'pw/rebase-i-regression-fix-tests'
Fix a recent regression to "git rebase -i" and add tests that would have caught it and others. * pw/rebase-i-regression-fix-tests: t3420: fix under GETTEXT_POISON build rebase: add more regression tests for console output rebase: add regression tests for console output rebase -i: add test for reflog message sequencer: print autostash messages to stderr
This commit is contained in:
commit
5452224710
@ -166,14 +166,14 @@ apply_autostash () {
|
|||||||
stash_sha1=$(cat "$state_dir/autostash")
|
stash_sha1=$(cat "$state_dir/autostash")
|
||||||
if git stash apply $stash_sha1 2>&1 >/dev/null
|
if git stash apply $stash_sha1 2>&1 >/dev/null
|
||||||
then
|
then
|
||||||
echo "$(gettext 'Applied autostash.')"
|
echo "$(gettext 'Applied autostash.')" >&2
|
||||||
else
|
else
|
||||||
git stash store -m "autostash" -q $stash_sha1 ||
|
git stash store -m "autostash" -q $stash_sha1 ||
|
||||||
die "$(eval_gettext "Cannot store \$stash_sha1")"
|
die "$(eval_gettext "Cannot store \$stash_sha1")"
|
||||||
gettext 'Applying autostash resulted in conflicts.
|
gettext 'Applying autostash resulted in conflicts.
|
||||||
Your changes are safe in the stash.
|
Your changes are safe in the stash.
|
||||||
You can run "git stash pop" or "git stash drop" at any time.
|
You can run "git stash pop" or "git stash drop" at any time.
|
||||||
'
|
' >&2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
11
sequencer.c
11
sequencer.c
@ -1922,7 +1922,7 @@ static int apply_autostash(struct replay_opts *opts)
|
|||||||
argv_array_push(&child.args, "apply");
|
argv_array_push(&child.args, "apply");
|
||||||
argv_array_push(&child.args, stash_sha1.buf);
|
argv_array_push(&child.args, stash_sha1.buf);
|
||||||
if (!run_command(&child))
|
if (!run_command(&child))
|
||||||
printf(_("Applied autostash.\n"));
|
fprintf(stderr, _("Applied autostash.\n"));
|
||||||
else {
|
else {
|
||||||
struct child_process store = CHILD_PROCESS_INIT;
|
struct child_process store = CHILD_PROCESS_INIT;
|
||||||
|
|
||||||
@ -1936,10 +1936,11 @@ static int apply_autostash(struct replay_opts *opts)
|
|||||||
if (run_command(&store))
|
if (run_command(&store))
|
||||||
ret = error(_("cannot store %s"), stash_sha1.buf);
|
ret = error(_("cannot store %s"), stash_sha1.buf);
|
||||||
else
|
else
|
||||||
printf(_("Applying autostash resulted in conflicts.\n"
|
fprintf(stderr,
|
||||||
"Your changes are safe in the stash.\n"
|
_("Applying autostash resulted in conflicts.\n"
|
||||||
"You can run \"git stash pop\" or"
|
"Your changes are safe in the stash.\n"
|
||||||
" \"git stash drop\" at any time.\n"));
|
"You can run \"git stash pop\" or"
|
||||||
|
" \"git stash drop\" at any time.\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf_release(&stash_sha1);
|
strbuf_release(&stash_sha1);
|
||||||
|
@ -169,6 +169,13 @@ test_expect_success 'reflog for the branch shows state before rebase' '
|
|||||||
test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
|
test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'reflog for the branch shows correct finish message' '
|
||||||
|
printf "rebase -i (finish): refs/heads/branch1 onto %s\n" \
|
||||||
|
"$(git rev-parse branch2)" >expected &&
|
||||||
|
git log -g --pretty=%gs -1 refs/heads/branch1 >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'exchange two commits' '
|
test_expect_success 'exchange two commits' '
|
||||||
set_fake_editor &&
|
set_fake_editor &&
|
||||||
FAKE_LINES="2 1" git rebase -i HEAD~2 &&
|
FAKE_LINES="2 1" git rebase -i HEAD~2 &&
|
||||||
|
@ -33,7 +33,123 @@ test_expect_success setup '
|
|||||||
git commit -m "related commit"
|
git commit -m "related commit"
|
||||||
'
|
'
|
||||||
|
|
||||||
testrebase() {
|
create_expected_success_am () {
|
||||||
|
cat >expected <<-EOF
|
||||||
|
$(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
|
||||||
|
HEAD is now at $(git rev-parse --short feature-branch) third commit
|
||||||
|
First, rewinding head to replay your work on top of it...
|
||||||
|
Applying: second commit
|
||||||
|
Applying: third commit
|
||||||
|
Applied autostash.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
create_expected_success_interactive () {
|
||||||
|
q_to_cr >expected <<-EOF
|
||||||
|
$(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
|
||||||
|
HEAD is now at $(git rev-parse --short feature-branch) third commit
|
||||||
|
Rebasing (1/2)QRebasing (2/2)QApplied autostash.
|
||||||
|
Successfully rebased and updated refs/heads/rebased-feature-branch.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
create_expected_success_merge () {
|
||||||
|
cat >expected <<-EOF
|
||||||
|
$(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
|
||||||
|
HEAD is now at $(git rev-parse --short feature-branch) third commit
|
||||||
|
First, rewinding head to replay your work on top of it...
|
||||||
|
Merging unrelated-onto-branch with HEAD~1
|
||||||
|
Merging:
|
||||||
|
$(git rev-parse --short unrelated-onto-branch) unrelated commit
|
||||||
|
$(git rev-parse --short feature-branch^) second commit
|
||||||
|
found 1 common ancestor:
|
||||||
|
$(git rev-parse --short feature-branch~2) initial commit
|
||||||
|
[detached HEAD $(git rev-parse --short rebased-feature-branch~1)] second commit
|
||||||
|
Author: A U Thor <author@example.com>
|
||||||
|
Date: Thu Apr 7 15:14:13 2005 -0700
|
||||||
|
2 files changed, 2 insertions(+)
|
||||||
|
create mode 100644 file1
|
||||||
|
create mode 100644 file2
|
||||||
|
Committed: 0001 second commit
|
||||||
|
Merging unrelated-onto-branch with HEAD~0
|
||||||
|
Merging:
|
||||||
|
$(git rev-parse --short rebased-feature-branch~1) second commit
|
||||||
|
$(git rev-parse --short feature-branch) third commit
|
||||||
|
found 1 common ancestor:
|
||||||
|
$(git rev-parse --short feature-branch~1) second commit
|
||||||
|
[detached HEAD $(git rev-parse --short rebased-feature-branch)] third commit
|
||||||
|
Author: A U Thor <author@example.com>
|
||||||
|
Date: Thu Apr 7 15:15:13 2005 -0700
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
create mode 100644 file3
|
||||||
|
Committed: 0002 third commit
|
||||||
|
All done.
|
||||||
|
Applied autostash.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
create_expected_failure_am () {
|
||||||
|
cat >expected <<-EOF
|
||||||
|
$(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
|
||||||
|
HEAD is now at $(git rev-parse --short feature-branch) third commit
|
||||||
|
First, rewinding head to replay your work on top of it...
|
||||||
|
Applying: second commit
|
||||||
|
Applying: third commit
|
||||||
|
Applying autostash resulted in conflicts.
|
||||||
|
Your changes are safe in the stash.
|
||||||
|
You can run "git stash pop" or "git stash drop" at any time.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
create_expected_failure_interactive () {
|
||||||
|
q_to_cr >expected <<-EOF
|
||||||
|
$(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
|
||||||
|
HEAD is now at $(git rev-parse --short feature-branch) third commit
|
||||||
|
Rebasing (1/2)QRebasing (2/2)QApplying autostash resulted in conflicts.
|
||||||
|
Your changes are safe in the stash.
|
||||||
|
You can run "git stash pop" or "git stash drop" at any time.
|
||||||
|
Successfully rebased and updated refs/heads/rebased-feature-branch.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
create_expected_failure_merge () {
|
||||||
|
cat >expected <<-EOF
|
||||||
|
$(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
|
||||||
|
HEAD is now at $(git rev-parse --short feature-branch) third commit
|
||||||
|
First, rewinding head to replay your work on top of it...
|
||||||
|
Merging unrelated-onto-branch with HEAD~1
|
||||||
|
Merging:
|
||||||
|
$(git rev-parse --short unrelated-onto-branch) unrelated commit
|
||||||
|
$(git rev-parse --short feature-branch^) second commit
|
||||||
|
found 1 common ancestor:
|
||||||
|
$(git rev-parse --short feature-branch~2) initial commit
|
||||||
|
[detached HEAD $(git rev-parse --short rebased-feature-branch~1)] second commit
|
||||||
|
Author: A U Thor <author@example.com>
|
||||||
|
Date: Thu Apr 7 15:14:13 2005 -0700
|
||||||
|
2 files changed, 2 insertions(+)
|
||||||
|
create mode 100644 file1
|
||||||
|
create mode 100644 file2
|
||||||
|
Committed: 0001 second commit
|
||||||
|
Merging unrelated-onto-branch with HEAD~0
|
||||||
|
Merging:
|
||||||
|
$(git rev-parse --short rebased-feature-branch~1) second commit
|
||||||
|
$(git rev-parse --short feature-branch) third commit
|
||||||
|
found 1 common ancestor:
|
||||||
|
$(git rev-parse --short feature-branch~1) second commit
|
||||||
|
[detached HEAD $(git rev-parse --short rebased-feature-branch)] third commit
|
||||||
|
Author: A U Thor <author@example.com>
|
||||||
|
Date: Thu Apr 7 15:15:13 2005 -0700
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
create mode 100644 file3
|
||||||
|
Committed: 0002 third commit
|
||||||
|
All done.
|
||||||
|
Applying autostash resulted in conflicts.
|
||||||
|
Your changes are safe in the stash.
|
||||||
|
You can run "git stash pop" or "git stash drop" at any time.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
testrebase () {
|
||||||
type=$1
|
type=$1
|
||||||
dotest=$2
|
dotest=$2
|
||||||
|
|
||||||
@ -51,14 +167,20 @@ testrebase() {
|
|||||||
test_config rebase.autostash true &&
|
test_config rebase.autostash true &&
|
||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
git checkout -b rebased-feature-branch feature-branch &&
|
git checkout -b rebased-feature-branch feature-branch &&
|
||||||
test_when_finished git branch -D rebased-feature-branch &&
|
|
||||||
echo dirty >>file3 &&
|
echo dirty >>file3 &&
|
||||||
git rebase$type unrelated-onto-branch &&
|
git rebase$type unrelated-onto-branch >actual 2>&1 &&
|
||||||
grep unrelated file4 &&
|
grep unrelated file4 &&
|
||||||
grep dirty file3 &&
|
grep dirty file3 &&
|
||||||
git checkout feature-branch
|
git checkout feature-branch
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success "rebase$type --autostash: check output" '
|
||||||
|
test_when_finished git branch -D rebased-feature-branch &&
|
||||||
|
suffix=${type#\ --} && suffix=${suffix:-am} &&
|
||||||
|
create_expected_success_$suffix &&
|
||||||
|
test_i18ncmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success "rebase$type: dirty index, non-conflicting rebase" '
|
test_expect_success "rebase$type: dirty index, non-conflicting rebase" '
|
||||||
test_config rebase.autostash true &&
|
test_config rebase.autostash true &&
|
||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
@ -137,10 +259,9 @@ testrebase() {
|
|||||||
test_config rebase.autostash true &&
|
test_config rebase.autostash true &&
|
||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
git checkout -b rebased-feature-branch feature-branch &&
|
git checkout -b rebased-feature-branch feature-branch &&
|
||||||
test_when_finished git branch -D rebased-feature-branch &&
|
|
||||||
echo dirty >file4 &&
|
echo dirty >file4 &&
|
||||||
git add file4 &&
|
git add file4 &&
|
||||||
git rebase$type unrelated-onto-branch &&
|
git rebase$type unrelated-onto-branch >actual 2>&1 &&
|
||||||
test_path_is_missing $dotest &&
|
test_path_is_missing $dotest &&
|
||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
grep unrelated file4 &&
|
grep unrelated file4 &&
|
||||||
@ -149,6 +270,13 @@ testrebase() {
|
|||||||
git stash pop &&
|
git stash pop &&
|
||||||
grep dirty file4
|
grep dirty file4
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success "rebase$type: check output with conflicting stash" '
|
||||||
|
test_when_finished git branch -D rebased-feature-branch &&
|
||||||
|
suffix=${type#\ --} && suffix=${suffix:-am} &&
|
||||||
|
create_expected_failure_$suffix &&
|
||||||
|
test_i18ncmp expected actual
|
||||||
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
test_expect_success "rebase: fast-forward rebase" '
|
test_expect_success "rebase: fast-forward rebase" '
|
||||||
|
Loading…
Reference in New Issue
Block a user