Skip to content

Commit 123ee3c

Browse files
author
Junio C Hamano
committed
Add --no-commit to git-merge/git-pull.
With --no-commit flag, git-pull will perform the merge but pretends as if the merge needed a hand resolve even if automerge cleanly resolves, to give the user a chance to add further changes and edit the commit message. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent a3114b3 commit 123ee3c

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

git-merge.sh

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LF='
99
'
1010

1111
usage () {
12-
die "git-merge [-n] [-s <strategy>]... <merge-message> <head> <remote>+"
12+
die "git-merge [-n] [--no-commit] [-s <strategy>]... <merge-message> <head> <remote>+"
1313
}
1414

1515
# all_strategies='resolve recursive stupid octopus'
@@ -63,6 +63,8 @@ do
6363
-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
6464
--no-summa|--no-summar|--no-summary)
6565
no_summary=t ;;
66+
--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
67+
no_commit=t ;;
6668
-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
6769
--strateg=*|--strategy=*|\
6870
-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
@@ -111,18 +113,18 @@ done
111113
common=$(git-show-branch --merge-base $head "$@")
112114
echo "$head" >"$GIT_DIR/ORIG_HEAD"
113115

114-
case "$#,$common" in
115-
*,'')
116+
case "$#,$common,$no_commit" in
117+
*,'',*)
116118
# No common ancestors found. We need a real merge.
117119
;;
118-
1,"$1")
120+
1,"$1",*)
119121
# If head can reach all the merge then we are up to date.
120122
# but first the most common case of merging one remote
121123
echo "Already up-to-date."
122124
dropsave
123125
exit 0
124126
;;
125-
1,"$head")
127+
1,"$head",*)
126128
# Again the most common case of merging one remote.
127129
echo "Updating from $head to $1."
128130
git-update-index --refresh 2>/dev/null
@@ -132,11 +134,11 @@ case "$#,$common" in
132134
dropsave
133135
exit 0
134136
;;
135-
1,?*"$LF"?*)
137+
1,?*"$LF"?*,*)
136138
# We are not doing octopus and not fast forward. Need a
137139
# real merge.
138140
;;
139-
1,*)
141+
1,*,)
140142
# We are not doing octopus, not fast forward, and have only
141143
# one common. See if it is really trivial.
142144
echo "Trying really trivial in-index merge..."
@@ -210,12 +212,18 @@ do
210212
# Remember which strategy left the state in the working tree
211213
wt_strategy=$strategy
212214

213-
git-merge-$strategy $common -- "$head_arg" "$@" || {
215+
git-merge-$strategy $common -- "$head_arg" "$@"
216+
exit=$?
217+
if test "$no_commit" = t && test "$exit" = 0
218+
then
219+
exit=1 ;# pretend it left conflicts.
220+
fi
221+
222+
test "$exit" = 0 || {
214223

215224
# The backend exits with 1 when conflicts are left to be resolved,
216225
# with 2 when it does not handle the given merge at all.
217226

218-
exit=$?
219227
if test "$exit" -eq 1
220228
then
221229
cnt=`{
@@ -272,4 +280,4 @@ do
272280
done >"$GIT_DIR/MERGE_HEAD"
273281
echo $merge_msg >"$GIT_DIR/MERGE_MSG"
274282

275-
die "Automatic merge failed; fix up by hand"
283+
die "Automatic merge failed/prevented; fix up by hand"

git-pull.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ usage () {
1010
die "git pull [-n] [-s strategy]... <repo> <head>..."
1111
}
1212

13-
strategy_args= no_summary=
13+
strategy_args= no_summary= no_commit=
1414
while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
1515
do
1616
case "$1" in
1717
-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
1818
--no-summa|--no-summar|--no-summary)
1919
no_summary=-n ;;
20+
--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
21+
no_commit=--no-commit ;;
2022
-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
2123
--strateg=*|--strategy=*|\
2224
-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
@@ -81,4 +83,4 @@ case "$strategy_args" in
8183
esac
8284

8385
merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD")
84-
git-merge $no_summary $strategy_args "$merge_name" HEAD $merge_head
86+
git-merge $no_summary $no_commit $strategy_args "$merge_name" HEAD $merge_head

0 commit comments

Comments
 (0)