Skip to content

Commit 9765b6a

Browse files
Martin von Zweigbergkgitster
authored andcommitted
rebase: align variable content
Make sure to interpret variables with the same name in the same way in git-rebase.sh and git-rebase--interactive.sh. This will make it easier to factor out code from git-rebase.sh to git-rebase--interactive and export the variables. Signed-off-by: Martin von Zweigbergk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6bb4e48 commit 9765b6a

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

git-rebase--interactive.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ pick_one_preserving_merges () {
339339
# No point in merging the first parent, that's HEAD
340340
new_parents=${new_parents# $first_parent}
341341
if ! do_with_author output \
342-
git merge $strategy -m "$msg_content" $new_parents
342+
git merge ${strategy:+-s $strategy} -m \
343+
"$msg_content" $new_parents
343344
then
344345
printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
345346
die_with_patch $sha1 "Error redoing merge $sha1"
@@ -827,11 +828,11 @@ first and then run 'git rebase --continue' again."
827828
-s)
828829
case "$#,$1" in
829830
*,*=*)
830-
strategy="-s "$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
831+
strategy=$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
831832
1,*)
832833
usage ;;
833834
*)
834-
strategy="-s $2"
835+
strategy="$2"
835836
shift ;;
836837
esac
837838
;;
@@ -860,9 +861,9 @@ first and then run 'git rebase --continue' again."
860861
autosquash=
861862
;;
862863
--onto)
864+
test 2 -le "$#" || usage
865+
onto="$2"
863866
shift
864-
onto=$(parse_onto "$1") ||
865-
die "Does not point to a valid commit: $1"
866867
;;
867868
--)
868869
shift
@@ -872,6 +873,11 @@ first and then run 'git rebase --continue' again."
872873
shift
873874
done
874875

876+
if test -n "$onto"
877+
then
878+
onto=$(parse_onto "$onto") || die "Does not point to a valid commit: $1"
879+
fi
880+
875881
test -z "$rebase_root" -a $# -ge 1 -a $# -le 2 ||
876882
test ! -z "$rebase_root" -a $# -le 1 || usage
877883
test -d "$dotest" &&

git-rebase.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\".
4343
To restore the original branch and stop rebasing run \"git rebase --abort\".
4444
"
4545
unset onto
46-
strategy=recursive
46+
strategy=
4747
strategy_opts=
4848
do_merge=
4949
merge_dir="$GIT_DIR"/rebase-merge
@@ -130,6 +130,7 @@ call_merge () {
130130
then
131131
GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY
132132
fi
133+
test -z "$strategy" && strategy=recursive
133134
eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
134135
rv=$?
135136
case "$rv" in
@@ -267,6 +268,7 @@ do
267268
esac
268269
strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$newopt")"
269270
do_merge=t
271+
test -z "$strategy" && strategy=recursive
270272
;;
271273
-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
272274
--strateg=*|--strategy=*|\

0 commit comments

Comments
 (0)