Skip to content

Commit

Permalink
Merge branch 'jk/rebase-no-autostash' into maint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Dec 8, 2015
2 parents 9a8c740 + 82e0668 commit 697bd28
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Documentation/git-rebase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ If the '--autosquash' option is enabled by default using the
configuration variable `rebase.autoSquash`, this option can be
used to override and disable this setting.

--[no-]autostash::
--autostash::
--no-autostash::
Automatically create a temporary stash before the operation
begins, and apply it after the operation ends. This means
that you can run rebase on a dirty worktree. However, use
Expand Down
5 changes: 4 additions & 1 deletion git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ git-rebase --continue | --abort | --skip | --edit-todo
Available options are
v,verbose! display a diffstat of what changed upstream
q,quiet! be quiet. implies --no-stat
autostash! automatically stash/stash pop before and after
autostash automatically stash/stash pop before and after
fork-point use 'merge-base --fork-point' to refine upstream
onto=! rebase onto given branch instead of upstream
p,preserve-merges! try to recreate merges instead of ignoring them
Expand Down Expand Up @@ -292,6 +292,9 @@ do
--autostash)
autostash=true
;;
--no-autostash)
autostash=false
;;
--verbose)
verbose=t
diffstat=t
Expand Down
10 changes: 10 additions & 0 deletions t/t3420-rebase-autostash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ testrebase() {
type=$1
dotest=$2

test_expect_success "rebase$type: dirty worktree, --no-autostash" '
test_config rebase.autostash true &&
git reset --hard &&
git checkout -b rebased-feature-branch feature-branch &&
test_when_finished git branch -D rebased-feature-branch &&
test_when_finished git checkout feature-branch &&
echo dirty >>file3 &&
test_must_fail git rebase$type --no-autostash unrelated-onto-branch
'

test_expect_success "rebase$type: dirty worktree, non-conflicting rebase" '
test_config rebase.autostash true &&
git reset --hard &&
Expand Down

0 comments on commit 697bd28

Please sign in to comment.