Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'git-rebase.sh')
-rwxr-xr-xgit-rebase.sh54
1 files changed, 40 insertions, 14 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index 6344e8d5e3..a1f6e5de6a 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -9,7 +9,7 @@ OPTIONS_STUCKLONG=t
OPTIONS_SPEC="\
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
-git-rebase --continue | --abort | --skip | --edit-todo
+git rebase --continue | --abort | --skip | --edit-todo
--
Available options are
v,verbose! display a diffstat of what changed upstream
@@ -24,6 +24,7 @@ m,merge! use merging strategies to rebase
i,interactive! let the user edit the list of commits to rebase
x,exec=! add exec lines after each commit of the editable list
k,keep-empty preserve empty commits during rebase
+allow-empty-message allow rebasing commits with empty messages
f,force-rebase! force rebase even if branch is up to date
X,strategy-option=! pass the argument through to the merge strategy
stat! display a diffstat of what changed upstream
@@ -45,6 +46,7 @@ abort! abort and check out the original branch
skip! skip current patch and continue
edit-todo! edit the todo list during an interactive rebase
quit! abort but keep HEAD where it is
+show-current-patch! show the patch file being applied or merged
"
. git-sh-setup
set_reflog_action rebase
@@ -89,6 +91,7 @@ action=
preserve_merges=
autosquash=
keep_empty=
+allow_empty_message=
test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
case "$(git config --bool commit.gpgsign)" in
true) gpg_sign_opt=-S ;;
@@ -166,7 +169,7 @@ apply_autostash () {
if test -f "$state_dir/autostash"
then
stash_sha1=$(cat "$state_dir/autostash")
- if git stash apply $stash_sha1 2>&1 >/dev/null
+ if git stash apply $stash_sha1 >/dev/null 2>&1
then
echo "$(gettext 'Applied autostash.')" >&2
else
@@ -181,6 +184,7 @@ You can run "git stash pop" or "git stash drop" at any time.
}
finish_rebase () {
+ rm -f "$(git rev-parse --git-path REBASE_HEAD)"
apply_autostash &&
{ git gc --auto || true; } &&
rm -rf "$state_dir"
@@ -216,7 +220,7 @@ run_pre_rebase_hook () {
}
test -f "$apply_dir"/applying &&
- die "$(gettext "It looks like git-am is in progress. Cannot rebase.")"
+ die "$(gettext "It looks like 'git am' is in progress. Cannot rebase.")"
if test -d "$apply_dir"
then
@@ -245,7 +249,7 @@ do
--verify)
ok_to_skip_pre_rebase=
;;
- --continue|--skip|--abort|--quit|--edit-todo)
+ --continue|--skip|--abort|--quit|--edit-todo|--show-current-patch)
test $total_argc -eq 2 || usage
action=${1##--}
;;
@@ -262,6 +266,9 @@ do
--keep-empty)
keep_empty=yes
;;
+ --allow-empty-message)
+ allow_empty_message=--allow-empty-message
+ ;;
--preserve-merges)
preserve_merges=t
test -z "$interactive_rebase" && interactive_rebase=implied
@@ -412,6 +419,10 @@ quit)
edit-todo)
run_specific_rebase
;;
+show-current-patch)
+ run_specific_rebase
+ die "BUG: run_specific_rebase is not supposed to return here"
+ ;;
esac
# Make sure no rebase is in progress
@@ -477,7 +488,7 @@ then
;;
esac
upstream=$(peel_committish "${upstream_name}") ||
- die "$(eval_gettext "invalid upstream \$upstream_name")"
+ die "$(eval_gettext "invalid upstream '\$upstream_name'")"
upstream_arg="$upstream_name"
else
if test -z "$onto"
@@ -518,7 +529,7 @@ case "$onto_name" in
esac
# 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
# $head_name -- refs/heads/<that-branch> or "detached HEAD"
switch_to=
@@ -528,15 +539,18 @@ case "$#" in
branch_name="$1"
switch_to="$1"
- if git show-ref --verify --quiet -- "refs/heads/$1" &&
- orig_head=$(git rev-parse -q --verify "refs/heads/$1")
+ # Is it a local branch?
+ if git show-ref --verify --quiet -- "refs/heads/$branch_name" &&
+ orig_head=$(git rev-parse -q --verify "refs/heads/$branch_name")
then
- head_name="refs/heads/$1"
- elif orig_head=$(git rev-parse -q --verify "$1")
+ head_name="refs/heads/$branch_name"
+ # If not is it a valid ref (branch or commit)?
+ elif orig_head=$(git rev-parse -q --verify "$branch_name")
then
head_name="detached HEAD"
+
else
- die "$(eval_gettext "fatal: no such branch: \$branch_name")"
+ die "$(eval_gettext "fatal: no such branch/commit '\$branch_name'")"
fi
;;
0)
@@ -547,7 +561,7 @@ case "$#" in
branch_name=$(expr "z$branch_name" : 'zrefs/heads/\(.*\)')
else
head_name="detached HEAD"
- branch_name=HEAD ;# detached
+ branch_name=HEAD
fi
orig_head=$(git rev-parse --verify HEAD) || exit
;;
@@ -598,11 +612,23 @@ then
test -z "$switch_to" ||
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $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
exit 0
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