{"thread":{"id":"9973","subject":"[PATCH 0/5] per branch options for git-merge incl. --no-ff","startedAt":"2007-09-22T00:33:01Z","lastAt":"2007-09-23T19:33:15Z","messageCount":14,"participants":["Lars Hjemli","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"53773","messageId":"1190421186-21784-1-git-send-email-hjemli@gmail.com","threadId":"9973","inReplyTo":null,"subject":"[PATCH 0/5] per branch options for git-merge incl. --no-ff","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-22T00:33:01Z","receivedAt":"2007-09-22T00:33:01Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This patch-series implements support for per branch configuration of\ngit-merge, using entries (branch.<name>.mergeoptions) in .git/config.\n\nThere is also a new option, --no-ff, which can be used to force git-merge\nto create merge commits even when the merge was a fast-forward.\n\nFinally, the new optiond --ff and --commit can be used to override\nsetting specified in .git/config.\n\nNote: patch 1/5 is a resend of the testscript for git-merge, this time\nwith correct mode bits.\n\nShortlog:\n     Add test-script for git-merge porcelain\n     git-merge: refactor option parsing\n     git-merge: add support for branch.<name>.mergeoptions\n     git-merge: add support for --commit\n     git-merge: add --ff and --no-ff options\n\nDiffstat:\n Documentation/config.txt        |    6 +\n Documentation/git-merge.txt     |    4 +\n Documentation/merge-options.txt |   13 ++\n git-merge.sh                    |   56 +++++-\n t/t7600-merge.sh                |  414 +++++++++++++++++++++++++++++++++++++++\n\n 5 files changed, 483 insertions(+), 10 deletions(-)\n"},{"id":"53775","messageId":"1190421186-21784-2-git-send-email-hjemli@gmail.com","threadId":"9973","inReplyTo":"1190421186-21784-1-git-send-email-hjemli@gmail.com","subject":"[PATCH 1/5] Add test-script for git-merge porcelain","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-22T00:33:02Z","receivedAt":"2007-09-22T00:33:02Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This test-script tries to excercise the porcelainish aspects of git-merge.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n t/t7600-merge.sh |  317 ++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 317 insertions(+), 0 deletions(-)\n create mode 100755 t/t7600-merge.sh\n\ndiff --git a/t/t7600-merge.sh b/t/t7600-merge.sh\nnew file mode 100755\nindex 0000000..9e58636\n--- /dev/null\n+++ b/t/t7600-merge.sh\n@@ -0,0 +1,317 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Lars Hjemli\n+#\n+\n+test_description='git-merge\n+\n+Testing basic merge operations/option parsing.'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\techo \"\n+1\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+\" > file &&\n+\tgit add file &&\n+\tgit commit -m \"commit 0\" &&\n+\tgit tag c0 &&\n+\tc0=$(git rev-parse HEAD) &&\n+\techo \"\n+1 X\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+\" > file &&\n+\tgit add file &&\n+\tgit commit -m \"commit 1\" &&\n+\tgit tag c1 &&\n+\tc1=$(git rev-parse HEAD) &&\n+\tgit reset --hard \"$c0\" &&\n+\techo \"\n+1\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9\n+\" > file &&\n+\tgit add file &&\n+\tgit commit -m \"commit 2\" &&\n+\tgit tag c2 &&\n+\tc2=$(git rev-parse HEAD) &&\n+\tgit reset --hard \"$c0\" &&\n+\techo \"\n+1\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9 X\n+\" > file &&\n+\tgit add file &&\n+\tgit commit -m \"commit 3\" &&\n+\tgit tag c3 &&\n+\tc3=$(git rev-parse HEAD)\n+\tgit reset --hard \"$c0\"\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'test option parsing' '\n+\tif git merge -$ c1\n+\tthen\n+\t\techo \"[OOPS] -$ accepted\"\n+\t\tfalse\n+\tfi &&\n+\tif git merge --no-such c1\n+\tthen\n+\t\techo \"[OOPS] --no-such accepted\"\n+\t\tfalse\n+\tfi &&\n+\tif git merge -s foobar c1\n+\tthen\n+\t\techo \"[OOPS] -s foobar accepted\"\n+\t\tfalse\n+\tfi &&\n+\tif git merge -s=foobar c1\n+\tthen\n+\t\techo \"[OOPS] -s=foobar accepted\"\n+\t\tfalse\n+\tfi &&\n+\tif git merge -m\n+\tthen\n+\t\techo \"[OOPS] missing commit msg accepted\"\n+\t\tfalse\n+\tfi &&\n+\tif git merge\n+\tthen\n+\t\techo \"[OOPS] missing commit references accepted\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_expect_success 'merge c0 with c1' '\n+\tgit reset --hard c0 &&\n+\tgit merge c1 &&\n+\ttest \"$c1\" = \"$(git rev-parse HEAD)\"\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'verify merge result' '\n+\techo \"\n+1 X\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+\" > result.1 &&\n+\tcmp -s file result.1\n+'\n+\n+test_expect_success 'merge c1 with c2' '\n+\tgit reset --hard c1 &&\n+\tgit merge c2 &&\n+\ttest \"$c1\" = \"$(git rev-parse HEAD^1)\" &&\n+\ttest \"$c2\" = \"$(git rev-parse HEAD^2)\"\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'verify merge result' '\n+\techo \"\n+1 X\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9\n+\" > result.1-5 &&\n+\tcmp -s file result.1-5\n+'\n+\n+test_expect_success 'merge c1 with c2 and c3' '\n+\tgit reset --hard c1 &&\n+\tgit merge c2 c3 &&\n+\ttest \"$c1\" = \"$(git rev-parse HEAD^1)\" &&\n+\ttest \"$c2\" = \"$(git rev-parse HEAD^2)\" &&\n+\ttest \"$c3\" = \"$(git rev-parse HEAD^3)\"\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'verify merge result' '\n+\techo \"\n+1 X\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9 X\n+\" > result.1-5-9 &&\n+\tcmp -s file result.1-5-9\n+'\n+\n+test_expect_success 'merge c0 with c1 (no-commit)' '\n+\tgit reset --hard c0 &&\n+\tgit merge --no-commit c1 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] fast-forward not performed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c1 with c2 (no-commit)' '\n+\tgit reset --hard c1 &&\n+\tgit merge --no-commit c2 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] HEAD changed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1-5\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif test \"$c2\" != \"$(cat .git/MERGE_HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] MERGE_HEAD is wrong\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c1 with c2 and c3 (no-commit)' '\n+\tgit reset --hard c1 &&\n+\tgit merge --no-commit c2 c3 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] HEAD changed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1-5-9\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif ! grep -q \"$c2\" .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] c2 not in MERGE_HEAD\"\n+\t\tfalse\n+\tfi &&\n+\tif ! grep -q \"$c3\" .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] c3 not in MERGE_HEAD\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c0 with c1 (squash)' '\n+\tgit reset --hard c0 &&\n+\tgit merge --squash c1 &&\n+\tif test \"$c0\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] HEAD changed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif test -f .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] MERGE_HEAD exists\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c1 with c2 (squash)' '\n+\tgit reset --hard c1 &&\n+\tgit merge --squash c2 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] new commit created\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1-5\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif test -f .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] MERGE_HEAD exists\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c1 with c2 and c3 (squash)' '\n+\tgit reset --hard c1 &&\n+\tgit merge --squash c2 c3 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] HEAD changed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1-5-9\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif test -f .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] MERGE_HEAD exists\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_done\n-- \n1.5.3.2.82.g75c8d\n"},{"id":"53774","messageId":"1190421186-21784-3-git-send-email-hjemli@gmail.com","threadId":"9973","inReplyTo":"1190421186-21784-2-git-send-email-hjemli@gmail.com","subject":"[PATCH 2/5] git-merge: refactor option parsing","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-22T00:33:03Z","receivedAt":"2007-09-22T00:33:03Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"Move the option parsing into a separate function as preparation for reuse\nby the next commit.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n git-merge.sh |   20 ++++++++++++++------\n 1 files changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 3a01db0..a3ef676 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -119,11 +119,7 @@ merge_name () {\n \tfi\n }\n \n-case \"$#\" in 0) usage ;; esac\n-\n-have_message=\n-while case \"$#\" in 0) break ;; esac\n-do\n+parse_option () {\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@@ -166,9 +162,21 @@ do\n \t\thave_message=t\n \t\t;;\n \t-*)\tusage ;;\n-\t*)\tbreak ;;\n+\t*)\treturn 1 ;;\n \tesac\n \tshift\n+\targs_left=\"$#\"\n+}\n+\n+case \"$#\" in 0) usage ;; esac\n+\n+have_message=\n+while parse_option \"$@\"\n+do\n+\twhile test $args_left -lt $#\n+\tdo\n+\t\tshift\n+\tdone\n done\n \n if test -z \"$show_diffstat\"; then\n-- \n1.5.3.2.82.g75c8d\n"},{"id":"53776","messageId":"1190421186-21784-4-git-send-email-hjemli@gmail.com","threadId":"9973","inReplyTo":"1190421186-21784-3-git-send-email-hjemli@gmail.com","subject":"[PATCH 3/5] git-merge: add support for branch.<name>.mergeoptions","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-22T00:33:04Z","receivedAt":"2007-09-22T00:33:04Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This enables per branch configuration of merge options. Currently, the most\nuseful options to specify per branch are --squash, --summary/--no-summary\nand possibly --strategy, but all options are supported.\n\nNote: Options containing whitespace will _not_ be handled correctly. Luckily,\nthe only option which can include whitespace is --message and it doesn't\nmake much sense to give that option a default value.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n Documentation/config.txt    |    6 ++++\n Documentation/git-merge.txt |    4 +++\n git-merge.sh                |   16 +++++++++++\n t/t7600-merge.sh            |   63 +++++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 89 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 015910f..d3c25f3 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -337,6 +337,12 @@ branch.<name>.merge::\n \tbranch.<name>.merge to the desired branch, and use the special setting\n \t`.` (a period) for branch.<name>.remote.\n \n+branch.<name>.mergeoptions::\n+\tSets default options for merging into branch <name>. The syntax and\n+\tsupported options are equal to that of gitlink:git-merge[1], but\n+\toption values containing whitespace characters are currently not\n+\tsupported.\n+\n clean.requireForce::\n \tA boolean to make git-clean do nothing unless given -f or -n.  Defaults\n \tto false.\ndiff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt\nindex 144bc16..b1771a1 100644\n--- a/Documentation/git-merge.txt\n+++ b/Documentation/git-merge.txt\n@@ -58,6 +58,10 @@ merge.verbosity::\n \tabove outputs debugging information.  The default is level 2.\n \tCan be overriden by 'GIT_MERGE_VERBOSITY' environment variable.\n \n+branch.<name>.mergeoptions::\n+\tSets default options for merging into branch <name>. The syntax and\n+\tsupported options are equal to that of git-merge, but option values\n+\tcontaining whitespace characters are currently not supported.\n \n HOW MERGE WORKS\n ---------------\ndiff --git a/git-merge.sh b/git-merge.sh\nindex a3ef676..39a24ac 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -168,9 +168,25 @@ parse_option () {\n \targs_left=\"$#\"\n }\n \n+parse_config () {\n+\twhile test \"$#\" != \"0\"\n+\tdo\n+\t\tparse_option \"$@\" || usage\n+\t\twhile test $args_left -lt $#\n+\t\tdo\n+\t\t\tshift\n+\t\tdone\n+\tdone\n+}\n+\n case \"$#\" in 0) usage ;; esac\n \n have_message=\n+\n+branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')\n+mergeopts=$(git config \"branch.$branch.mergeoptions\")\n+parse_config $mergeopts\n+\n while parse_option \"$@\"\n do\n \twhile test $args_left -lt $#\ndiff --git a/t/t7600-merge.sh b/t/t7600-merge.sh\nindex 9e58636..e99b5d9 100755\n--- a/t/t7600-merge.sh\n+++ b/t/t7600-merge.sh\n@@ -314,4 +314,67 @@ test_expect_success 'merge c1 with c2 and c3 (squash)' '\n \n test_debug 'gitk --all'\n \n+test_expect_success 'merge c1 with c2 (no-commit in config)' '\n+\tgit reset --hard c1 &&\n+\tgit config branch.master.mergeoptions \"--no-commit\" &&\n+\tgit merge c2 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] HEAD changed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1-5\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif test \"$c2\" != \"$(cat .git/MERGE_HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] MERGE_HEAD is wrong\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_expect_success 'merge c1 with c2 (squash in config)' '\n+\tgit reset --hard c1 &&\n+\tgit config branch.master.mergeoptions \"--squash\" &&\n+\tgit merge c2 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] new commit created\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1-5\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif test -f .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] MERGE_HEAD exists\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_expect_success 'override config option -n' '\n+\tgit reset --hard c1 &&\n+\tgit config branch.master.mergeoptions \"-n\" &&\n+\tgit merge --summary c2 >diffstat.txt &&\n+\tif ! grep -e \"^ file | \\+2 +-$\" diffstat.txt\n+\tthen\n+\t\techo \"[OOPS] diffstat was not generated\"\n+\tfi\n+'\n+\n+test_expect_success 'override config option --summary' '\n+\tgit reset --hard c1 &&\n+\tgit config branch.master.mergeoptions \"--summary\" &&\n+\tgit merge -n c2 >diffstat.txt &&\n+\tif grep -e \"^ file | \\+2 +-$\" diffstat.txt\n+\tthen\n+\t\techo \"[OOPS] diffstat was generated\"\n+\t\tfalse\n+\tfi\n+'\n+\n test_done\n-- \n1.5.3.2.82.g75c8d\n"},{"id":"53777","messageId":"1190421186-21784-5-git-send-email-hjemli@gmail.com","threadId":"9973","inReplyTo":"1190421186-21784-4-git-send-email-hjemli@gmail.com","subject":"[PATCH 4/5] git-merge: add support for --commit","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-22T00:33:05Z","receivedAt":"2007-09-22T00:33:05Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This option can be used to override --no-commit and --squash. The change\nalso introduces slightly different behavior for --no-commit: when specified,\nit explicitly overrides --squash.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n Documentation/merge-options.txt |    4 ++++\n git-merge.sh                    |    6 ++++--\n t/t7600-merge.sh                |   16 ++++++++++++++++\n 3 files changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt\nindex d64c259..9be90b5 100644\n--- a/Documentation/merge-options.txt\n+++ b/Documentation/merge-options.txt\n@@ -10,6 +10,10 @@\n \tnot autocommit, to give the user a chance to inspect and\n \tfurther tweak the merge result before committing.\n \n+--commit::\n+\tPerform the merge and commit the result. This option can\n+\tbe used to override --no-commit and --squash.\n+\n --squash::\n \tProduce the working tree and index state as if a real\n \tmerge happened, but do not actually make a commit or\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 39a24ac..73ff130 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -3,7 +3,7 @@\n # Copyright (c) 2005 Junio C Hamano\n #\n \n-USAGE='[-n] [--summary] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'\n+USAGE='[-n] [--summary] [--[no-]commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'\n \n SUBDIRECTORY_OK=Yes\n . git-sh-setup\n@@ -128,8 +128,10 @@ parse_option () {\n \t\tshow_diffstat=t ;;\n \t--sq|--squ|--squa|--squas|--squash)\n \t\tsquash=t no_commit=t ;;\n+\t--c|--co|--com|--comm|--commi|--commit)\n+\t\tsquash= no_commit= ;;\n \t--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)\n-\t\tno_commit=t ;;\n+\t\tsquash= no_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)\ndiff --git a/t/t7600-merge.sh b/t/t7600-merge.sh\nindex e99b5d9..75b0ee4 100755\n--- a/t/t7600-merge.sh\n+++ b/t/t7600-merge.sh\n@@ -377,4 +377,20 @@ test_expect_success 'override config option --summary' '\n \tfi\n '\n \n+test_expect_success 'merge c1 with c2 (override --no-commit)' '\n+\tgit reset --hard c1 &&\n+\tgit config branch.master.mergeoptions \"--no-commit\" &&\n+\tgit merge --commit c2 &&\n+\ttest \"$c1\" = \"$(git rev-parse HEAD^1)\" &&\n+\ttest \"$c2\" = \"$(git rev-parse HEAD^2)\"\n+'\n+\n+test_expect_success 'merge c1 with c2 (override --squash)' '\n+\tgit reset --hard c1 &&\n+\tgit config branch.master.mergeoptions \"--squash\" &&\n+\tgit merge --commit c2 &&\n+\ttest \"$c1\" = \"$(git rev-parse HEAD^1)\" &&\n+\ttest \"$c2\" = \"$(git rev-parse HEAD^2)\"\n+'\n+\n test_done\n-- \n1.5.3.2.82.g75c8d\n"},{"id":"53778","messageId":"1190421186-21784-6-git-send-email-hjemli@gmail.com","threadId":"9973","inReplyTo":"1190421186-21784-5-git-send-email-hjemli@gmail.com","subject":"[PATCH 5/5] git-merge: add --ff and --no-ff options","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-22T00:33:06Z","receivedAt":"2007-09-22T00:33:06Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"These new options can be used to control the policy for fast-forward\nmerges: --ff allows it (this is the default) while --no-ff will create\na merge commit.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n Documentation/merge-options.txt |    9 +++++++++\n git-merge.sh                    |   20 +++++++++++++++-----\n t/t7600-merge.sh                |   18 ++++++++++++++++++\n 3 files changed, 42 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt\nindex 9be90b5..b6c4dc4 100644\n--- a/Documentation/merge-options.txt\n+++ b/Documentation/merge-options.txt\n@@ -23,6 +23,15 @@\n \ttop of the current branch whose effect is the same as\n \tmerging another branch (or more in case of an octopus).\n \n+--no-ff::\n+\tGenerate a merge commit even if the merge resolved as a\n+\tfast-forward.\n+\n+--ff::\n+\tDo not generate a merge commit if the merge resolved as\n+\ta fast-forward, only update the branch pointer. This is\n+\tthe default behavior of git-merge.\n+\n -s <strategy>, \\--strategy=<strategy>::\n \tUse the given merge strategy; can be supplied more than\n \tonce to specify them in the order they should be tried.\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 73ff130..daa95a1 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -3,7 +3,7 @@\n # Copyright (c) 2005 Junio C Hamano\n #\n \n-USAGE='[-n] [--summary] [--[no-]commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'\n+USAGE='[-n] [--summary] [--[no-]commit] [--squash] [--[no-]ff] -s <strategy>] [-m=<merge-message>] <commit>+'\n \n SUBDIRECTORY_OK=Yes\n . git-sh-setup\n@@ -127,11 +127,15 @@ parse_option () {\n \t--summary)\n \t\tshow_diffstat=t ;;\n \t--sq|--squ|--squa|--squas|--squash)\n-\t\tsquash=t no_commit=t ;;\n+\t\tallow_fast_forward=t squash=t no_commit=t ;;\n \t--c|--co|--com|--comm|--commi|--commit)\n-\t\tsquash= no_commit= ;;\n+\t\tallow_fast_forward=t squash= no_commit= ;;\n \t--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)\n-\t\tsquash= no_commit=t ;;\n+\t\tallow_fast_forward=t squash= no_commit=t ;;\n+\t--ff)\n+\t\tallow_fast_forward=t squash= no_commit= ;;\n+\t--no-ff)\n+\t\tallow_fast_forward=false squash= 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@@ -470,7 +474,13 @@ done\n # auto resolved the merge cleanly.\n if test '' != \"$result_tree\"\n then\n-    parents=$(git show-branch --independent \"$head\" \"$@\" | sed -e 's/^/-p /')\n+    if test \"$allow_fast_forward\" = \"t\"\n+    then\n+        parents=$(git show-branch --independent \"$head\" \"$@\")\n+    else\n+        parents=$(git rev-parse \"$head\" \"$@\")\n+    fi\n+    parents=$(echo \"$parents\" | sed -e 's/^/-p /')\n     result_commit=$(printf '%s\\n' \"$merge_msg\" | git commit-tree $result_tree $parents) || exit\n     finish \"$result_commit\" \"Merge made by $wt_strategy.\"\n     dropsave\ndiff --git a/t/t7600-merge.sh b/t/t7600-merge.sh\nindex 75b0ee4..6e16a28 100755\n--- a/t/t7600-merge.sh\n+++ b/t/t7600-merge.sh\n@@ -393,4 +393,22 @@ test_expect_success 'merge c1 with c2 (override --squash)' '\n \ttest \"$c2\" = \"$(git rev-parse HEAD^2)\"\n '\n \n+test_expect_success 'merge c0 with c1 (no-ff)' '\n+\tgit reset --hard c0 &&\n+\tgit merge --no-ff c1 &&\n+\ttest \"$c0\" = \"$(git rev-parse HEAD^1)\" &&\n+\ttest \"$c1\" = \"$(git rev-parse HEAD^2)\"\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '\n+\tgit reset --hard c0 &&\n+\tgit config branch.master.mergeoptions \"--no-ff\" &&\n+\tgit merge --ff c1 &&\n+\ttest \"$c1\" = \"$(git rev-parse HEAD)\"\n+'\n+\n+test_debug 'gitk --all'\n+\n test_done\n-- \n1.5.3.2.82.g75c8d\n"},{"id":"53816","messageId":"7vwsuidx1a.fsf@gitster.siamese.dyndns.org","threadId":"9973","inReplyTo":"1190421186-21784-2-git-send-email-hjemli@gmail.com","subject":"Re: [PATCH 1/5] Add test-script for git-merge porcelain","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-23T00:51:13Z","receivedAt":"2007-09-23T00:51:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> writes:\n\n> This test-script tries to excercise the porcelainish aspects of git-merge.\n\nIt does exercise; no need for \"tries to\" ;-).\n\n> +test_expect_success 'verify merge result' '\n> +\techo \"\n> +1 X\n> +2\n> +3\n> +4\n> +5\n> +6\n> +7\n> +8\n> +9\n> +\" > result.1 &&\n> +\tcmp -s file result.1\n> +'\n\nUnless there is a compelling reason otherwise, I'd prefer tests\nwith a test vector like this to be spelled like this:\n\n\tdiff -u result.1 file\n\nThat is, compare to show the difference actual output might have\nfrom the expected result.  It's easier to spot the difference\nwhen you later break things this way.\n\n> +test_expect_success 'merge c1 with c2' '\n> +\tgit reset --hard c1 &&\n> +\tgit merge c2 &&\n> +\ttest \"$c1\" = \"$(git rev-parse HEAD^1)\" &&\n> +\ttest \"$c2\" = \"$(git rev-parse HEAD^2)\"\n> +'\n\nWe might also want to test:\n\n - the index is merged;\n\n - the working tree matches the index;\n\n - the merge message (e.g. \"git show -s --pretty=format:%s\n   HEAD\") is as expected;\n\nOtherwise I think it is a good idea to add these tests.\n\nBy the way, I think squash_message() leaves a wrong message\ntemplate for an Octopus, which might be worth fixing.\n"},{"id":"53817","messageId":"7vps0adx0x.fsf@gitster.siamese.dyndns.org","threadId":"9973","inReplyTo":"1190421186-21784-4-git-send-email-hjemli@gmail.com","subject":"Re: [PATCH 3/5] git-merge: add support for branch.<name>.mergeoptions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-23T00:51:26Z","receivedAt":"2007-09-23T00:51:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> writes:\n\n> diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt\n> index 144bc16..b1771a1 100644\n> --- a/Documentation/git-merge.txt\n> +++ b/Documentation/git-merge.txt\n> @@ -58,6 +58,10 @@ merge.verbosity::\n>  \tabove outputs debugging information.  The default is level 2.\n>  \tCan be overriden by 'GIT_MERGE_VERBOSITY' environment variable.\n>  \n> +branch.<name>.mergeoptions::\n> +\tSets default options for merging into branch <name>. The syntax and\n> +\tsupported options are equal to that of git-merge, but option values\n> +\tcontaining whitespace characters are currently not supported.\n\nI think this is a sensible thing to do in general.\n\n> +branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')\n> +mergeopts=$(git config \"branch.$branch.mergeoptions\")\n> +parse_config $mergeopts\n\nWhat should happen when your head is detached?\n"},{"id":"53818","messageId":"7vir62dx0u.fsf@gitster.siamese.dyndns.org","threadId":"9973","inReplyTo":"1190421186-21784-5-git-send-email-hjemli@gmail.com","subject":"Re: [PATCH 4/5] git-merge: add support for --commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-23T00:51:29Z","receivedAt":"2007-09-23T00:51:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> writes:\n\n> This option can be used to override --no-commit and --squash. The change\n> also introduces slightly different behavior for --no-commit: when specified,\n> it explicitly overrides --squash.\n\nMakes me wonder if --no-squash also make sense to override a --squash.\nIs this really needed?  IOW, does it ever make sense to have --no-commit\nin the configuration?\n"},{"id":"53829","messageId":"8c5c35580709230324m65c5399ds8c7ce21df4461e66@mail.gmail.com","threadId":"9973","inReplyTo":"7vwsuidx1a.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/5] Add test-script for git-merge porcelain","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-23T10:24:03Z","receivedAt":"2007-09-23T10:24:03Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 9/23/07, Junio C Hamano <gitster@pobox.com> wrote:\n> Lars Hjemli <hjemli@gmail.com> writes:\n>\n> > This test-script tries to excercise the porcelainish aspects of git-merge.\n>\n> It does exercise; no need for \"tries to\" ;-).\n\nHeh, ok\n\n> > +     cmp -s file result.1\n> > +'\n>\n> Unless there is a compelling reason otherwise, I'd prefer tests\n> with a test vector like this to be spelled like this:\n>\n>         diff -u result.1 file\n>\n> That is, compare to show the difference actual output might have\n> from the expected result.  It's easier to spot the difference\n> when you later break things this way.\n\nGood point, I'll change it.\n\n>\n> > +test_expect_success 'merge c1 with c2' '\n> > +     git reset --hard c1 &&\n> > +     git merge c2 &&\n> > +     test \"$c1\" = \"$(git rev-parse HEAD^1)\" &&\n> > +     test \"$c2\" = \"$(git rev-parse HEAD^2)\"\n> > +'\n>\n> We might also want to test:\n>\n>  - the index is merged;\n>\n>  - the working tree matches the index;\n>\n>  - the merge message (e.g. \"git show -s --pretty=format:%s\n>    HEAD\") is as expected;\n\nYes, sorry for being lazy ;-)  I'll add more thorough verification\n\n>\n> Otherwise I think it is a good idea to add these tests.\n>\n> By the way, I think squash_message() leaves a wrong message\n> template for an Octopus, which might be worth fixing.\n\nOk, I'll try to detect it in the test-script and send a proper fix.\n\nThanks for the review.\n\n-- \nlarsh\n"},{"id":"53830","messageId":"8c5c35580709230331h459bd07ay8b17146b5feec212@mail.gmail.com","threadId":"9973","inReplyTo":"7vps0adx0x.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/5] git-merge: add support for branch.<name>.mergeoptions","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-23T10:31:23Z","receivedAt":"2007-09-23T10:31:23Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 9/23/07, Junio C Hamano <gitster@pobox.com> wrote:\n> Lars Hjemli <hjemli@gmail.com> writes:\n> > +branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')\n> > +mergeopts=$(git config \"branch.$branch.mergeoptions\")\n> > +parse_config $mergeopts\n>\n> What should happen when your head is detached?\n>\n\nMy plan was 'nothing', but I should have tested it (it does work, but\nalso prints an ugly \"fatal: ref HEAD is not a symbolic ref\").\n\n-- \nlarsh\n"},{"id":"53831","messageId":"8c5c35580709230335w2b4dcfe8xa05d50312cc2f6c3@mail.gmail.com","threadId":"9973","inReplyTo":"7vir62dx0u.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 4/5] git-merge: add support for --commit","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-23T10:35:54Z","receivedAt":"2007-09-23T10:35:54Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 9/23/07, Junio C Hamano <gitster@pobox.com> wrote:\n> Lars Hjemli <hjemli@gmail.com> writes:\n>\n> > This option can be used to override --no-commit and --squash. The change\n> > also introduces slightly different behavior for --no-commit: when specified,\n> > it explicitly overrides --squash.\n>\n> Makes me wonder if --no-squash also make sense to override a --squash.\n> Is this really needed?  IOW, does it ever make sense to have --no-commit\n> in the configuration?\n>\n\nActually, I did add --no-squash but the semantics (and implementation)\nwas identical to --commit so I decided it wasn't worth it (but maybe\nit is - just to avoid user confusion?).\n\n-- \nlarsh\n"},{"id":"53849","messageId":"7vr6kpchny.fsf@gitster.siamese.dyndns.org","threadId":"9973","inReplyTo":"8c5c35580709230331h459bd07ay8b17146b5feec212@mail.gmail.com","subject":"Re: [PATCH 3/5] git-merge: add support for branch.<name>.mergeoptions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-23T19:20:49Z","receivedAt":"2007-09-23T19:20:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lars Hjemli\" <hjemli@gmail.com> writes:\n\n> On 9/23/07, Junio C Hamano <gitster@pobox.com> wrote:\n>> Lars Hjemli <hjemli@gmail.com> writes:\n>> > +branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')\n>> > +mergeopts=$(git config \"branch.$branch.mergeoptions\")\n>> > +parse_config $mergeopts\n>>\n>> What should happen when your head is detached?\n>>\n>\n> My plan was 'nothing', but I should have tested it (it does work, but\n> also prints an ugly \"fatal: ref HEAD is not a symbolic ref\").\n\nThat, and also running \"git config branch..mergeoptions\" and\nexpect it does not change behaviour to issue more strict\nwarning, are both not so good.  Perhaps the code needs to be\nmore defensive like:\n\n    if branch=$(git symbolic-ref -q HEAD)\n    then\n        mergeopts=$(git config \"branch.${branch#refs/heads/}.mergeoptions\")\n\tif test -n \"$mergeopts\"\n        then\n\t    parse_config $mergeopts\n\tfi\n    fi\n\n\n \n"},{"id":"53851","messageId":"8c5c35580709231233k1e24e36ayf294483d67096058@mail.gmail.com","threadId":"9973","inReplyTo":"7vr6kpchny.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/5] git-merge: add support for branch.<name>.mergeoptions","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-23T19:33:15Z","receivedAt":"2007-09-23T19:33:15Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 9/23/07, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Lars Hjemli\" <hjemli@gmail.com> writes:\n>\n> > On 9/23/07, Junio C Hamano <gitster@pobox.com> wrote:\n> >> Lars Hjemli <hjemli@gmail.com> writes:\n> >> > +branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')\n> >> > +mergeopts=$(git config \"branch.$branch.mergeoptions\")\n> >> > +parse_config $mergeopts\n> >>\n> >> What should happen when your head is detached?\n> >>\n> >\n> > My plan was 'nothing', but I should have tested it (it does work, but\n> > also prints an ugly \"fatal: ref HEAD is not a symbolic ref\").\n>\n> That, and also running \"git config branch..mergeoptions\" and\n> expect it does not change behaviour to issue more strict\n> warning, are both not so good.  Perhaps the code needs to be\n> more defensive like:\n>\n>     if branch=$(git symbolic-ref -q HEAD)\n>     then\n>         mergeopts=$(git config \"branch.${branch#refs/heads/}.mergeoptions\")\n>         if test -n \"$mergeopts\"\n>         then\n>             parse_config $mergeopts\n>         fi\n>     fi\n\nYes, this is much better (and the ${parameter#word} syntax was nice too).\n\nThanks.\n\n--\nlarsh\n"}]}