pull: abort by default when fast-forwarding is not possible

We have for some time shown a long warning when the user does not
specify how to reconcile divergent branches with git pull.  Make it an
error now.

Initial-patch-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren 2021-07-22 05:04:48 +00:00 коммит произвёл Junio C Hamano
Родитель adc27d6a93
Коммит 031e2f7ae1
13 изменённых файлов: 83 добавлений и 77 удалений

Просмотреть файл

@ -15,14 +15,18 @@ SYNOPSIS
DESCRIPTION DESCRIPTION
----------- -----------
Incorporates changes from a remote repository into the current Incorporates changes from a remote repository into the current branch.
branch. In its default mode, `git pull` is shorthand for If the current branch is behind the remote, then by default it will
`git fetch` followed by `git merge FETCH_HEAD`. fast-forward the current branch to match the remote. If the current
branch and the remote have diverged, the user needs to specify how to
reconcile the divergent branches with `--no-ff`, `--ff`, or `--rebase`
(or the corresponding configuration options in `pull.ff` or
`pull.rebase`).
More precisely, 'git pull' runs 'git fetch' with the given More precisely, `git pull` runs `git fetch` with the given parameters
parameters and calls 'git merge' to merge the retrieved branch and then depending on configuration options or command line flags,
heads into the current branch. will call either `git merge` or `git rebase` to reconcile diverging
With `--rebase`, it runs 'git rebase' instead of 'git merge'. branches.
<repository> should be the name of a remote repository as <repository> should be the name of a remote repository as
passed to linkgit:git-fetch[1]. <refspec> can name an passed to linkgit:git-fetch[1]. <refspec> can name an

Просмотреть файл

