Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull: should be noop when already-up-to-date #1078

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions builtin/pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
struct object_id rebase_fork_point;
int rebase_unspecified = 0;
int can_ff;
int divergent;

if (!getenv("GIT_REFLOG_ACTION"))
set_reflog_message(argc, argv);
Expand Down Expand Up @@ -1102,15 +1103,16 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
}

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 */
if (opt_ff && !strcmp(opt_ff, "--ff-only")) {
if (!can_ff && !already_up_to_date(&orig_head, &merge_heads))
if (divergent)
die_ff_impossible();
opt_rebase = REBASE_FALSE;
}
/* 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();
die(_("Need to specify how to reconcile divergent branches."));
}
Expand Down
6 changes: 6 additions & 0 deletions t/t7601-merge-pull-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@ test_expect_success 'pull prevents non-fast-forward with "only" in pull.ff' '
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' '
git reset --hard c1 &&
test_config pull.ff only &&
Expand Down