pull: allow dirty tree when rebase.autostash enabled
rebase learned to stash changes when it encounters a dirty work tree, but git pull --rebase does not. Only verify if the working tree is dirty when rebase.autostash is not enabled. Signed-off-by: Kevin Daudt <me@ikke.info> Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kevin Daudt committed
Jul 4, 2015 at 23:42 UTC
53c76dc05e0b5ad5b1f92db9577694e896d67a0a
2 files changed
+17
-1
builtin/pull.c
+5
-1
@@ -823,10 +823,14 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
823
hashclr(orig_head);
824
825
if (opt_rebase) {
826
+ int autostash = 0;
827
+
828
if (is_null_sha1(orig_head) && !is_cache_unborn())
829
die(_("Updating an unborn branch with changes added to the index."));
830
829
- die_on_unclean_work_tree(prefix);
831
+ git_config_get_bool("rebase.autostash", &autostash);
832
+ if (!autostash)
833
+ die_on_unclean_work_tree(prefix);
834
835
if (get_rebase_fork_point(rebase_fork_point, repo, *refspecs))
836
hashclr(rebase_fork_point);
t/t5520-pull.sh
+12
@@ -122,6 +122,18 @@ test_expect_success '--rebase' '
122
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
123
test new = $(git show HEAD:file2)
124
'
125
+
126
+test_expect_success 'pull --rebase succeeds with dirty working directory and rebase.autostash set' '
127
+ test_config rebase.autostash true &&
128
+ git reset --hard before-rebase &&
129
+ echo dirty >new_file &&
130
+ git add new_file &&
131
+ git pull --rebase . copy &&
132
+ test_cmp_rev HEAD^ copy &&
133
+ test "$(cat new_file)" = dirty &&
134
+ test "$(cat file)" = "modified again"
135
+'
136
+
137
test_expect_success 'pull.rebase' '
138
git reset --hard before-rebase &&
139
test_config pull.rebase true &&