@ -927,9 +927,9 @@ static int get_can_ff(struct object_id *orig_head, struct object_id *orig_merge_
static void show_advice_pull_non_ff(void) static void show_advice_pull_non_ff(void)
{ {
advise(_("Pulling without specifying how to reconcile divergent branches is\n" advise(_("You have divergent branches and need to specify how to reconcile them.\n"
"discouraged. You can squelch this message by running one of the following\n" "You can do so by running one of the following commands sometime before\n"
"commands sometime before your next pull:\n" "your next pull:\n"
"\n" "\n"
" git config pull.rebase false # merge (the default strategy)\n" " git config pull.rebase false # merge (the default strategy)\n"
" git config pull.rebase true # rebase\n" " git config pull.rebase true # rebase\n"
@ -1067,8 +1067,10 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
opt_rebase = REBASE_FALSE; opt_rebase = REBASE_FALSE;
} }
/* If no action specified and we can't fast forward, then warn. */ /* If no action specified and we can't fast forward, then warn. */
if (!opt_ff && rebase_unspecified && !can_ff) if (!opt_ff && rebase_unspecified && !can_ff) {
show_advice_pull_non_ff(); show_advice_pull_non_ff();
die(_("Need to specify how to reconcile divergent branches."));
}
if (opt_rebase) { if (opt_rebase) {
int ret = 0; int ret = 0;

Просмотреть файл

@ -65,7 +65,7 @@ test_expect_success setup '
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
git checkout master && git checkout master &&
git pull -s ours . side && git pull -s ours --no-rebase . side &&
GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" && GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" &&
GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" && GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" &&

Просмотреть файл

@ -136,12 +136,12 @@ test_expect_success 'the default remote . should not break explicit pull' '
git reset --hard HEAD^ && git reset --hard HEAD^ &&
echo file >expect && echo file >expect &&
test_cmp expect file && test_cmp expect file &&
git pull . second && git pull --no-rebase . second &&
echo modified >expect && echo modified >expect &&
test_cmp expect file && test_cmp expect file &&
git reflog -1 >reflog.actual && git reflog -1 >reflog.actual &&
sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy && sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
echo "OBJID HEAD@{0}: pull . second: Fast-forward" >reflog.expected && echo "OBJID HEAD@{0}: pull --no-rebase . second: Fast-forward" >reflog.expected &&
test_cmp reflog.expected reflog.fuzzy test_cmp reflog.expected reflog.fuzzy
' '
@ -226,7 +226,7 @@ test_expect_success 'fail if the index has unresolved entries' '
test_commit modified2 file && test_commit modified2 file &&
git ls-files -u >unmerged && git ls-files -u >unmerged &&
test_must_be_empty unmerged && test_must_be_empty unmerged &&
test_must_fail git pull . second && test_must_fail git pull --no-rebase . second &&
git ls-files -u >unmerged && git ls-files -u >unmerged &&
test_file_not_empty unmerged && test_file_not_empty unmerged &&
cp file expected && cp file expected &&
@ -409,37 +409,37 @@ test_expect_success 'pull --rebase --no-autostash & rebase.autostash unset' '
test_expect_success 'pull succeeds with dirty working directory and merge.autostash set' ' test_expect_success 'pull succeeds with dirty working directory and merge.autostash set' '
test_config merge.autostash true && test_config merge.autostash true &&
test_pull_autostash 2 test_pull_autostash 2 --no-rebase
' '
test_expect_success 'pull --autostash & merge.autostash=true' ' test_expect_success 'pull --autostash & merge.autostash=true' '
test_config merge.autostash true && test_config merge.autostash true &&
test_pull_autostash 2 --autostash test_pull_autostash 2 --autostash --no-rebase
' '
test_expect_success 'pull --autostash & merge.autostash=false' ' test_expect_success 'pull --autostash & merge.autostash=false' '
test_config merge.autostash false && test_config merge.autostash false &&
test_pull_autostash 2 --autostash test_pull_autostash 2 --autostash --no-rebase
' '
test_expect_success 'pull --autostash & merge.autostash unset' ' test_expect_success 'pull --autostash & merge.autostash unset' '
test_unconfig merge.autostash && test_unconfig merge.autostash &&
test_pull_autostash 2 --autostash test_pull_autostash 2 --autostash --no-rebase
' '
test_expect_success 'pull --no-autostash & merge.autostash=true' ' test_expect_success 'pull --no-autostash & merge.autostash=true' '
test_config merge.autostash true && test_config merge.autostash true &&
test_pull_autostash_fail --no-autostash test_pull_autostash_fail --no-autostash --no-rebase
' '
test_expect_success 'pull --no-autostash & merge.autostash=false' ' test_expect_success 'pull --no-autostash & merge.autostash=false' '
test_config merge.autostash false && test_config merge.autostash false &&
test_pull_autostash_fail --no-autostash test_pull_autostash_fail --no-autostash --no-rebase
' '
test_expect_success 'pull --no-autostash & merge.autostash unset' ' test_expect_success 'pull --no-autostash & merge.autostash unset' '
test_unconfig merge.autostash && test_unconfig merge.autostash &&
test_pull_autostash_fail --no-autostash test_pull_autostash_fail --no-autostash --no-rebase
' '
test_expect_success 'pull.rebase' ' test_expect_success 'pull.rebase' '

Просмотреть файл

@ -113,7 +113,7 @@ test_expect_success 'git pull --force' '
git pull two && git pull two &&
test_commit A && test_commit A &&
git branch -f origin && git branch -f origin &&
git pull --all --force git pull --no-rebase --all --force
) )
' '
@ -179,7 +179,7 @@ test_expect_success 'git pull --allow-unrelated-histories' '
( (
cd dst && cd dst &&
test_must_fail git pull ../src side && test_must_fail git pull ../src side &&
git pull --allow-unrelated-histories ../src side git pull --no-rebase --allow-unrelated-histories ../src side
) )
' '

Просмотреть файл

@ -28,7 +28,7 @@ test_expect_success setup '
test_expect_success pull ' test_expect_success pull '
( (
cd cloned && cd cloned &&
git pull --log && git pull --no-rebase --log &&
git log -2 && git log -2 &&
git cat-file commit HEAD >result && git cat-file commit HEAD >result &&
grep Dollar result grep Dollar result
@ -41,7 +41,7 @@ test_expect_success '--log=1 limits shortlog length' '
git reset --hard HEAD^ && git reset --hard HEAD^ &&
test "$(cat afile)" = original && test "$(cat afile)" = original &&
test "$(cat bfile)" = added && test "$(cat bfile)" = added &&
git pull --log=1 && git pull --no-rebase --log=1 &&
git log -3 && git log -3 &&
git cat-file commit HEAD >result && git cat-file commit HEAD >result &&
grep Dollar result && grep Dollar result &&

Просмотреть файл

@ -108,27 +108,27 @@ test_expect_success 'setup commit on main and other pull' '
test_expect_success 'pull --set-upstream upstream main sets branch main but not other' ' test_expect_success 'pull --set-upstream upstream main sets branch main but not other' '
clear_config main other && clear_config main other &&
git pull --set-upstream upstream main && git pull --no-rebase --set-upstream upstream main &&
check_config main upstream refs/heads/main && check_config main upstream refs/heads/main &&
check_config_missing other check_config_missing other
' '
test_expect_success 'pull --set-upstream main:other2 does not set the branch other2' ' test_expect_success 'pull --set-upstream main:other2 does not set the branch other2' '
clear_config other2 && clear_config other2 &&
git pull --set-upstream upstream main:other2 && git pull --no-rebase --set-upstream upstream main:other2 &&
check_config_missing other2 check_config_missing other2
' '
test_expect_success 'pull --set-upstream upstream other sets branch main' ' test_expect_success 'pull --set-upstream upstream other sets branch main' '
clear_config main other && clear_config main other &&
git pull --set-upstream upstream other && git pull --no-rebase --set-upstream upstream other &&
check_config main upstream refs/heads/other && check_config main upstream refs/heads/other &&
check_config_missing other check_config_missing other
' '
test_expect_success 'pull --set-upstream upstream tag does not set the tag' ' test_expect_success 'pull --set-upstream upstream tag does not set the tag' '
clear_config three && clear_config three &&
git pull --tags --set-upstream upstream three && git pull --no-rebase --tags --set-upstream upstream three &&
check_config_missing three check_config_missing three
' '
@ -144,16 +144,16 @@ test_expect_success 'pull --set-upstream http://nosuchdomain.example.com fails w
test_expect_success 'pull --set-upstream upstream HEAD sets branch HEAD' ' test_expect_success 'pull --set-upstream upstream HEAD sets branch HEAD' '
clear_config main other && clear_config main other &&
git pull --set-upstream upstream HEAD && git pull --no-rebase --set-upstream upstream HEAD &&
check_config main upstream HEAD && check_config main upstream HEAD &&
git checkout other && git checkout other &&
git pull --set-upstream upstream HEAD && git pull --no-rebase --set-upstream upstream HEAD &&
check_config other upstream HEAD check_config other upstream HEAD
' '
test_expect_success 'pull --set-upstream upstream with more than one branch does nothing' ' test_expect_success 'pull --set-upstream upstream with more than one branch does nothing' '
clear_config main three && clear_config main three &&
git pull --set-upstream upstream main three && git pull --no-rebase --set-upstream upstream main three &&
check_config_missing main && check_config_missing main &&
check_config_missing three check_config_missing three
' '

Просмотреть файл

@ -87,7 +87,7 @@ test_expect_success 'updating origin' '
' '
test_expect_success 'pulling changes from origin' ' test_expect_success 'pulling changes from origin' '
git -C C pull origin git -C C pull --no-rebase origin
' '
# the 2 local objects are commit and tree from the merge # the 2 local objects are commit and tree from the merge
@ -96,7 +96,7 @@ test_expect_success 'that alternate to origin gets used' '
' '
test_expect_success 'pulling changes from origin' ' test_expect_success 'pulling changes from origin' '
git -C D pull origin git -C D pull --no-rebase origin
' '
# the 5 local objects are expected; file3 blob, commit in A to add it # the 5 local objects are expected; file3 blob, commit in A to add it

Просмотреть файл

@ -103,7 +103,7 @@ test_expect_success 'setup' '
test_expect_success 'pull renaming branch into unrenaming one' \ test_expect_success 'pull renaming branch into unrenaming one' \
' '
git show-branch && git show-branch &&
test_expect_code 1 git pull . white && test_expect_code 1 git pull --no-rebase . white &&
git ls-files -s && git ls-files -s &&
git ls-files -u B >b.stages && git ls-files -u B >b.stages &&
test_line_count = 3 b.stages && test_line_count = 3 b.stages &&
@ -121,7 +121,7 @@ test_expect_success 'pull renaming branch into another renaming one' \
rm -f B && rm -f B &&
git reset --hard && git reset --hard &&
git checkout red && git checkout red &&
test_expect_code 1 git pull . white && test_expect_code 1 git pull --no-rebase . white &&
git ls-files -u B >b.stages && git ls-files -u B >b.stages &&
test_line_count = 3 b.stages && test_line_count = 3 b.stages &&
git ls-files -s N >n.stages && git ls-files -s N >n.stages &&
@ -137,7 +137,7 @@ test_expect_success 'pull unrenaming branch into renaming one' \
' '
git reset --hard && git reset --hard &&
git show-branch && git show-branch &&
test_expect_code 1 git pull . main && test_expect_code 1 git pull --no-rebase . main &&
git ls-files -u B >b.stages && git ls-files -u B >b.stages &&
test_line_count = 3 b.stages && test_line_count = 3 b.stages &&
git ls-files -s N >n.stages && git ls-files -s N >n.stages &&
@ -153,7 +153,7 @@ test_expect_success 'pull conflicting renames' \
' '
git reset --hard && git reset --hard &&
git show-branch && git show-branch &&
test_expect_code 1 git pull . blue && test_expect_code 1 git pull --no-rebase . blue &&
git ls-files -u A >a.stages && git ls-files -u A >a.stages &&
test_line_count = 1 a.stages && test_line_count = 1 a.stages &&
git ls-files -u B >b.stages && git ls-files -u B >b.stages &&
@ -173,7 +173,7 @@ test_expect_success 'interference with untracked working tree file' '
git reset --hard && git reset --hard &&
git show-branch && git show-branch &&
echo >A this file should not matter && echo >A this file should not matter &&
test_expect_code 1 git pull . white && test_expect_code 1 git pull --no-rebase . white &&
test_path_is_file A test_path_is_file A
' '
@ -183,7 +183,7 @@ test_expect_success 'interference with untracked working tree file' '
git show-branch && git show-branch &&
rm -f A && rm -f A &&
echo >A this file should not matter && echo >A this file should not matter &&
test_expect_code 1 git pull . red && test_expect_code 1 git pull --no-rebase . red &&
test_path_is_file A test_path_is_file A
' '
@ -193,7 +193,7 @@ test_expect_success 'interference with untracked working tree file' '
git checkout -f main && git checkout -f main &&
git tag -f anchor && git tag -f anchor &&
git show-branch && git show-branch &&
git pull . yellow && git pull --no-rebase . yellow &&
test_path_is_missing M && test_path_is_missing M &&
git reset --hard anchor git reset --hard anchor
' '
@ -220,7 +220,7 @@ test_expect_success 'updated working tree file should prevent the merge' '
echo >>M one line addition && echo >>M one line addition &&
cat M >M.saved && cat M >M.saved &&
git update-index M && git update-index M &&
test_expect_code 128 git pull . yellow && test_expect_code 128 git pull --no-rebase . yellow &&
test_cmp M M.saved && test_cmp M M.saved &&
rm -f M.saved rm -f M.saved
' '
@ -232,7 +232,7 @@ test_expect_success 'interference with untracked working tree file' '
git tag -f anchor && git tag -f anchor &&
git show-branch && git show-branch &&
echo >M this file should not matter && echo >M this file should not matter &&
git pull . main && git pull --no-rebase . main &&
test_path_is_file M && test_path_is_file M &&
! { ! {
git ls-files -s | git ls-files -s |

Просмотреть файл

@ -100,7 +100,7 @@ test_expect_success 'merge update' '
git checkout -b topic_2 && git checkout -b topic_2 &&
git commit -m "update git-gui" && git commit -m "update git-gui" &&
cd ../git && cd ../git &&
git pull -s subtree gui topic_2 && git pull --no-rebase -s subtree gui topic_2 &&
git ls-files -s >actual && git ls-files -s >actual &&
( (
echo "100644 $o3 0 git-gui/git-gui.sh" && echo "100644 $o3 0 git-gui/git-gui.sh" &&
@ -129,7 +129,7 @@ test_expect_success 'initial ambiguous subtree' '
test_expect_success 'merge using explicit' ' test_expect_success 'merge using explicit' '
cd ../git && cd ../git &&
git reset --hard topic_2 && git reset --hard topic_2 &&
git pull -Xsubtree=git-gui gui topic_2 && git pull --no-rebase -Xsubtree=git-gui gui topic_2 &&
git ls-files -s >actual && git ls-files -s >actual &&
( (
echo "100644 $o3 0 git-gui/git-gui.sh" && echo "100644 $o3 0 git-gui/git-gui.sh" &&
@ -142,7 +142,7 @@ test_expect_success 'merge using explicit' '
test_expect_success 'merge2 using explicit' ' test_expect_success 'merge2 using explicit' '
cd ../git && cd ../git &&
git reset --hard topic_2 && git reset --hard topic_2 &&
git pull -Xsubtree=git-gui2 gui topic_2 && git pull --no-rebase -Xsubtree=git-gui2 gui topic_2 &&
git ls-files -s >actual && git ls-files -s >actual &&
( (
echo "100644 $o1 0 git-gui/git-gui.sh" && echo "100644 $o1 0 git-gui/git-gui.sh" &&

Просмотреть файл

@ -69,11 +69,11 @@ test_expect_success 'binary file with -Xours/-Xtheirs' '
' '
test_expect_success 'pull passes -X to underlying merge' ' test_expect_success 'pull passes -X to underlying merge' '
git reset --hard main && git pull -s recursive -Xours . side && git reset --hard main && git pull --no-rebase -s recursive -Xours . side &&
git reset --hard main && git pull -s recursive -X ours . side && git reset --hard main && git pull --no-rebase -s recursive -X ours . side &&
git reset --hard main && git pull -s recursive -Xtheirs . side && git reset --hard main && git pull --no-rebase -s recursive -Xtheirs . side &&
git reset --hard main && git pull -s recursive -X theirs . side && git reset --hard main && git pull --no-rebase -s recursive -X theirs . side &&
git reset --hard main && test_must_fail git pull -s recursive -X bork . side git reset --hard main && test_must_fail git pull --no-rebase -s recursive -X bork . side
' '
test_expect_success SYMLINKS 'symlink with -Xours/-Xtheirs' ' test_expect_success SYMLINKS 'symlink with -Xours/-Xtheirs' '

Просмотреть файл

@ -27,120 +27,120 @@ test_expect_success 'setup' '
git tag c3 git tag c3
' '
test_expect_success 'pull.rebase not set' ' test_expect_success 'pull.rebase not set, ff possible' '
git reset --hard c0 && git reset --hard c0 &&
git pull . c1 2>err && git pull . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and pull.ff=true' ' test_expect_success 'pull.rebase not set and pull.ff=true' '
git reset --hard c0 && git reset --hard c0 &&
test_config pull.ff true && test_config pull.ff true &&
git pull . c1 2>err && git pull . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and pull.ff=false' ' test_expect_success 'pull.rebase not set and pull.ff=false' '
git reset --hard c0 && git reset --hard c0 &&
test_config pull.ff false && test_config pull.ff false &&
git pull . c1 2>err && git pull . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and pull.ff=only' ' test_expect_success 'pull.rebase not set and pull.ff=only' '
git reset --hard c0 && git reset --hard c0 &&
test_config pull.ff only && test_config pull.ff only &&
git pull . c1 2>err && git pull . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and --rebase given' ' test_expect_success 'pull.rebase not set and --rebase given' '
git reset --hard c0 && git reset --hard c0 &&
git pull --rebase . c1 2>err && git pull --rebase . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and --no-rebase given' ' test_expect_success 'pull.rebase not set and --no-rebase given' '
git reset --hard c0 && git reset --hard c0 &&
git pull --no-rebase . c1 2>err && git pull --no-rebase . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and --ff given' ' test_expect_success 'pull.rebase not set and --ff given' '
git reset --hard c0 && git reset --hard c0 &&
git pull --ff . c1 2>err && git pull --ff . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and --no-ff given' ' test_expect_success 'pull.rebase not set and --no-ff given' '
git reset --hard c0 && git reset --hard c0 &&
git pull --no-ff . c1 2>err && git pull --no-ff . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and --ff-only given' ' test_expect_success 'pull.rebase not set and --ff-only given' '
git reset --hard c0 && git reset --hard c0 &&
git pull --ff-only . c1 2>err && git pull --ff-only . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set (not-fast-forward)' ' test_expect_success 'pull.rebase not set (not-fast-forward)' '
git reset --hard c2 && git reset --hard c2 &&
git -c color.advice=always pull . c1 2>err && test_must_fail git -c color.advice=always pull . c1 2>err &&
test_decode_color <err >decoded && test_decode_color <err >decoded &&
test_i18ngrep "<YELLOW>hint: " decoded && test_i18ngrep "<YELLOW>hint: " decoded &&
test_i18ngrep "Pulling without specifying how to reconcile" decoded test_i18ngrep "You have divergent branches" decoded
' '
test_expect_success 'pull.rebase not set and pull.ff=true (not-fast-forward)' ' test_expect_success 'pull.rebase not set and pull.ff=true (not-fast-forward)' '
git reset --hard c2 && git reset --hard c2 &&
test_config pull.ff true && test_config pull.ff true &&
git pull . c1 2>err && git pull . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and pull.ff=false (not-fast-forward)' ' test_expect_success 'pull.rebase not set and pull.ff=false (not-fast-forward)' '
git reset --hard c2 && git reset --hard c2 &&
test_config pull.ff false && test_config pull.ff false &&
git pull . c1 2>err && git pull . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and pull.ff=only (not-fast-forward)' ' test_expect_success 'pull.rebase not set and pull.ff=only (not-fast-forward)' '
git reset --hard c2 && git reset --hard c2 &&
test_config pull.ff only && test_config pull.ff only &&
test_must_fail git pull . c1 2>err && test_must_fail git pull . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and --rebase given (not-fast-forward)' ' test_expect_success 'pull.rebase not set and --rebase given (not-fast-forward)' '
git reset --hard c2 && git reset --hard c2 &&
git pull --rebase . c1 2>err && git pull --rebase . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and --no-rebase given (not-fast-forward)' ' test_expect_success 'pull.rebase not set and --no-rebase given (not-fast-forward)' '
git reset --hard c2 && git reset --hard c2 &&
git pull --no-rebase . c1 2>err && git pull --no-rebase . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and --ff given (not-fast-forward)' ' test_expect_success 'pull.rebase not set and --ff given (not-fast-forward)' '
git reset --hard c2 && git reset --hard c2 &&
git pull --ff . c1 2>err && git pull --ff . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and --no-ff given (not-fast-forward)' ' test_expect_success 'pull.rebase not set and --no-ff given (not-fast-forward)' '
git reset --hard c2 && git reset --hard c2 &&
git pull --no-ff . c1 2>err && git pull --no-ff . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_expect_success 'pull.rebase not set and --ff-only given (not-fast-forward)' ' test_expect_success 'pull.rebase not set and --ff-only given (not-fast-forward)' '
git reset --hard c2 && git reset --hard c2 &&
test_must_fail git pull --ff-only . c1 2>err && test_must_fail git pull --ff-only . c1 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err test_i18ngrep ! "You have divergent branches" err
' '
test_does_rebase () { test_does_rebase () {
@ -325,16 +325,16 @@ test_expect_success 'pull.rebase=false and --ff, ff not possible' '
# End of groupings for conflicting merge vs. rebase flags/options # End of groupings for conflicting merge vs. rebase flags/options
test_expect_failure 'Multiple heads warns about inability to fast forward' ' test_expect_success 'Multiple heads warns about inability to fast forward' '
git reset --hard c1 && git reset --hard c1 &&
test_must_fail git pull . c2 c3 2>err && test_must_fail git pull . c2 c3 2>err &&
test_i18ngrep "Pulling without specifying how to reconcile" err test_i18ngrep "You have divergent branches" err
' '
test_expect_failure 'Multiple can never be fast forwarded' ' test_expect_failure 'Multiple can never be fast forwarded' '
git reset --hard c0 && git reset --hard c0 &&
test_must_fail git -c pull.ff=only pull . c1 c2 c3 2>err && test_must_fail git -c pull.ff=only pull . c1 c2 c3 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err && test_i18ngrep ! "You have divergent branches" err &&
# In addition to calling out "cannot fast-forward", we very much # In addition to calling out "cannot fast-forward", we very much
# want the "multiple branches" piece to be called out to users. # want the "multiple branches" piece to be called out to users.
test_i18ngrep "Cannot fast-forward to multiple branches" err test_i18ngrep "Cannot fast-forward to multiple branches" err
@ -343,7 +343,7 @@ test_expect_failure 'Multiple can never be fast forwarded' '
test_expect_success 'Cannot rebase with multiple heads' ' test_expect_success 'Cannot rebase with multiple heads' '
git reset --hard c0 && git reset --hard c0 &&
test_must_fail git -c pull.rebase=true pull . c1 c2 c3 2>err && test_must_fail git -c pull.rebase=true pull . c1 c2 c3 2>err &&
test_i18ngrep ! "Pulling without specifying how to reconcile" err && test_i18ngrep ! "You have divergent branches" err &&
test_i18ngrep "Cannot rebase onto multiple branches." err test_i18ngrep "Cannot rebase onto multiple branches." err
' '

Просмотреть файл

@ -68,7 +68,7 @@ test_expect_success 'merge c1 with c2, c3, c4, c5' '
test_expect_success 'pull c2, c3, c4, c5 into c1' ' test_expect_success 'pull c2, c3, c4, c5 into c1' '
git reset --hard c1 && git reset --hard c1 &&
git pull . c2 c3 c4 c5 && git pull --no-rebase . c2 c3 c4 c5 &&
test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" && test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" && test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" && test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&