Merge branch 'ks/rebase-error-messages'

Error messages from "git rebase" have been somewhat cleaned up.

* ks/rebase-error-messages:
  rebase: rebasing can also be done when HEAD is detached
  rebase: distinguish user input by quoting it
  rebase: consistently use branch_name variable
This commit is contained in:
Junio C Hamano 2017-12-28 14:08:49 -08:00
commit 594672d237

View file

@ -477,7 +477,7 @@ then
;; ;;
esac esac
upstream=$(peel_committish "${upstream_name}") || upstream=$(peel_committish "${upstream_name}") ||
die "$(eval_gettext "invalid upstream \$upstream_name")" die "$(eval_gettext "invalid upstream '\$upstream_name'")"
upstream_arg="$upstream_name" upstream_arg="$upstream_name"
else else
if test -z "$onto" if test -z "$onto"
@ -518,7 +518,7 @@ case "$onto_name" in
esac esac
# If the branch to rebase is given, that is the branch we will rebase # If the branch to rebase is given, that is the branch we will rebase
# $branch_name -- branch being rebased, or HEAD (already detached) # $branch_name -- branch/commit being rebased, or HEAD (already detached)
# $orig_head -- commit object name of tip of the branch before rebasing # $orig_head -- commit object name of tip of the branch before rebasing
# $head_name -- refs/heads/<that-branch> or "detached HEAD" # $head_name -- refs/heads/<that-branch> or "detached HEAD"
switch_to= switch_to=
@ -528,15 +528,18 @@ case "$#" in
branch_name="$1" branch_name="$1"
switch_to="$1" switch_to="$1"
if git show-ref --verify --quiet -- "refs/heads/$1" && # Is it a local branch?
orig_head=$(git rev-parse -q --verify "refs/heads/$1") if git show-ref --verify --quiet -- "refs/heads/$branch_name" &&
orig_head=$(git rev-parse -q --verify "refs/heads/$branch_name")
then then
head_name="refs/heads/$1" head_name="refs/heads/$branch_name"
elif orig_head=$(git rev-parse -q --verify "$1") # If not is it a valid ref (branch or commit)?
elif orig_head=$(git rev-parse -q --verify "$branch_name")
then then
head_name="detached HEAD" head_name="detached HEAD"
else else
die "$(eval_gettext "fatal: no such branch: \$branch_name")" die "$(eval_gettext "fatal: no such branch/commit '\$branch_name'")"
fi fi
;; ;;
0) 0)
@ -547,7 +550,7 @@ case "$#" in
branch_name=$(expr "z$branch_name" : 'zrefs/heads/\(.*\)') branch_name=$(expr "z$branch_name" : 'zrefs/heads/\(.*\)')
else else
head_name="detached HEAD" head_name="detached HEAD"
branch_name=HEAD ;# detached branch_name=HEAD
fi fi
orig_head=$(git rev-parse --verify HEAD) || exit orig_head=$(git rev-parse --verify HEAD) || exit
;; ;;
@ -598,11 +601,23 @@ then
test -z "$switch_to" || test -z "$switch_to" ||
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \ GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \
git checkout -q "$switch_to" -- git checkout -q "$switch_to" --
say "$(eval_gettext "Current branch \$branch_name is up to date.")" if test "$branch_name" = "HEAD" &&
! git symbolic-ref -q HEAD
then
say "$(eval_gettext "HEAD is up to date.")"
else
say "$(eval_gettext "Current branch \$branch_name is up to date.")"
fi
finish_rebase finish_rebase
exit 0 exit 0
else else
say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")" if test "$branch_name" = "HEAD" &&
! git symbolic-ref -q HEAD
then
say "$(eval_gettext "HEAD is up to date, rebase forced.")"
else
say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")"
fi
fi fi
fi fi