Skip to content

Commit 7a9ae6d

Browse files
committed
Merge branch 'pb/pull-rebase-autostash-fix'
"git pull --rebase" ignored the rebase.autostash configuration variable when the remote history is a descendant of our history, which has been corrected. * pb/pull-rebase-autostash-fix: pull --rebase: honor rebase.autostash when fast-forwarding
2 parents 5d01301 + 3013d98 commit 7a9ae6d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

builtin/pull.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,14 +1038,13 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
10381038
oidclr(&orig_head);
10391039

10401040
if (opt_rebase) {
1041-
int autostash = config_autostash;
1042-
if (opt_autostash != -1)
1043-
autostash = opt_autostash;
1041+
if (opt_autostash == -1)
1042+
opt_autostash = config_autostash;
10441043

10451044
if (is_null_oid(&orig_head) && !is_cache_unborn())
10461045
die(_("Updating an unborn branch with changes added to the index."));
10471046

1048-
if (!autostash)
1047+
if (!opt_autostash)
10491048
require_clean_work_tree(the_repository,
10501049
N_("pull with rebase"),
10511050
_("please commit or stash them."), 1, 0);

t/t5520-pull.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ test_expect_success '--rebase --autostash fast forward' '
330330
test_cmp_rev HEAD to-rebase-ff
331331
'
332332

333+
test_expect_success '--rebase with rebase.autostash succeeds on ff' '
334+
test_when_finished "rm -fr src dst actual" &&
335+
git init src &&
336+
test_commit -C src "initial" file "content" &&
337+
git clone src dst &&
338+
test_commit -C src --printf "more_content" file "more content\ncontent\n" &&
339+
echo "dirty" >>dst/file &&
340+
test_config -C dst rebase.autostash true &&
341+
git -C dst pull --rebase >actual 2>&1 &&
342+
grep -q "Fast-forward" actual &&
343+
grep -q "Applied autostash." actual
344+
'
345+
333346
test_expect_success '--rebase with conflicts shows advice' '
334347
test_when_finished "git rebase --abort; git checkout -f to-rebase" &&
335348
git checkout -b seq &&

0 commit comments

Comments
 (0)