2013-05-12 11:56:41 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2013 Ramkumar Ramachandra
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='git rebase --autostash tests'
|
2020-11-18 23:44:25 +00:00
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
tests: mark tests relying on the current default for `init.defaultBranch`
In addition to the manual adjustment to let the `linux-gcc` CI job run
the test suite with `master` and then with `main`, this patch makes sure
that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts
that currently rely on the initial branch name being `master by default.
To determine which test scripts to mark up, the first step was to
force-set the default branch name to `master` in
- all test scripts that contain the keyword `master`,
- t4211, which expects `t/t4211/history.export` with a hard-coded ref to
initialize the default branch,
- t5560 because it sources `t/t556x_common` which uses `master`,
- t8002 and t8012 because both source `t/annotate-tests.sh` which also
uses `master`)
This trick was performed by this command:
$ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' $(git grep -l master t/t[0-9]*.sh) \
t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh
After that, careful, manual inspection revealed that some of the test
scripts containing the needle `master` do not actually rely on a
specific default branch name: either they mention `master` only in a
comment, or they initialize that branch specificially, or they do not
actually refer to the current default branch. Therefore, the
aforementioned modification was undone in those test scripts thusly:
$ git checkout HEAD -- \
t/t0027-auto-crlf.sh t/t0060-path-utils.sh \
t/t1011-read-tree-sparse-checkout.sh \
t/t1305-config-include.sh t/t1309-early-config.sh \
t/t1402-check-ref-format.sh t/t1450-fsck.sh \
t/t2024-checkout-dwim.sh \
t/t2106-update-index-assume-unchanged.sh \
t/t3040-subprojects-basic.sh t/t3301-notes.sh \
t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \
t/t3436-rebase-more-options.sh \
t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \
t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \
t/t5511-refspec.sh t/t5526-fetch-submodules.sh \
t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \
t/t5548-push-porcelain.sh \
t/t5552-skipping-fetch-negotiator.sh \
t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \
t/t5614-clone-submodules-shallow.sh \
t/t7508-status.sh t/t7606-merge-custom.sh \
t/t9302-fast-import-unpack-limit.sh
We excluded one set of test scripts in these commands, though: the range
of `git p4` tests. The reason? `git p4` stores the (foreign) remote
branch in the branch called `p4/master`, which is obviously not the
default branch. Manual analysis revealed that only five of these tests
actually require a specific default branch name to pass; They were
modified thusly:
$ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' t/t980[0167]*.sh t/t9811*.sh
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-18 23:44:19 +00:00
|
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
|
2013-05-12 11:56:41 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
echo hello-world >file0 &&
|
|
|
|
git add . &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "initial commit" &&
|
|
|
|
git checkout -b feature-branch &&
|
|
|
|
echo another-hello >file1 &&
|
|
|
|
echo goodbye >file2 &&
|
|
|
|
git add . &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "second commit" &&
|
|
|
|
echo final-goodbye >file3 &&
|
|
|
|
git add . &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "third commit" &&
|
2020-11-18 23:44:25 +00:00
|
|
|
git checkout -b unrelated-onto-branch main &&
|
2013-05-12 11:56:41 +00:00
|
|
|
echo unrelated >file4 &&
|
|
|
|
git add . &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "unrelated commit" &&
|
2020-11-18 23:44:25 +00:00
|
|
|
git checkout -b related-onto-branch main &&
|
2013-05-12 11:56:41 +00:00
|
|
|
echo conflicting-change >file2 &&
|
|
|
|
git add . &&
|
|
|
|
test_tick &&
|
2019-07-04 09:47:02 +00:00
|
|
|
git commit -m "related commit" &&
|
|
|
|
remove_progress_re="$(printf "s/.*\\r//")"
|
2013-05-12 11:56:41 +00:00
|
|
|
'
|
|
|
|
|
2020-02-15 21:36:41 +00:00
|
|
|
create_expected_success_apply () {
|
2017-06-19 17:56:04 +00:00
|
|
|
cat >expected <<-EOF
|
|
|
|
$(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
|
|
|
|
First, rewinding head to replay your work on top of it...
|
|
|
|
Applying: second commit
|
|
|
|
Applying: third commit
|
|
|
|
Applied autostash.
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2020-02-15 21:36:41 +00:00
|
|
|
create_expected_success_merge () {
|
2017-06-19 17:56:04 +00:00
|
|
|
q_to_cr >expected <<-EOF
|
|
|
|
$(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
|
2019-07-04 09:47:02 +00:00
|
|
|
Applied autostash.
|
|
|
|
Successfully rebased and updated refs/heads/rebased-feature-branch.
|
2017-06-19 17:56:04 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2020-02-15 21:36:41 +00:00
|
|
|
create_expected_failure_apply () {
|
2017-06-19 17:56:05 +00:00
|
|
|
cat >expected <<-EOF
|
|
|
|
$(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-02-15 21:36:41 +00:00
|
|
|
create_expected_failure_merge () {
|
2019-07-04 09:47:02 +00:00
|
|
|
cat >expected <<-EOF
|
2017-06-19 17:56:05 +00:00
|
|
|
$(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
|
2019-07-04 09:47:02 +00:00
|
|
|
Applying autostash resulted in conflicts.
|
2017-06-19 17:56:05 +00:00
|
|
|
Your changes are safe in the stash.
|
|
|
|
You can run "git stash pop" or "git stash drop" at any time.
|
2019-07-04 09:47:02 +00:00
|
|
|
Successfully rebased and updated refs/heads/rebased-feature-branch.
|
2017-06-19 17:56:05 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2017-06-19 17:56:04 +00:00
|
|
|
testrebase () {
|
2013-05-12 11:56:41 +00:00
|
|
|
type=$1
|
|
|
|
dotest=$2
|
|
|
|
|
2015-09-10 22:30:51 +00:00
|
|
|
test_expect_success "rebase$type: dirty worktree, --no-autostash" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b rebased-feature-branch feature-branch &&
|
|
|
|
test_when_finished git branch -D rebased-feature-branch &&
|
|
|
|
test_when_finished git checkout feature-branch &&
|
|
|
|
echo dirty >>file3 &&
|
|
|
|
test_must_fail git rebase$type --no-autostash unrelated-onto-branch
|
|
|
|
'
|
|
|
|
|
2013-05-12 11:56:41 +00:00
|
|
|
test_expect_success "rebase$type: dirty worktree, non-conflicting rebase" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b rebased-feature-branch feature-branch &&
|
|
|
|
echo dirty >>file3 &&
|
2017-06-19 17:56:04 +00:00
|
|
|
git rebase$type unrelated-onto-branch >actual 2>&1 &&
|
2013-05-12 11:56:41 +00:00
|
|
|
grep unrelated file4 &&
|
|
|
|
grep dirty file3 &&
|
|
|
|
git checkout feature-branch
|
|
|
|
'
|
|
|
|
|
2017-06-19 17:56:04 +00:00
|
|
|
test_expect_success "rebase$type --autostash: check output" '
|
|
|
|
test_when_finished git branch -D rebased-feature-branch &&
|
2020-02-15 21:36:41 +00:00
|
|
|
suffix=${type#\ --} && suffix=${suffix:-apply} &&
|
|
|
|
if test ${suffix} = "interactive"; then
|
|
|
|
suffix=merge
|
rebase: implement --merge via the interactive machinery
As part of an ongoing effort to make rebase have more uniform behavior,
modify the merge backend to behave like the interactive one, by
re-implementing it on top of the latter.
Interactive rebases are implemented in terms of cherry-pick rather than
the merge-recursive builtin, but cherry-pick also calls into the
recursive merge machinery by default and can accept special merge
strategies and/or special strategy options. As such, there really is
not any need for having both git-rebase--merge and
git-rebase--interactive anymore. Delete git-rebase--merge.sh and
instead implement it in builtin/rebase.c.
This results in a few deliberate but small user-visible changes:
* The progress output is modified (see t3406 and t3420 for examples)
* A few known test failures are now fixed (see t3421)
* bash-prompt during a rebase --merge is now REBASE-i instead of
REBASE-m. Reason: The prompt is a reflection of the backend in use;
this allows users to report an issue to the git mailing list with
the appropriate backend information, and allows advanced users to
know where to search for relevant control files. (see t9903)
testcase modification notes:
t3406: --interactive and --merge had slightly different progress output
while running; adjust a test to match the new expectation
t3420: these test precise output while running, but rebase--am,
rebase--merge, and rebase--interactive all were built on very
different commands (am, merge-recursive, cherry-pick), so the
tests expected different output for each type. Now we expect
--merge and --interactive to have the same output.
t3421: --interactive fixes some bugs in --merge! Wahoo!
t9903: --merge uses the interactive backend so the prompt expected is
now REBASE-i.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-12-11 16:11:39 +00:00
|
|
|
fi &&
|
2017-06-19 17:56:04 +00:00
|
|
|
create_expected_success_$suffix &&
|
2019-07-04 09:47:02 +00:00
|
|
|
sed "$remove_progress_re" <actual >actual2 &&
|
2021-02-11 01:53:53 +00:00
|
|
|
test_cmp expected actual2
|
2017-06-19 17:56:04 +00:00
|
|
|
'
|
|
|
|
|
2013-05-12 11:56:41 +00:00
|
|
|
test_expect_success "rebase$type: dirty index, non-conflicting rebase" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b rebased-feature-branch feature-branch &&
|
|
|
|
test_when_finished git branch -D rebased-feature-branch &&
|
|
|
|
echo dirty >>file3 &&
|
|
|
|
git add file3 &&
|
|
|
|
git rebase$type unrelated-onto-branch &&
|
|
|
|
grep unrelated file4 &&
|
|
|
|
grep dirty file3 &&
|
|
|
|
git checkout feature-branch
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "rebase$type: conflicting rebase" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b rebased-feature-branch feature-branch &&
|
|
|
|
test_when_finished git branch -D rebased-feature-branch &&
|
|
|
|
echo dirty >>file3 &&
|
|
|
|
test_must_fail git rebase$type related-onto-branch &&
|
|
|
|
test_path_is_file $dotest/autostash &&
|
2018-08-22 18:13:20 +00:00
|
|
|
test_path_is_missing file3 &&
|
2013-05-12 11:56:41 +00:00
|
|
|
rm -rf $dotest &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout feature-branch
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "rebase$type: --continue" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b rebased-feature-branch feature-branch &&
|
|
|
|
test_when_finished git branch -D rebased-feature-branch &&
|
|
|
|
echo dirty >>file3 &&
|
|
|
|
test_must_fail git rebase$type related-onto-branch &&
|
|
|
|
test_path_is_file $dotest/autostash &&
|
2018-08-22 18:13:20 +00:00
|
|
|
test_path_is_missing file3 &&
|
2013-05-12 11:56:41 +00:00
|
|
|
echo "conflicting-plus-goodbye" >file2 &&
|
|
|
|
git add file2 &&
|
|
|
|
git rebase --continue &&
|
|
|
|
test_path_is_missing $dotest/autostash &&
|
|
|
|
grep dirty file3 &&
|
|
|
|
git checkout feature-branch
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "rebase$type: --skip" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b rebased-feature-branch feature-branch &&
|
|
|
|
test_when_finished git branch -D rebased-feature-branch &&
|
|
|
|
echo dirty >>file3 &&
|
|
|
|
test_must_fail git rebase$type related-onto-branch &&
|
|
|
|
test_path_is_file $dotest/autostash &&
|
2018-08-22 18:13:20 +00:00
|
|
|
test_path_is_missing file3 &&
|
2013-05-12 11:56:41 +00:00
|
|
|
git rebase --skip &&
|
|
|
|
test_path_is_missing $dotest/autostash &&
|
|
|
|
grep dirty file3 &&
|
|
|
|
git checkout feature-branch
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "rebase$type: --abort" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b rebased-feature-branch feature-branch &&
|
|
|
|
test_when_finished git branch -D rebased-feature-branch &&
|
|
|
|
echo dirty >>file3 &&
|
|
|
|
test_must_fail git rebase$type related-onto-branch &&
|
|
|
|
test_path_is_file $dotest/autostash &&
|
2018-08-22 18:13:20 +00:00
|
|
|
test_path_is_missing file3 &&
|
2013-05-12 11:56:41 +00:00
|
|
|
git rebase --abort &&
|
|
|
|
test_path_is_missing $dotest/autostash &&
|
|
|
|
grep dirty file3 &&
|
|
|
|
git checkout feature-branch
|
|
|
|
'
|
|
|
|
|
2020-04-28 09:31:31 +00:00
|
|
|
test_expect_success "rebase$type: --quit" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b rebased-feature-branch feature-branch &&
|
|
|
|
test_when_finished git branch -D rebased-feature-branch &&
|
|
|
|
echo dirty >>file3 &&
|
|
|
|
git diff >expect &&
|
|
|
|
test_must_fail git rebase$type related-onto-branch &&
|
|
|
|
test_path_is_file $dotest/autostash &&
|
|
|
|
test_path_is_missing file3 &&
|
|
|
|
git rebase --quit &&
|
|
|
|
test_when_finished git stash drop &&
|
|
|
|
test_path_is_missing $dotest/autostash &&
|
|
|
|
! grep dirty file3 &&
|
|
|
|
git stash show -p >actual &&
|
|
|
|
test_cmp expect actual &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout feature-branch
|
|
|
|
'
|
|
|
|
|
2013-05-12 11:56:41 +00:00
|
|
|
test_expect_success "rebase$type: non-conflicting rebase, conflicting stash" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b rebased-feature-branch feature-branch &&
|
|
|
|
echo dirty >file4 &&
|
|
|
|
git add file4 &&
|
2017-06-19 17:56:05 +00:00
|
|
|
git rebase$type unrelated-onto-branch >actual 2>&1 &&
|
2013-05-12 11:56:41 +00:00
|
|
|
test_path_is_missing $dotest &&
|
|
|
|
git reset --hard &&
|
|
|
|
grep unrelated file4 &&
|
|
|
|
! grep dirty file4 &&
|
|
|
|
git checkout feature-branch &&
|
|
|
|
git stash pop &&
|
|
|
|
grep dirty file4
|
|
|
|
'
|
2017-06-19 17:56:05 +00:00
|
|
|
|
|
|
|
test_expect_success "rebase$type: check output with conflicting stash" '
|
|
|
|
test_when_finished git branch -D rebased-feature-branch &&
|
2020-02-15 21:36:41 +00:00
|
|
|
suffix=${type#\ --} && suffix=${suffix:-apply} &&
|
|
|
|
if test ${suffix} = "interactive"; then
|
|
|
|
suffix=merge
|
rebase: implement --merge via the interactive machinery
As part of an ongoing effort to make rebase have more uniform behavior,
modify the merge backend to behave like the interactive one, by
re-implementing it on top of the latter.
Interactive rebases are implemented in terms of cherry-pick rather than
the merge-recursive builtin, but cherry-pick also calls into the
recursive merge machinery by default and can accept special merge
strategies and/or special strategy options. As such, there really is
not any need for having both git-rebase--merge and
git-rebase--interactive anymore. Delete git-rebase--merge.sh and
instead implement it in builtin/rebase.c.
This results in a few deliberate but small user-visible changes:
* The progress output is modified (see t3406 and t3420 for examples)
* A few known test failures are now fixed (see t3421)
* bash-prompt during a rebase --merge is now REBASE-i instead of
REBASE-m. Reason: The prompt is a reflection of the backend in use;
this allows users to report an issue to the git mailing list with
the appropriate backend information, and allows advanced users to
know where to search for relevant control files. (see t9903)
testcase modification notes:
t3406: --interactive and --merge had slightly different progress output
while running; adjust a test to match the new expectation
t3420: these test precise output while running, but rebase--am,
rebase--merge, and rebase--interactive all were built on very
different commands (am, merge-recursive, cherry-pick), so the
tests expected different output for each type. Now we expect
--merge and --interactive to have the same output.
t3421: --interactive fixes some bugs in --merge! Wahoo!
t9903: --merge uses the interactive backend so the prompt expected is
now REBASE-i.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-12-11 16:11:39 +00:00
|
|
|
fi &&
|
2017-06-19 17:56:05 +00:00
|
|
|
create_expected_failure_$suffix &&
|
2019-07-04 09:47:02 +00:00
|
|
|
sed "$remove_progress_re" <actual >actual2 &&
|
2021-02-11 01:53:53 +00:00
|
|
|
test_cmp expected actual2
|
2017-06-19 17:56:05 +00:00
|
|
|
'
|
2013-05-12 11:56:41 +00:00
|
|
|
}
|
|
|
|
|
2013-06-13 16:06:12 +00:00
|
|
|
test_expect_success "rebase: fast-forward rebase" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b behind-feature-branch feature-branch~1 &&
|
|
|
|
test_when_finished git branch -D behind-feature-branch &&
|
|
|
|
echo dirty >>file1 &&
|
|
|
|
git rebase feature-branch &&
|
|
|
|
grep dirty file1 &&
|
|
|
|
git checkout feature-branch
|
|
|
|
'
|
|
|
|
|
2013-06-13 16:06:13 +00:00
|
|
|
test_expect_success "rebase: noop rebase" '
|
|
|
|
test_config rebase.autostash true &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b same-feature-branch feature-branch &&
|
|
|
|
test_when_finished git branch -D same-feature-branch &&
|
|
|
|
echo dirty >>file1 &&
|
|
|
|
git rebase feature-branch &&
|
|
|
|
grep dirty file1 &&
|
|
|
|
git checkout feature-branch
|
|
|
|
'
|
|
|
|
|
2020-02-15 21:36:41 +00:00
|
|
|
testrebase " --apply" .git/rebase-apply
|
2013-05-12 11:56:41 +00:00
|
|
|
testrebase " --merge" .git/rebase-merge
|
|
|
|
testrebase " --interactive" .git/rebase-merge
|
|
|
|
|
2014-05-20 07:49:31 +00:00
|
|
|
test_expect_success 'abort rebase -i with --autostash' '
|
|
|
|
test_when_finished "git reset --hard" &&
|
2016-08-09 08:53:38 +00:00
|
|
|
echo uncommitted-content >file0 &&
|
2014-05-20 07:49:31 +00:00
|
|
|
(
|
|
|
|
write_script abort-editor.sh <<-\EOF &&
|
|
|
|
echo >"$1"
|
|
|
|
EOF
|
|
|
|
test_set_editor "$(pwd)/abort-editor.sh" &&
|
|
|
|
test_must_fail git rebase -i --autostash HEAD^ &&
|
|
|
|
rm -f abort-editor.sh
|
|
|
|
) &&
|
2016-08-09 08:53:38 +00:00
|
|
|
echo uncommitted-content >expected &&
|
2014-05-20 07:49:31 +00:00
|
|
|
test_cmp expected file0
|
|
|
|
'
|
|
|
|
|
2016-06-29 06:21:27 +00:00
|
|
|
test_expect_success 'restore autostash on editor failure' '
|
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
echo uncommitted-content >file0 &&
|
|
|
|
(
|
|
|
|
test_set_editor "false" &&
|
|
|
|
test_must_fail git rebase -i --autostash HEAD^
|
|
|
|
) &&
|
|
|
|
echo uncommitted-content >expected &&
|
|
|
|
test_cmp expected file0
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'autostash is saved on editor failure with conflict' '
|
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
echo uncommitted-content >file0 &&
|
|
|
|
(
|
|
|
|
write_script abort-editor.sh <<-\EOF &&
|
|
|
|
echo conflicting-content >file0
|
|
|
|
exit 1
|
|
|
|
EOF
|
|
|
|
test_set_editor "$(pwd)/abort-editor.sh" &&
|
|
|
|
test_must_fail git rebase -i --autostash HEAD^ &&
|
|
|
|
rm -f abort-editor.sh
|
|
|
|
) &&
|
|
|
|
echo conflicting-content >expected &&
|
|
|
|
test_cmp expected file0 &&
|
|
|
|
git checkout file0 &&
|
|
|
|
git stash pop &&
|
|
|
|
echo uncommitted-content >expected &&
|
|
|
|
test_cmp expected file0
|
|
|
|
'
|
|
|
|
|
2018-10-23 19:57:17 +00:00
|
|
|
test_expect_success 'autostash with dirty submodules' '
|
2020-11-18 23:44:25 +00:00
|
|
|
test_when_finished "git reset --hard && git checkout main" &&
|
2018-10-23 19:57:16 +00:00
|
|
|
git checkout -b with-submodule &&
|
2022-07-29 19:20:28 +00:00
|
|
|
git -c protocol.file.allow=always submodule add ./ sub &&
|
2018-10-23 19:57:16 +00:00
|
|
|
test_tick &&
|
|
|
|
git commit -m add-submodule &&
|
|
|
|
echo changed >sub/file0 &&
|
|
|
|
git rebase -i --autostash HEAD
|
|
|
|
'
|
|
|
|
|
2018-11-07 14:00:50 +00:00
|
|
|
test_expect_success 'branch is left alone when possible' '
|
2018-11-07 14:00:48 +00:00
|
|
|
git checkout -b unchanged-branch &&
|
|
|
|
echo changed >file0 &&
|
|
|
|
git rebase --autostash unchanged-branch &&
|
|
|
|
test changed = "$(cat file0)" &&
|
|
|
|
test unchanged-branch = "$(git rev-parse --abbrev-ref HEAD)"
|
|
|
|
'
|
|
|
|
|
2019-08-30 15:16:05 +00:00
|
|
|
test_expect_success 'never change active branch' '
|
|
|
|
git checkout -b not-the-feature-branch unrelated-onto-branch &&
|
2020-11-18 23:44:25 +00:00
|
|
|
test_when_finished "git reset --hard && git checkout main" &&
|
2019-08-30 15:16:05 +00:00
|
|
|
echo changed >file0 &&
|
|
|
|
git rebase --autostash not-the-feature-branch feature-branch &&
|
|
|
|
test_cmp_rev not-the-feature-branch unrelated-onto-branch
|
|
|
|
'
|
|
|
|
|
2013-05-12 11:56:41 +00:00
|
|
|
test_done
|