{"thread":{"id":"45515","subject":"[PATCH] contrib/subtree: add \"--no-commit\" flag for merge and pull","startedAt":"2017-03-26T07:12:18Z","lastAt":"2017-03-29T07:57:09Z","messageCount":3,"participants":["Mike Lewis","David Aguilar"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"315452","messageId":"20170326070238.64522-1-mike@mplew.is","threadId":"45515","inReplyTo":null,"subject":"[PATCH] contrib/subtree: add \"--no-commit\" flag for merge and pull","fromName":"Mike Lewis","fromEmail":"mike@mplew.is","sentAt":"2017-03-26T07:02:38Z","receivedAt":"2017-03-26T07:12:18Z","isPatch":true,"sender":{"key":"mike@mplew.is","avatar":null},"body":"Allows the user to verify and/or change the contents of the merge\nbefore committing as necessary\n\nSigned-off-by: Mike Lewis <mike@mplew.is>\n---\n contrib/subtree/git-subtree.sh | 17 +++++++++++++----\n 1 file changed, 13 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex dec085a23..c30087485 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -29,6 +29,8 @@ onto=         try connecting new tree to an existing one\n rejoin        merge the new branch back into HEAD\n  options for 'add', 'merge', and 'pull'\n squash        merge subtree changes as a single commit\n+ options for 'merge' and 'pull'\n+no-commit     perform the merge, but don't commit\n \"\n eval \"$(echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?)\"\n \n@@ -48,6 +50,7 @@ annotate=\n squash=\n message=\n prefix=\n+commit_option=\"--commit\"\n \n debug () {\n \tif test -n \"$debug\"\n@@ -137,6 +140,12 @@ do\n \t--no-squash)\n \t\tsquash=\n \t\t;;\n+\t--no-commit)\n+\t\tcommit_option=\"--no-commit\"\n+\t\t;;\n+\t--no-no-commit)\n+\t\tcommit_option=\"--commit\"\n+\t\t;;\n \t--)\n \t\tbreak\n \t\t;;\n@@ -815,17 +824,17 @@ cmd_merge () {\n \tthen\n \t\tif test -n \"$message\"\n \t\tthen\n-\t\t\tgit merge -s subtree --message=\"$message\" \"$rev\"\n+\t\t\tgit merge -s subtree --message=\"$message\" \"$commit_option\" \"$rev\"\n \t\telse\n-\t\t\tgit merge -s subtree \"$rev\"\n+\t\t\tgit merge -s subtree \"$commit_option\" \"$rev\"\n \t\tfi\n \telse\n \t\tif test -n \"$message\"\n \t\tthen\n \t\t\tgit merge -Xsubtree=\"$prefix\" \\\n-\t\t\t\t--message=\"$message\" \"$rev\"\n+\t\t\t\t--message=\"$message\" \"$commit_option\" \"$rev\"\n \t\telse\n-\t\t\tgit merge -Xsubtree=\"$prefix\" $rev\n+\t\t\tgit merge -Xsubtree=\"$prefix\" \"$commit_option\" $rev\n \t\tfi\n \tfi\n }\n-- \n2.12.2\n\n"},{"id":"315653","messageId":"20170329073704.vhya5gkwg7j5kchb@gmail.com","threadId":"45515","inReplyTo":"20170326070238.64522-1-mike@mplew.is","subject":"Re: [PATCH] contrib/subtree: add \"--no-commit\" flag for merge and pull","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2017-03-29T07:37:04Z","receivedAt":"2017-03-29T07:37:24Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Sun, Mar 26, 2017 at 03:02:38AM -0400, Mike Lewis wrote:\n> Allows the user to verify and/or change the contents of the merge\n> before committing as necessary\n> \n> Signed-off-by: Mike Lewis <mike@mplew.is>\n> ---\n>  contrib/subtree/git-subtree.sh | 17 +++++++++++++----\n>  1 file changed, 13 insertions(+), 4 deletions(-)\n> \n> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\n> index dec085a23..c30087485 100755\n> --- a/contrib/subtree/git-subtree.sh\n> +++ b/contrib/subtree/git-subtree.sh\n> @@ -29,6 +29,8 @@ onto=         try connecting new tree to an existing one\n>  rejoin        merge the new branch back into HEAD\n>   options for 'add', 'merge', and 'pull'\n>  squash        merge subtree changes as a single commit\n> + options for 'merge' and 'pull'\n> +no-commit     perform the merge, but don't commit\n>  \"\n>  eval \"$(echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?)\"\n>  \n> @@ -48,6 +50,7 @@ annotate=\n>  squash=\n>  message=\n>  prefix=\n> +commit_option=\"--commit\"\n\nIt might be simpler to default commit_option= empty like the others, and\nremove the \"\" double quotes around \"$commit_option\" indicated below so\nthat the shell ignores it when it's empty.\n\n>  \n>  debug () {\n>  \tif test -n \"$debug\"\n> @@ -137,6 +140,12 @@ do\n>  \t--no-squash)\n>  \t\tsquash=\n>  \t\t;;\n> +\t--no-commit)\n> +\t\tcommit_option=\"--no-commit\"\n> +\t\t;;\n> +\t--no-no-commit)\n> +\t\tcommit_option=\"--commit\"\n> +\t\t;;\n\n\"--no-no-commit\" should just be \"--commit\" instead.\nThe real flag is called \"--commit\" (git help merge), so subtree\nshould follow suite by supporting \"--commit\" and \"--no-commit\" only.\n\n\n> @@ -815,17 +824,17 @@ cmd_merge () {\n>  \tthen\n>  \t\tif test -n \"$message\"\n>  \t\tthen\n> -\t\t\tgit merge -s subtree --message=\"$message\" \"$rev\"\n> +\t\t\tgit merge -s subtree --message=\"$message\" \"$commit_option\" \"$rev\"\n                                                                  ^              ^\n>  \t\telse\n> -\t\t\tgit merge -s subtree \"$rev\"\n> +\t\t\tgit merge -s subtree \"$commit_option\" \"$rev\"\n                                             ^              ^\n>  \t\tfi\n>  [...]\n\n-- \nDavid\n"},{"id":"315654","messageId":"E240B4F0-41D3-4FDB-A2BE-B085CCAAA5B1@mplew.is","threadId":"45515","inReplyTo":"20170329073704.vhya5gkwg7j5kchb@gmail.com","subject":"Re: [PATCH] contrib/subtree: add \"--no-commit\" flag for merge and pull","fromName":"Mike Lewis","fromEmail":"mike@mplew.is","sentAt":"2017-03-29T07:56:57Z","receivedAt":"2017-03-29T07:57:09Z","isPatch":true,"sender":{"key":"mike@mplew.is","avatar":null},"body":"I had defaulted it to \"--commit\" just to make it absolutely clear what the default was going to be, since passing the \"--commit\" flag to `git-merge` in this case doesn’t change the existing behavior. But you’re right that having the default be blank matches the existing style better, so I’ll make a new patch.\n\nRegarding the \"--no-no-commit\"  I definitely agree it should be that way, and my first attempt at this had it that way. However, `git rev-parse --parseopt` seems to rewrite \"--commit\" to \"--no-no-commit\" when it detects the \"no-commit\" option in the $OPTS_SPEC variable. Essentially, you still type the argument as \"--commit\", but it’s rewritten to \"--no-no-commit\" before it gets to the argument case block, as \"no-commit\" is the only documented option. Documenting both the \"--commit\" and \"--no-commit\" options in $OPTS_SPEC leads to the expected resulting argument, but I wasn't sure if both arguments should be documented, as none of the other \"default\" options (for instance, \"--no-squash\") are documented in the help output. But please let me know what your thoughts are, and I'll gladly update my patch.\n\nMike Lewis\n\n> On 29 Mar 2017, at 03:37, David Aguilar <davvid@gmail.com> wrote:\n> \n> On Sun, Mar 26, 2017 at 03:02:38AM -0400, Mike Lewis wrote:\n>> Allows the user to verify and/or change the contents of the merge\n>> before committing as necessary\n>> \n>> Signed-off-by: Mike Lewis <mike@mplew.is>\n>> ---\n>> contrib/subtree/git-subtree.sh | 17 +++++++++++++----\n>> 1 file changed, 13 insertions(+), 4 deletions(-)\n>> \n>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\n>> index dec085a23..c30087485 100755\n>> --- a/contrib/subtree/git-subtree.sh\n>> +++ b/contrib/subtree/git-subtree.sh\n>> @@ -29,6 +29,8 @@ onto=         try connecting new tree to an existing one\n>> rejoin        merge the new branch back into HEAD\n>>  options for 'add', 'merge', and 'pull'\n>> squash        merge subtree changes as a single commit\n>> + options for 'merge' and 'pull'\n>> +no-commit     perform the merge, but don't commit\n>> \"\n>> eval \"$(echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?)\"\n>> \n>> @@ -48,6 +50,7 @@ annotate=\n>> squash=\n>> message=\n>> prefix=\n>> +commit_option=\"--commit\"\n> \n> It might be simpler to default commit_option= empty like the others, and\n> remove the \"\" double quotes around \"$commit_option\" indicated below so\n> that the shell ignores it when it's empty.\n> \n>> \n>> debug () {\n>> \tif test -n \"$debug\"\n>> @@ -137,6 +140,12 @@ do\n>> \t--no-squash)\n>> \t\tsquash=\n>> \t\t;;\n>> +\t--no-commit)\n>> +\t\tcommit_option=\"--no-commit\"\n>> +\t\t;;\n>> +\t--no-no-commit)\n>> +\t\tcommit_option=\"--commit\"\n>> +\t\t;;\n> \n> \"--no-no-commit\" should just be \"--commit\" instead.\n> The real flag is called \"--commit\" (git help merge), so subtree\n> should follow suite by supporting \"--commit\" and \"--no-commit\" only.\n> \n> \n>> @@ -815,17 +824,17 @@ cmd_merge () {\n>> \tthen\n>> \t\tif test -n \"$message\"\n>> \t\tthen\n>> -\t\t\tgit merge -s subtree --message=\"$message\" \"$rev\"\n>> +\t\t\tgit merge -s subtree --message=\"$message\" \"$commit_option\" \"$rev\"\n>                                                                  ^              ^\n>> \t\telse\n>> -\t\t\tgit merge -s subtree \"$rev\"\n>> +\t\t\tgit merge -s subtree \"$commit_option\" \"$rev\"\n>                                             ^              ^\n>> \t\tfi\n>> [...]\n> \n> -- \n> David\n\n"}]}