@matheusbsbs / matheus-bagliano / commits / 9b2df3e8d0
Fork 0

rebase: save autostash entry into stash reflog on --quit

In a03b55530a (merge: teach --autostash option, 2020-04-07), the --autostash option was introduced for `git merge`. Notably, when `git merge --quit` is run with an autostash entry present, it is saved into the stash reflog. This is contrasted with the current behaviour of `git rebase --quit` where the autostash entry is simply just dropped out of existence. Adopt the behaviour of `git merge --quit` in `git rebase --quit` and save the autostash entry into the stash reflog instead of just deleting it. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Apr 28, 2020 at 05:31 UTC 9b2df3e8d093145f1628af82b94f6dcfc85b9646
3 files changed +23 -1
Documentation/git-rebase.txt
+2 -1
@@ -256,7 +256,8 @@ See also INCOMPATIBLE OPTIONS below.
256 --quit::
257 Abort the rebase operation but HEAD is not reset back to the
258 original branch. The index and working tree are also left
259 - unchanged as a result.
259 + unchanged as a result. If a temporary stash entry was created
260 + using --autostash, it will be saved to the stash reflog.
261
262 --apply:
263 Use applying strategies to rebase (calling `git-am`
builtin/rebase.c
+1
@@ -1556,6 +1556,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1556 goto cleanup;
1557 }
1558 case ACTION_QUIT: {
1559 + save_autostash(state_dir_path("autostash", &options));
1560 if (options.type == REBASE_MERGE) {
1561 struct replay_opts replay = REPLAY_OPTS_INIT;
1562
t/t3420-rebase-autostash.sh
+20
@@ -184,6 +184,26 @@ testrebase () {
184 git checkout feature-branch
185 '
186
187 + test_expect_success "rebase$type: --quit" '
188 + test_config rebase.autostash true &&
189 + git reset --hard &&
190 + git checkout -b rebased-feature-branch feature-branch &&
191 + test_when_finished git branch -D rebased-feature-branch &&
192 + echo dirty >>file3 &&
193 + git diff >expect &&
194 + test_must_fail git rebase$type related-onto-branch &&
195 + test_path_is_file $dotest/autostash &&
196 + test_path_is_missing file3 &&
197 + git rebase --quit &&
198 + test_when_finished git stash drop &&
199 + test_path_is_missing $dotest/autostash &&
200 + ! grep dirty file3 &&
201 + git stash show -p >actual &&
202 + test_cmp expect actual &&
203 + git reset --hard &&
204 + git checkout feature-branch
205 + '
206 +
207 test_expect_success "rebase$type: non-conflicting rebase, conflicting stash" '
208 test_config rebase.autostash true &&
209 git reset --hard &&