From: Junio C Hamano Date: Fri, 20 Sep 2013 19:34:36 +0000 (-0700) Subject: Merge branch 'mm/rebase-continue-freebsd-WB' X-Git-Tag: v1.8.5-rc0~96 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f26f250b442b57d0e6d9295bb98690ce70640759?ds=inline;hp=-c Merge branch 'mm/rebase-continue-freebsd-WB' Work around a bug in FreeBSD shell that caused a regression to "git rebase" in v1.8.4. May need to be later applied to 'maint'. * mm/rebase-continue-freebsd-WB: rebase: fix run_specific_rebase's use of "return" on FreeBSD --- f26f250b442b57d0e6d9295bb98690ce70640759 diff --combined git-rebase.sh index 8d7659a22c,7ab6434a4f..226752fbff --- a/git-rebase.sh +++ b/git-rebase.sh @@@ -13,7 -13,6 +13,7 @@@ git-rebase --continue | --abort | --ski 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 onto=! rebase onto given branch instead of upstream p,preserve-merges! try to recreate merges instead of ignoring them s,strategy=! use the given merge strategy @@@ -65,7 -64,6 +65,7 @@@ apply_dir="$GIT_DIR"/rebase-appl verbose= diffstat= test "$(git config --bool rebase.stat)" = true && diffstat=t +autostash="$(git config --bool rebase.autostash || echo false)" git_am_opt= rebase_root= force_rebase= @@@ -84,8 -82,6 +84,8 @@@ keep_empty test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t read_basic_state () { + test -f "$state_dir/head-name" && + test -f "$state_dir/onto" && head_name=$(cat "$state_dir"/head-name) && onto=$(cat "$state_dir"/onto) && # We always write to orig-head, but interactive rebase used to write to @@@ -147,37 -143,27 +147,46 @@@ move_to_original_branch () esac } +finish_rebase () { + if test -f "$state_dir/autostash" + then + stash_sha1=$(cat "$state_dir/autostash") + if git stash apply $stash_sha1 2>&1 >/dev/null + then + echo "$(gettext 'Applied autostash.')" + else + git stash store -m "autostash" -q $stash_sha1 || + die "$(eval_gettext "Cannot store \$stash_sha1")" + gettext 'Applying autostash resulted in conflicts. +Your changes are safe in the stash. +You can run "git stash pop" or "git stash drop" at any time. +' + fi + fi + git gc --auto && + rm -rf "$state_dir" +} + - run_specific_rebase () { + run_specific_rebase_internal () { if [ "$interactive_rebase" = implied ]; then GIT_EDITOR=: export GIT_EDITOR autosquash= fi + # On FreeBSD, the shell's "return" returns from the current + # function, not from the current file inclusion. + # run_specific_rebase_internal has the file inclusion as a + # last statement, so POSIX and FreeBSD's return will do the + # same thing. . git-rebase--$type + } + + run_specific_rebase () { + run_specific_rebase_internal ret=$? if test $ret -eq 0 then - git gc --auto && - rm -rf "$state_dir" + finish_rebase fi exit $ret } @@@ -271,9 -257,6 +280,9 @@@ d --stat) diffstat=t ;; + --autostash) + autostash=true + ;; -v) verbose=t diffstat=t @@@ -374,7 -357,7 +383,7 @@@ abort ;; esac output git reset --hard $orig_head - rm -r "$state_dir" + finish_rebase exit ;; edit-todo) @@@ -433,7 -416,7 +442,7 @@@ the shift ;; esac - upstream=`git rev-parse --verify "${upstream_name}^0"` || + upstream=$(peel_committish "${upstream_name}") || die "$(eval_gettext "invalid upstream \$upstream_name")" upstream_arg="$upstream_name" else @@@ -469,7 -452,7 +478,7 @@@ case "$onto_name" i fi ;; *) - onto=$(git rev-parse --verify "${onto_name}^0") || + onto=$(peel_committish "$onto_name") || die "$(eval_gettext "Does not point to a valid commit: \$onto_name")" ;; esac @@@ -513,18 -496,6 +522,18 @@@ case "$#" i ;; esac +if test "$autostash" = true && ! (require_clean_work_tree) 2>/dev/null +then + stash_sha1=$(git stash create "autostash") || + die "$(gettext 'Cannot autostash')" + + mkdir -p "$state_dir" && + echo $stash_sha1 >"$state_dir/autostash" && + stash_abbrev=$(git rev-parse --short $stash_sha1) && + echo "$(eval_gettext 'Created autostash: $stash_abbrev')" && + git reset --hard +fi + require_clean_work_tree "rebase" "$(gettext "Please commit or stash them.")" # Now we are rebasing commits $upstream..$orig_head (or with --root, @@@ -542,11 -513,8 +551,11 @@@ the if test -z "$force_rebase" then # Lazily switch to the target branch if needed... - test -z "$switch_to" || git checkout "$switch_to" -- + test -z "$switch_to" || + GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \ + git checkout "$switch_to" -- say "$(eval_gettext "Current branch \$branch_name is up to date.")" + finish_rebase exit 0 else say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")" @@@ -570,9 -538,7 +579,9 @@@ test "$type" = interactive && run_speci # Detach HEAD and reset the tree say "$(gettext "First, rewinding head to replay your work on top of it...")" -git checkout -q "$onto^0" || die "could not detach HEAD" + +GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name" \ + git checkout -q "$onto^0" || die "could not detach HEAD" git update-ref ORIG_HEAD $orig_head # If the $onto is a proper descendant of the tip of the branch, then @@@ -581,7 -547,6 +590,7 @@@ if test "$mb" = "$orig_head then say "$(eval_gettext "Fast-forwarded \$branch_name to \$onto_name.")" move_to_original_branch + finish_rebase exit 0 fi