Skip to content

Commit 697bd28

Browse files
committed
Merge branch 'jk/rebase-no-autostash' into maint
There was no way to defeat a configured rebase.autostash variable from the command line, as "git rebase --no-autostash" was missing. * jk/rebase-no-autostash: Documentation/git-rebase: fix --no-autostash formatting rebase: support --no-autostash
2 parents 9a8c740 + 82e0668 commit 697bd28

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Documentation/git-rebase.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ If the '--autosquash' option is enabled by default using the
434434
configuration variable `rebase.autoSquash`, this option can be
435435
used to override and disable this setting.
436436

437-
--[no-]autostash::
437+
--autostash::
438+
--no-autostash::
438439
Automatically create a temporary stash before the operation
439440
begins, and apply it after the operation ends. This means
440441
that you can run rebase on a dirty worktree. However, use

git-rebase.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ git-rebase --continue | --abort | --skip | --edit-todo
1414
Available options are
1515
v,verbose! display a diffstat of what changed upstream
1616
q,quiet! be quiet. implies --no-stat
17-
autostash! automatically stash/stash pop before and after
17+
autostash automatically stash/stash pop before and after
1818
fork-point use 'merge-base --fork-point' to refine upstream
1919
onto=! rebase onto given branch instead of upstream
2020
p,preserve-merges! try to recreate merges instead of ignoring them
@@ -292,6 +292,9 @@ do
292292
--autostash)
293293
autostash=true
294294
;;
295+
--no-autostash)
296+
autostash=false
297+
;;
295298
--verbose)
296299
verbose=t
297300
diffstat=t

t/t3420-rebase-autostash.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ testrebase() {
3737
type=$1
3838
dotest=$2
3939

40+
test_expect_success "rebase$type: dirty worktree, --no-autostash" '
41+
test_config rebase.autostash true &&
42+
git reset --hard &&
43+
git checkout -b rebased-feature-branch feature-branch &&
44+
test_when_finished git branch -D rebased-feature-branch &&
45+
test_when_finished git checkout feature-branch &&
46+
echo dirty >>file3 &&
47+
test_must_fail git rebase$type --no-autostash unrelated-onto-branch
48+
'
49+
4050
test_expect_success "rebase$type: dirty worktree, non-conflicting rebase" '
4151
test_config rebase.autostash true &&
4252
git reset --hard &&

0 commit comments

Comments
 (0)