{"thread":{"id":"2309","subject":"[PATCH] Add --no-commit to git-merge/git-pull.","startedAt":"2005-11-02T03:43:30Z","lastAt":"2005-11-02T03:43:30Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"10990","messageId":"7vd5lj3eal.fsf@assigned-by-dhcp.cox.net","threadId":"2309","inReplyTo":null,"subject":"[PATCH] Add --no-commit to git-merge/git-pull.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-02T03:43:30Z","receivedAt":"2005-11-02T03:43:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"With --no-commit flag, git-pull will perform the merge but pretends as\nif the merge needed a hand resolve even if automerge cleanly resolves,\nto give the user a chance to add further changes and edit the commit\nmessage.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n This turns out to be useful while maintaining the maint branch\n for 0.99.9[a-z] lettered maintenance releases.  The plan is for\n the contents of that branch to match always the tip of the\n master branch during 0.99.9 timeframe, and every time a merge\n is done from master into maint, only GIT_VERSION in the\n Makefile is bumped up.  0.99.8 maintenance branch was done by\n pulling from a private branch \"fixes\", immediately followed by\n a separate commit to bump that definition up, but with this, I\n could instead do this:\n\n        $ git checkout master\n        $ git am -3 -s ./++patches-from-the-list.mbox\n\t... work work work in master ...\n        $ git checkout maint\n        $ git pull --no-commit . master\n        ... update the version in Makefile and debian/changelog ...\n        $ git commit -a -m 'GIT 0.99.9b'\n\n git-merge.sh |   28 ++++++++++++++++++----------\n git-pull.sh  |    6 ++++--\n 2 files changed, 22 insertions(+), 12 deletions(-)\n\napplies-to: 60d390a285756ba840953418954ac05dca40f75b\nc575e6d759f2305e5710dae7ac58274db5930de7\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 6ad96eb..dd104db 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -9,7 +9,7 @@ LF='\n '\n \n usage () {\n-    die \"git-merge [-n] [-s <strategy>]... <merge-message> <head> <remote>+\"\n+    die \"git-merge [-n] [--no-commit] [-s <strategy>]... <merge-message> <head> <remote>+\"\n }\n \n # all_strategies='resolve recursive stupid octopus'\n@@ -63,6 +63,8 @@ do\n \t-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\\\n \t\t--no-summa|--no-summar|--no-summary)\n \t\tno_summary=t ;;\n+\t--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)\n+\t\tno_commit=t ;;\n \t-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\\\n \t\t--strateg=*|--strategy=*|\\\n \t-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)\n@@ -111,18 +113,18 @@ done\n common=$(git-show-branch --merge-base $head \"$@\")\n echo \"$head\" >\"$GIT_DIR/ORIG_HEAD\"\n \n-case \"$#,$common\" in\n-*,'')\n+case \"$#,$common,$no_commit\" in\n+*,'',*)\n \t# No common ancestors found. We need a real merge.\n \t;;\n-1,\"$1\")\n+1,\"$1\",*)\n \t# If head can reach all the merge then we are up to date.\n \t# but first the most common case of merging one remote\n \techo \"Already up-to-date.\"\n \tdropsave\n \texit 0\n \t;;\n-1,\"$head\")\n+1,\"$head\",*)\n \t# Again the most common case of merging one remote.\n \techo \"Updating from $head to $1.\"\n \tgit-update-index --refresh 2>/dev/null\n@@ -132,11 +134,11 @@ case \"$#,$common\" in\n \tdropsave\n \texit 0\n \t;;\n-1,?*\"$LF\"?*)\n+1,?*\"$LF\"?*,*)\n \t# We are not doing octopus and not fast forward.  Need a\n \t# real merge.\n \t;;\n-1,*)\n+1,*,)\n \t# We are not doing octopus, not fast forward, and have only\n \t# one common.  See if it is really trivial.\n \techo \"Trying really trivial in-index merge...\"\n@@ -210,12 +212,18 @@ do\n     # Remember which strategy left the state in the working tree\n     wt_strategy=$strategy\n \n-    git-merge-$strategy $common -- \"$head_arg\" \"$@\" || {\n+    git-merge-$strategy $common -- \"$head_arg\" \"$@\"\n+    exit=$?\n+    if test \"$no_commit\" = t && test \"$exit\" = 0\n+    then\n+\texit=1 ;# pretend it left conflicts.\n+    fi\n+\n+    test \"$exit\" = 0 || {\n \n \t# The backend exits with 1 when conflicts are left to be resolved,\n \t# with 2 when it does not handle the given merge at all.\n \n-\texit=$?\n \tif test \"$exit\" -eq 1\n \tthen\n \t    cnt=`{\n@@ -272,4 +280,4 @@ do\n done >\"$GIT_DIR/MERGE_HEAD\"\n echo $merge_msg >\"$GIT_DIR/MERGE_MSG\"\n \n-die \"Automatic merge failed; fix up by hand\"\n+die \"Automatic merge failed/prevented; fix up by hand\"\ndiff --git a/git-pull.sh b/git-pull.sh\nindex d476518..9601627 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -10,13 +10,15 @@ usage () {\n     die \"git pull [-n] [-s strategy]... <repo> <head>...\"\n }\n \n-strategy_args= no_summary=\n+strategy_args= no_summary= no_commit=\n while case \"$#,$1\" in 0) break ;; *,-*) ;; *) break ;; esac\n do\n \tcase \"$1\" in\n \t-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\\\n \t\t--no-summa|--no-summar|--no-summary)\n \t\tno_summary=-n ;;\n+\t--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)\n+\t\tno_commit=--no-commit ;;\n \t-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\\\n \t\t--strateg=*|--strategy=*|\\\n \t-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)\n@@ -81,4 +83,4 @@ case \"$strategy_args\" in\n esac\n \n merge_name=$(git-fmt-merge-msg <\"$GIT_DIR/FETCH_HEAD\")\n-git-merge $no_summary $strategy_args \"$merge_name\" HEAD $merge_head\n+git-merge $no_summary $no_commit $strategy_args \"$merge_name\" HEAD $merge_head\n---\n0.99.9.GIT\n"}]}