@matheusbsbs / matheus-bagliano / commits / 123ee3ca7b
Fork 0

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>

Junio C Hamano committed Nov 1, 2005 at 19:30 UTC 123ee3ca7b57c32bb3ecd8cfede20dbb9dd5a8a8
2 files changed +22 -12
git-merge.sh
+18 -10
@@ -9,7 +9,7 @@ LF='
9 '
10
11 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>+"
13 }
14
15 # all_strategies='resolve recursive stupid octopus'
@@ -63,6 +63,8 @@ do
63 -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
64 --no-summa|--no-summar|--no-summary)
65 no_summary=t ;;
66 + --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
67 + no_commit=t ;;
68 -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
69 --strateg=*|--strategy=*|\
70 -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
@@ -111,18 +113,18 @@ done
113 common=$(git-show-branch --merge-base $head "$@")
114 echo "$head" >"$GIT_DIR/ORIG_HEAD"
115
114 -case "$#,$common" in
115 -*,'')
116 +case "$#,$common,$no_commit" in
117 +*,'',*)
118 # No common ancestors found. We need a real merge.
119 ;;
118 -1,"$1")
120 +1,"$1",*)
121 # If head can reach all the merge then we are up to date.
122 # but first the most common case of merging one remote
123 echo "Already up-to-date."
124 dropsave
125 exit 0
126 ;;
125 -1,"$head")
127 +1,"$head",*)
128 # Again the most common case of merging one remote.
129 echo "Updating from $head to $1."
130 git-update-index --refresh 2>/dev/null
@@ -132,11 +134,11 @@ case "$#,$common" in
134 dropsave
135 exit 0
136 ;;
135 -1,?*"$LF"?*)
137 +1,?*"$LF"?*,*)
138 # We are not doing octopus and not fast forward. Need a
139 # real merge.
140 ;;
139 -1,*)
141 +1,*,)
142 # We are not doing octopus, not fast forward, and have only
143 # one common. See if it is really trivial.
144 echo "Trying really trivial in-index merge..."
@@ -210,12 +212,18 @@ do
212 # Remember which strategy left the state in the working tree
213 wt_strategy=$strategy
214
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 || {
223
224 # The backend exits with 1 when conflicts are left to be resolved,
225 # with 2 when it does not handle the given merge at all.
226
218 - exit=$?
227 if test "$exit" -eq 1
228 then
229 cnt=`{
@@ -272,4 +280,4 @@ do
280 done >"$GIT_DIR/MERGE_HEAD"
281 echo $merge_msg >"$GIT_DIR/MERGE_MSG"
282
275 -die "Automatic merge failed; fix up by hand"
283 +die "Automatic merge failed/prevented; fix up by hand"
git-pull.sh
+4 -2
@@ -10,13 +10,15 @@ usage () {
10 die "git pull [-n] [-s strategy]... <repo> <head>..."
11 }
12
13 -strategy_args= no_summary=
13 +strategy_args= no_summary= no_commit=
14 while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
15 do
16 case "$1" in
17 -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
18 --no-summa|--no-summar|--no-summary)
19 no_summary=-n ;;
20 + --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
21 + no_commit=--no-commit ;;
22 -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
23 --strateg=*|--strategy=*|\
24 -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
@@ -81,4 +83,4 @@ case "$strategy_args" in
83 esac
84
85 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