Merge branch 'ev/pull-already-up-to-date-is-noop'
"git pull" with any strategy when the other side is behind us should succeed as it is a no-op, but doesn't. * ev/pull-already-up-to-date-is-noop: pull: should be noop when already-up-to-date
This commit is contained in:
commit
0f2140f105
@ -988,6 +988,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
|
|||||||
struct object_id rebase_fork_point;
|
struct object_id rebase_fork_point;
|
||||||
int rebase_unspecified = 0;
|
int rebase_unspecified = 0;
|
||||||
int can_ff;
|
int can_ff;
|
||||||
|
int divergent;
|
||||||
|
|
||||||
if (!getenv("GIT_REFLOG_ACTION"))
|
if (!getenv("GIT_REFLOG_ACTION"))
|
||||||
set_reflog_message(argc, argv);
|
set_reflog_message(argc, argv);
|
||||||
@ -1102,15 +1103,16 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
can_ff = get_can_ff(&orig_head, &merge_heads);
|
can_ff = get_can_ff(&orig_head, &merge_heads);
|
||||||
|
divergent = !can_ff && !already_up_to_date(&orig_head, &merge_heads);
|
||||||
|
|
||||||
/* ff-only takes precedence over rebase */
|
/* ff-only takes precedence over rebase */
|
||||||
if (opt_ff && !strcmp(opt_ff, "--ff-only")) {
|
if (opt_ff && !strcmp(opt_ff, "--ff-only")) {
|
||||||
if (!can_ff && !already_up_to_date(&orig_head, &merge_heads))
|
if (divergent)
|
||||||
die_ff_impossible();
|
die_ff_impossible();
|
||||||
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 && divergent) {
|
||||||
show_advice_pull_non_ff();
|
show_advice_pull_non_ff();
|
||||||
die(_("Need to specify how to reconcile divergent branches."));
|
die(_("Need to specify how to reconcile divergent branches."));
|
||||||
}
|
}
|
||||||
|
@ -387,6 +387,12 @@ test_expect_success 'pull prevents non-fast-forward with "only" in pull.ff' '
|
|||||||
test_must_fail git pull . c3
|
test_must_fail git pull . c3
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'already-up-to-date pull succeeds with unspecified pull.ff' '
|
||||||
|
git reset --hard c1 &&
|
||||||
|
git pull . c0 &&
|
||||||
|
test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'already-up-to-date pull succeeds with "only" in pull.ff' '
|
test_expect_success 'already-up-to-date pull succeeds with "only" in pull.ff' '
|
||||||
git reset --hard c1 &&
|
git reset --hard c1 &&
|
||||||
test_config pull.ff only &&
|
test_config pull.ff only &&
|
||||||
|
Loading…
Reference in New Issue
Block a user