diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-11-01 13:46:20 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-11-01 13:46:27 -0700 |
commit | 0f49327c9755b6575b447f79b540749d231cb26d (patch) | |
tree | aa288af4723d7d99af2b5dc47736ac6a0ce49ce0 | |
parent | 6c9ad166dbbf9e5a0c09450b892151dbec49b8dc (diff) | |
download | git-0f49327c9755b6575b447f79b540749d231cb26d.tar.gz git-0f49327c9755b6575b447f79b540749d231cb26d.tar.xz |
Revert "rebase: allow starting from a dirty tree."
This reverts commit 6c9ad166dbbf9e5a0c09450b892151dbec49b8dc.
Allowing rebase to start in a dirty tree might have been a worthy
goal, but it is not necessarily always wanted (some people prefer
to be reminded that the state is dirty, and think about the next
action that may not be to stash and proceed). Furthermore, depending
on the nature of local changes, unstashing the dirty state on top of
the rebased result is not always desirable.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-x | git-rebase.sh | 72 |
1 files changed, 14 insertions, 58 deletions
diff --git a/git-rebase.sh b/git-rebase.sh index e342974dc..c9942f240 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -116,30 +116,10 @@ call_merge () { } finish_rb_merge () { - if test -f "$dotest/stash" - then - stash=$(cat "$dotest/stash") - git stash apply --index "$stash" - fi rm -r "$dotest" echo "All done." } -read_stash () { - if test -f "$1" - then - cat "$1" - fi -} -unstash_and_exit () { - err=$? - if test -f "$1" && test $err = 0 - then - git stash apply --index "$1" - fi - exit $err -} - is_interactive () { test -f "$dotest"/interactive || while case $#,"$1" in 0,|*,-i|*,--interactive) break ;; esac @@ -174,9 +154,8 @@ do finish_rb_merge exit fi - stash=$(read_stash ".dotest/stash") git am --resolved --3way --resolvemsg="$RESOLVEMSG" - unstash_and_exit "$stash" + exit ;; --skip) if test -d "$dotest" @@ -195,31 +174,21 @@ do finish_rb_merge exit fi - stash=$(read_stash ".dotest/stash") git am -3 --skip --resolvemsg="$RESOLVEMSG" - unstash_and_exit "$stash" + exit ;; --abort) git rerere clear if test -d "$dotest" then - if test -f "$dotest/stash" - then - stash=$(cat "$dotest/stash") - fi rm -r "$dotest" elif test -d .dotest then - if test -f ".dotest/stash" - then - stash=$(cat ".dotest/stash") - fi rm -r .dotest else die "No rebase in progress?" fi git reset --hard ORIG_HEAD - test -z "$stash" || git stash apply --index "$stash" exit ;; --onto) @@ -285,6 +254,16 @@ else fi fi +# The tree must be really really clean. +git update-index --refresh || exit +diff=$(git diff-index --cached --name-status -r HEAD) +case "$diff" in +?*) echo "cannot rebase: your index is not up-to-date" + echo "$diff" + exit 1 + ;; +esac + # The upstream head must be given. Make sure it is valid. upstream_name="$1" upstream=`git rev-parse --verify "${upstream_name}^0"` || @@ -294,19 +273,11 @@ upstream=`git rev-parse --verify "${upstream_name}^0"` || onto_name=${newbase-"$upstream_name"} onto=$(git rev-parse --verify "${onto_name}^0") || exit -# The tree must be clean enough for us to create a stash -stash=$(git stash create) || exit -if test -n "$stash" -then - echo >&2 "Stashed away your working tree changes" -fi - # If a hook exists, give it a chance to interrupt if test -x "$GIT_DIR/hooks/pre-rebase" then "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || { echo >&2 "The pre-rebase hook refused to rebase." - test -z "$stash" || git stash apply --index "$stash" exit 1 } fi @@ -315,10 +286,7 @@ fi case "$#" in 2) branch_name="$2" - git-checkout "$2" || { - test -z "$stash" || git stash apply --index "$stash" - usage - } + git-checkout "$2" || usage ;; *) if branch_name=`git symbolic-ref -q HEAD` @@ -341,7 +309,6 @@ if test "$upstream" = "$onto" && test "$mb" = "$onto" && ! git rev-list --parents "$onto".."$branch" | grep " .* " > /dev/null then echo >&2 "Current branch $branch_name is up to date." - test -z "$stash" || git stash apply --index "$stash" exit 0 fi @@ -361,7 +328,6 @@ git-reset --hard "$onto" if test "$mb" = "$branch" then echo >&2 "Fast-forwarded $branch_name to $onto_name." - test -z "$stash" || git stash apply --index "$stash" exit 0 fi @@ -369,16 +335,7 @@ if test -z "$do_merge" then git format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG" - err=$? - - if test $err = 0 - then - test -z "$stash" || git stash apply --index "$stash" - exit - else - test -z "$stash" || echo "$stash" >.dotest/stash - exit $err - fi + exit $? fi # start doing a rebase with git-merge @@ -389,7 +346,6 @@ echo "$onto" > "$dotest/onto" echo "$onto_name" > "$dotest/onto_name" prev_head=`git rev-parse HEAD^0` echo "$prev_head" > "$dotest/prev_head" -test -z "$stash" || echo "$stash" >"$dotest/stash" msgnum=0 for cmt in `git rev-list --reverse --no-merges "$upstream"..ORIG_HEAD` |