{"thread":{"id":"31772","subject":"[PATCH] Add --unannotate option to git-subtree","startedAt":"2012-10-09T20:26:50Z","lastAt":"2013-01-22T08:41:02Z","messageCount":7,"participants":["James Nylen","Herman van Rink","greened@obbligato.org"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"200855","messageId":"CABVa4NinSighUn7GKbzMx9qZj3Ao2dCtEZxUqCPwO9TocZ8Kkg@mail.gmail.com","threadId":"31772","inReplyTo":null,"subject":"[PATCH] Add --unannotate option to git-subtree","fromName":"James Nylen","fromEmail":"jnylen@gmail.com","sentAt":"2012-10-09T20:26:50Z","receivedAt":"2012-10-09T20:26:50Z","isPatch":true,"sender":{"key":"jnylen@gmail.com","avatar":"https://gravatar.com/avatar/96804ac655933f5b6380e992610d6ff9029c6d04db1042d4bec381312ff7ff1b?d=mp&s=160"},"body":"This new option does the reverse of --annotate, which is more useful\nwhen contributing back to a library which is also included in the\nrepository for a larger project, and perhaps in other situations as\nwell.\n\nRather than adding a marker to each commit when splitting out the\ncommits back to the subproject, --unannotate removes the specified\nstring (or bash glob pattern) from the beginning of the first line of\nthe commit message.  This enables the following workflow:\n\n - Commit to a library included in a large project, with message:\n     Library: Make some amazing change\n\n - Use `git-subtree split` to send this change to the library maintainer\n\n - Pass ` --unannotate='Library: ' ` or ` --unannotate='*: ' `\n\n - This will turn the commit message for the library project into:\n     Make some amazing change\n\nThis helps to keep the commit messages meaningful in both the large\nproject and the library project.\n\nSigned-off-by: James Nylen <jnylen@gmail.com>\n---\nLet me know if gmail has munged this patch.  You can also get at it\nlike this:\n\n$ git remote add nylen git://github.com/nylen/git.git\n$ git fetch nylen\n$ git show nylen/subtree-unannotate\n---\n contrib/subtree/git-subtree.sh  | 11 +++++++++--\n contrib/subtree/git-subtree.txt | 15 +++++++++++++++\n 2 files changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 920c664..8d1ed05 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -21,6 +21,7 @@ P,prefix=     the name of the subdir to split out\n m,message=    use the given message as the commit message for the merge commit\n  options for 'split'\n annotate=     add a prefix to commit message of new commits\n+unannotate=   remove a prefix from new commit messages (supports bash globbing)\n b,branch=     create a new branch from the split subtree\n ignore-joins  ignore prior --rejoin commits\n onto=         try connecting new tree to an existing one\n@@ -43,6 +44,7 @@ onto=\n rejoin=\n ignore_joins=\n annotate=\n+unannotate=\n squash=\n message=\n\n@@ -80,6 +82,8 @@ while [ $# -gt 0 ]; do\n \t\t-d) debug=1 ;;\n \t\t--annotate) annotate=\"$1\"; shift ;;\n \t\t--no-annotate) annotate= ;;\n+\t\t--unannotate) unannotate=\"$1\"; shift ;;\n+\t\t--no-unannotate) unannotate= ;;\n \t\t-b) branch=\"$1\"; shift ;;\n \t\t-P) prefix=\"$1\"; shift ;;\n \t\t-m) message=\"$1\"; shift ;;\n@@ -310,8 +314,11 @@ copy_commit()\n \t\t\tGIT_COMMITTER_NAME \\\n \t\t\tGIT_COMMITTER_EMAIL \\\n \t\t\tGIT_COMMITTER_DATE\n-\t\t(echo -n \"$annotate\"; cat ) |\n-\t\tgit commit-tree \"$2\" $3  # reads the rest of stdin\n+\t\t(\n+\t\t\tread FIRST_LINE\n+\t\t\techo \"$annotate${FIRST_LINE#$unannotate}\"\n+\t\t\tcat  # reads the rest of stdin\n+\t\t) | git commit-tree \"$2\" $3\n \t) || die \"Can't copy commit $1\"\n }\n\ndiff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt\nindex 0c44fda..ae420aa 100644\n--- a/contrib/subtree/git-subtree.txt\n+++ b/contrib/subtree/git-subtree.txt\n@@ -198,6 +198,21 @@ OPTIONS FOR split\n \tgit subtree tries to make it work anyway, particularly\n \tif you use --rejoin, but it may not always be effective.\n\n+--unannotate=<annotation>::\n+\tThis option is only valid for the split command.\n+\n+\tWhen generating synthetic history, try to remove the prefix\n+\t<annotation> from each commit message (using bash's \"strip\n+\tshortest match from beginning\" command, which supports\n+\tglobbing).  This makes sense if you format library commits\n+\tlike \"library: Change something or other\" when you're working\n+\tin your project's repository, but you want to remove this\n+\tprefix when pushing back to the library's upstream repository.\n+\t(In this case --unannotate='*: ' would work well.)\n+\t\n+\tLike --annotate,  you need to use the same <annotation>\n+\twhenever you split, or you may run into problems.\n+\n -b <branch>::\n --branch=<branch>::\n \tThis option is only valid for the split command.\n-- \n1.7.11.3\n"},{"id":"201331","messageId":"CABVa4NgdaiwfTvFe1CU+24QF-BA45tM2e3+9e2PJ_4ecuD0Cyg@mail.gmail.com","threadId":"31772","inReplyTo":"CABVa4NinSighUn7GKbzMx9qZj3Ao2dCtEZxUqCPwO9TocZ8Kkg@mail.gmail.com","subject":"Re: [PATCH] Add --unannotate option to git-subtree","fromName":"James Nylen","fromEmail":"jnylen@gmail.com","sentAt":"2012-10-16T12:47:09Z","receivedAt":"2012-10-16T12:47:09Z","isPatch":true,"sender":{"key":"jnylen@gmail.com","avatar":"https://gravatar.com/avatar/96804ac655933f5b6380e992610d6ff9029c6d04db1042d4bec381312ff7ff1b?d=mp&s=160"},"body":"On Tue, Oct 9, 2012 at 4:26 PM, James Nylen <jnylen@gmail.com> wrote:\n> This new option does the reverse of --annotate, which is more useful\n> when contributing back to a library which is also included in the\n> repository for a larger project, and perhaps in other situations as\n> well.\n>\n> Rather than adding a marker to each commit when splitting out the\n> commits back to the subproject, --unannotate removes the specified\n> string (or bash glob pattern) from the beginning of the first line of\n> the commit message.  This enables the following workflow:\n>\n>  - Commit to a library included in a large project, with message:\n>      Library: Make some amazing change\n>\n>  - Use `git-subtree split` to send this change to the library maintainer\n>\n>  - Pass ` --unannotate='Library: ' ` or ` --unannotate='*: ' `\n>\n>  - This will turn the commit message for the library project into:\n>      Make some amazing change\n>\n> This helps to keep the commit messages meaningful in both the large\n> project and the library project.\n>\n> Signed-off-by: James Nylen <jnylen@gmail.com>\n> ---\n\nHas anybody looked at this?\n\nIt has been very useful for me.\n\n> Let me know if gmail has munged this patch.  You can also get at it\n> like this:\n>\n> $ git remote add nylen git://github.com/nylen/git.git\n> $ git fetch nylen\n> $ git show nylen/subtree-unannotate\n> ---\n>  contrib/subtree/git-subtree.sh  | 11 +++++++++--\n>  contrib/subtree/git-subtree.txt | 15 +++++++++++++++\n>  2 files changed, 24 insertions(+), 2 deletions(-)\n>\n> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\n> index 920c664..8d1ed05 100755\n> --- a/contrib/subtree/git-subtree.sh\n> +++ b/contrib/subtree/git-subtree.sh\n> @@ -21,6 +21,7 @@ P,prefix=     the name of the subdir to split out\n>  m,message=    use the given message as the commit message for the merge commit\n>   options for 'split'\n>  annotate=     add a prefix to commit message of new commits\n> +unannotate=   remove a prefix from new commit messages (supports bash globbing)\n>  b,branch=     create a new branch from the split subtree\n>  ignore-joins  ignore prior --rejoin commits\n>  onto=         try connecting new tree to an existing one\n> @@ -43,6 +44,7 @@ onto=\n>  rejoin=\n>  ignore_joins=\n>  annotate=\n> +unannotate=\n>  squash=\n>  message=\n>\n> @@ -80,6 +82,8 @@ while [ $# -gt 0 ]; do\n>                 -d) debug=1 ;;\n>                 --annotate) annotate=\"$1\"; shift ;;\n>                 --no-annotate) annotate= ;;\n> +               --unannotate) unannotate=\"$1\"; shift ;;\n> +               --no-unannotate) unannotate= ;;\n>                 -b) branch=\"$1\"; shift ;;\n>                 -P) prefix=\"$1\"; shift ;;\n>                 -m) message=\"$1\"; shift ;;\n> @@ -310,8 +314,11 @@ copy_commit()\n>                         GIT_COMMITTER_NAME \\\n>                         GIT_COMMITTER_EMAIL \\\n>                         GIT_COMMITTER_DATE\n> -               (echo -n \"$annotate\"; cat ) |\n> -               git commit-tree \"$2\" $3  # reads the rest of stdin\n> +               (\n> +                       read FIRST_LINE\n> +                       echo \"$annotate${FIRST_LINE#$unannotate}\"\n> +                       cat  # reads the rest of stdin\n> +               ) | git commit-tree \"$2\" $3\n>         ) || die \"Can't copy commit $1\"\n>  }\n>\n> diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt\n> index 0c44fda..ae420aa 100644\n> --- a/contrib/subtree/git-subtree.txt\n> +++ b/contrib/subtree/git-subtree.txt\n> @@ -198,6 +198,21 @@ OPTIONS FOR split\n>         git subtree tries to make it work anyway, particularly\n>         if you use --rejoin, but it may not always be effective.\n>\n> +--unannotate=<annotation>::\n> +       This option is only valid for the split command.\n> +\n> +       When generating synthetic history, try to remove the prefix\n> +       <annotation> from each commit message (using bash's \"strip\n> +       shortest match from beginning\" command, which supports\n> +       globbing).  This makes sense if you format library commits\n> +       like \"library: Change something or other\" when you're working\n> +       in your project's repository, but you want to remove this\n> +       prefix when pushing back to the library's upstream repository.\n> +       (In this case --unannotate='*: ' would work well.)\n> +\n> +       Like --annotate,  you need to use the same <annotation>\n> +       whenever you split, or you may run into problems.\n> +\n>  -b <branch>::\n>  --branch=<branch>::\n>         This option is only valid for the split command.\n> --\n> 1.7.11.3\n"},{"id":"201600","messageId":"5082FC72.4000608@initfour.nl","threadId":"31772","inReplyTo":"CABVa4NgdaiwfTvFe1CU+24QF-BA45tM2e3+9e2PJ_4ecuD0Cyg@mail.gmail.com","subject":"Re: [PATCH] Add --unannotate option to git-subtree","fromName":"Herman van Rink","fromEmail":"rink@initfour.nl","sentAt":"2012-10-20T19:33:06Z","receivedAt":"2012-10-20T19:33:06Z","isPatch":true,"sender":{"key":"rink@initfour.nl","avatar":null},"body":"On 10/16/2012 02:47 PM, James Nylen wrote:\n> On Tue, Oct 9, 2012 at 4:26 PM, James Nylen <jnylen@gmail.com> wrote:\n>> This new option does the reverse of --annotate, which is more useful\n>> when contributing back to a library which is also included in the\n>> repository for a larger project, and perhaps in other situations as\n>> well.\n>>\n>> Rather than adding a marker to each commit when splitting out the\n>> commits back to the subproject, --unannotate removes the specified\n>> string (or bash glob pattern) from the beginning of the first line of\n>> the commit message.  This enables the following workflow:\n>>\n>>  - Commit to a library included in a large project, with message:\n>>      Library: Make some amazing change\n>>\n>>  - Use `git-subtree split` to send this change to the library maintainer\n>>\n>>  - Pass ` --unannotate='Library: ' ` or ` --unannotate='*: ' `\n>>\n>>  - This will turn the commit message for the library project into:\n>>      Make some amazing change\n>>\n>> This helps to keep the commit messages meaningful in both the large\n>> project and the library project.\n>>\n>> Signed-off-by: James Nylen <jnylen@gmail.com>\n>> ---\n> Has anybody looked at this?\n>\n> It has been very useful for me.\n\n\nThe version of subtree in contrib is rather out-dated unfortunately.\nYour patch looks interesting though. I can see how this could be useful.\n\nI've collected a bunch of patches in\nhttps://github.com/helmo/git/tree/subtree-updates\n\nApart from a line in git-subtree.txt ending in whitespace I think I can\nmerge it in there.\n\n>\n>> Let me know if gmail has munged this patch.  You can also get at it\n>> like this:\n>>\n>> $ git remote add nylen git://github.com/nylen/git.git\n>> $ git fetch nylen\n>> $ git show nylen/subtree-unannotate\n>> ---\n>>  contrib/subtree/git-subtree.sh  | 11 +++++++++--\n>>  contrib/subtree/git-subtree.txt | 15 +++++++++++++++\n>>  2 files changed, 24 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\n>> index 920c664..8d1ed05 100755\n>> --- a/contrib/subtree/git-subtree.sh\n>> +++ b/contrib/subtree/git-subtree.sh\n>> @@ -21,6 +21,7 @@ P,prefix=     the name of the subdir to split out\n>>  m,message=    use the given message as the commit message for the merge commit\n>>   options for 'split'\n>>  annotate=     add a prefix to commit message of new commits\n>> +unannotate=   remove a prefix from new commit messages (supports bash globbing)\n>>  b,branch=     create a new branch from the split subtree\n>>  ignore-joins  ignore prior --rejoin commits\n>>  onto=         try connecting new tree to an existing one\n>> @@ -43,6 +44,7 @@ onto=\n>>  rejoin=\n>>  ignore_joins=\n>>  annotate=\n>> +unannotate=\n>>  squash=\n>>  message=\n>>\n>> @@ -80,6 +82,8 @@ while [ $# -gt 0 ]; do\n>>                 -d) debug=1 ;;\n>>                 --annotate) annotate=\"$1\"; shift ;;\n>>                 --no-annotate) annotate= ;;\n>> +               --unannotate) unannotate=\"$1\"; shift ;;\n>> +               --no-unannotate) unannotate= ;;\n>>                 -b) branch=\"$1\"; shift ;;\n>>                 -P) prefix=\"$1\"; shift ;;\n>>                 -m) message=\"$1\"; shift ;;\n>> @@ -310,8 +314,11 @@ copy_commit()\n>>                         GIT_COMMITTER_NAME \\\n>>                         GIT_COMMITTER_EMAIL \\\n>>                         GIT_COMMITTER_DATE\n>> -               (echo -n \"$annotate\"; cat ) |\n>> -               git commit-tree \"$2\" $3  # reads the rest of stdin\n>> +               (\n>> +                       read FIRST_LINE\n>> +                       echo \"$annotate${FIRST_LINE#$unannotate}\"\n>> +                       cat  # reads the rest of stdin\n>> +               ) | git commit-tree \"$2\" $3\n>>         ) || die \"Can't copy commit $1\"\n>>  }\n>>\n>> diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt\n>> index 0c44fda..ae420aa 100644\n>> --- a/contrib/subtree/git-subtree.txt\n>> +++ b/contrib/subtree/git-subtree.txt\n>> @@ -198,6 +198,21 @@ OPTIONS FOR split\n>>         git subtree tries to make it work anyway, particularly\n>>         if you use --rejoin, but it may not always be effective.\n>>\n>> +--unannotate=<annotation>::\n>> +       This option is only valid for the split command.\n>> +\n>> +       When generating synthetic history, try to remove the prefix\n>> +       <annotation> from each commit message (using bash's \"strip\n>> +       shortest match from beginning\" command, which supports\n>> +       globbing).  This makes sense if you format library commits\n>> +       like \"library: Change something or other\" when you're working\n>> +       in your project's repository, but you want to remove this\n>> +       prefix when pushing back to the library's upstream repository.\n>> +       (In this case --unannotate='*: ' would work well.)\n>> +\n>> +       Like --annotate,  you need to use the same <annotation>\n>> +       whenever you split, or you may run into problems.\n>> +\n>>  -b <branch>::\n>>  --branch=<branch>::\n>>         This option is only valid for the split command.\n>> --\n>> 1.7.11.3\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n\n-- \n\nMet vriendelijke groet / Regards,\n\nHerman van Rink\nInitfour websolutions\n"},{"id":"205710","messageId":"87ehi54xnx.fsf@waller.obbligato.org","threadId":"31772","inReplyTo":"5082FC72.4000608@initfour.nl","subject":"Re: [PATCH] Add --unannotate option to git-subtree","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2012-12-31T23:19:46Z","receivedAt":"2012-12-31T23:19:46Z","isPatch":true,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"Herman van Rink <rink@initfour.nl> writes:\n\n>> Has anybody looked at this?\n>>\n>> It has been very useful for me.\n\nI am looking at it now.\n\n> The version of subtree in contrib is rather out-dated unfortunately.\n\nIt is the official version.  What's missing?  You have a bunch of\nchanges that need rework to include into \"mainline\" but other than that\nI am not aware of any major missing pieces.  If there are such changes I\nwould very much like to get them integrated\n\n> Your patch looks interesting though. I can see how this could be useful.\n\n> I've collected a bunch of patches in\n> https://github.com/helmo/git/tree/subtree-updates\n\nI hope you will submit your changes for inclusion.  Again, I'm not a\ngatekeeper but I do want the patches to have proper testcases and\nintegrate into contrib/subtree.\n\n                         -David\n"},{"id":"205718","messageId":"87a9st4sb8.fsf@waller.obbligato.org","threadId":"31772","inReplyTo":"CABVa4NinSighUn7GKbzMx9qZj3Ao2dCtEZxUqCPwO9TocZ8Kkg@mail.gmail.com","subject":"Re: [PATCH] Add --unannotate option to git-subtree","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2013-01-01T01:15:23Z","receivedAt":"2013-01-01T01:15:23Z","isPatch":true,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"James Nylen <jnylen@gmail.com> writes:\n\n> Rather than adding a marker to each commit when splitting out the\n> commits back to the subproject, --unannotate removes the specified\n> string (or bash glob pattern) from the beginning of the first line of\n> the commit message.  This enables the following workflow:\n\nI applied the patch to my working copy but it doesn't seem to do\nwhat I'd expect.  The test script does something like this:\n\n- create project A\n- add file to project A with message \"subproj: add F1\"\n- add file to project A with message \"subproj: add F2\"\n- add project A as a subtree of project B under directory subdir\n- add a file to subdir with message \"subproj: add F3\"\n- do a split --unannotate=\"subproj:\"\n\nI expected to see a log with no mention of \"subproj\" anywhere.  Instead\nI get:\n\nadd F3\nsubproj: add F2\nsubproj: add F1\n\nIs this as you intend?  Is --unannotate only supposed to strip the\nstring for commits added when A was a subtree of B?\n\nI guess this behavior makes sense in that the user would want to\nsee the same commits that existed before A became a subproject.\n\n                   -David\n"},{"id":"207169","messageId":"CABVa4NhwcD584ptSazOR9WvSWep1z+krhxkWDvUk8nXaF8EYxQ@mail.gmail.com","threadId":"31772","inReplyTo":"87a9st4sb8.fsf@waller.obbligato.org","subject":"Re: [PATCH] Add --unannotate option to git-subtree","fromName":"James Nylen","fromEmail":"jnylen@gmail.com","sentAt":"2013-01-17T20:56:57Z","receivedAt":"2013-01-17T20:56:57Z","isPatch":true,"sender":{"key":"jnylen@gmail.com","avatar":"https://gravatar.com/avatar/96804ac655933f5b6380e992610d6ff9029c6d04db1042d4bec381312ff7ff1b?d=mp&s=160"},"body":"On Mon, Dec 31, 2012 at 8:15 PM,  <greened@obbligato.org> wrote:\n> James Nylen <jnylen@gmail.com> writes:\n>\n>> Rather than adding a marker to each commit when splitting out the\n>> commits back to the subproject, --unannotate removes the specified\n>> string (or bash glob pattern) from the beginning of the first line of\n>> the commit message.  This enables the following workflow:\n>\n> I applied the patch to my working copy but it doesn't seem to do\n> what I'd expect.  The test script does something like this:\n>\n> - create project A\n> - add file to project A with message \"subproj: add F1\"\n> - add file to project A with message \"subproj: add F2\"\n> - add project A as a subtree of project B under directory subdir\n> - add a file to subdir with message \"subproj: add F3\"\n> - do a split --unannotate=\"subproj:\"\n>\n> I expected to see a log with no mention of \"subproj\" anywhere.  Instead\n> I get:\n>\n> add F3\n> subproj: add F2\n> subproj: add F1\n>\n> Is this as you intend?  Is --unannotate only supposed to strip the\n> string for commits added when A was a subtree of B?\n>\n> I guess this behavior makes sense in that the user would want to\n> see the same commits that existed before A became a subproject.\n>\n>                    -David\n\nWow, I missed a bunch of emails on this.  Thanks for applying and for\nwriting tests!\n\nThis is as intended.  You wouldn't want subtree to modify commits that\noccurred in the full repository for project A.  Furthermore, you\nwouldn't have a \"subproj:\" commit in project A's standalone repo since\nit wasn't a subproject at that time.\n\nThe --annotate option confused me because it was the reverse of what I\nwanted.  As in your example, a typical use would be 'add a file to\nsubdir with message \"subproj: add F3\" ' to make it clear that you were\ncommitting to the \"subproj\" part of a larger repository.  Then, when\nsplitting back out to subproj's main repository, you'd want to remove\nthe prefix.\n"},{"id":"207498","messageId":"87d2wxfw4h.fsf@waller.obbligato.org","threadId":"31772","inReplyTo":"CABVa4NhwcD584ptSazOR9WvSWep1z+krhxkWDvUk8nXaF8EYxQ@mail.gmail.com","subject":"Re: [PATCH] Add --unannotate option to git-subtree","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2013-01-22T08:41:02Z","receivedAt":"2013-01-22T08:41:02Z","isPatch":true,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"James Nylen <jnylen@gmail.com> writes:\n\n> Wow, I missed a bunch of emails on this.  Thanks for applying and for\n> writing tests!\n\nSorry it took so long.\n\n> This is as intended.  You wouldn't want subtree to modify commits that\n> occurred in the full repository for project A.  Furthermore, you\n> wouldn't have a \"subproj:\" commit in project A's standalone repo since\n> it wasn't a subproject at that time.\n\nYes, that makes sense.\n\n> The --annotate option confused me because it was the reverse of what I\n> wanted.  As in your example, a typical use would be 'add a file to\n> subdir with message \"subproj: add F3\" ' to make it clear that you were\n> committing to the \"subproj\" part of a larger repository.  Then, when\n> splitting back out to subproj's main repository, you'd want to remove\n> the prefix.\n\nOk.  I'll re-submit as part of the final sequence.\n\nThanks for the patch!\n\n                            -David\n"}]}