Skip to content

Commit 3afdeef

Browse files
committed
Merge branch 'dl/merge-autostash-rebase-quit-fix'
The stash entry created by "git rebase --autosquash" to keep the initial dirty state were discarded by mistake upon "git rebase --quit", which has been corrected. * dl/merge-autostash-rebase-quit-fix: rebase: save autostash entry into stash reflog on --quit
2 parents bf10200 + 9b2df3e commit 3afdeef

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

Documentation/git-rebase.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ See also INCOMPATIBLE OPTIONS below.
256256
--quit::
257257
Abort the rebase operation but HEAD is not reset back to the
258258
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.
260261

261262
--apply:
262263
Use applying strategies to rebase (calling `git-am`

builtin/rebase.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
15661566
goto cleanup;
15671567
}
15681568
case ACTION_QUIT: {
1569+
save_autostash(state_dir_path("autostash", &options));
15691570
if (options.type == REBASE_MERGE) {
15701571
struct replay_opts replay = REPLAY_OPTS_INIT;
15711572

t/t3420-rebase-autostash.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,26 @@ testrebase () {
184184
git checkout feature-branch
185185
'
186186

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+
187207
test_expect_success "rebase$type: non-conflicting rebase, conflicting stash" '
188208
test_config rebase.autostash true &&
189209
git reset --hard &&

0 commit comments

Comments
 (0)