{"thread":{"id":"31223","subject":"[PATCH/RFC] [git-subtree.sh] Use raw subject and body modifier \"%B\" instead of \"%s%n%n%b\" for commit","startedAt":"2012-08-10T01:15:57Z","lastAt":"2013-01-01T03:59:17Z","messageCount":6,"participants":["Techlive Zheng","greened@obbligato.org"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"196770","messageId":"1344561358-2953-1-git-send-email-techlivezheng@gmail.com","threadId":"31223","inReplyTo":null,"subject":"[PATCH/RFC] [git-subtree.sh] Use raw subject and body modifier \"%B\" instead of \"%s%n%n%b\" for commit","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2012-08-10T01:15:57Z","receivedAt":"2012-08-10T01:15:57Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"I don't know if it is the right place to post this patch, I have sended\nan email to the original author apenwarr and have no response. According\nto <https://github.com/apenwarr/git-subtree/blob/master/THIS-REPO-IS-OBSOLETE>,\nthis is the place, but <https://github.com/git/git/blob/master/contrib/README> says\ndifferent, which is really confusing. Anyway, here I am.\n\nRecently, I imported a foreign git project as a sub directory into a\nmain repo which I intend to maintain as primary.\n\nDue to the project I imported has its own remote repo which hosted\non the github, I expected after a 'git-subtree.sh split' the newly\ngenerated subtree branch would be exactly identical to the original\nbranch. Unfortunately, it is not. I have fixed the committer date\nand make everything looks the same with the original branch, but\nthey just did not end up with same commit sha1 hash. Then, I used\n`git cat-file -p` to view the raw output of the both commits and\nfound that the commit generate by git-subtree has a extra 'new-line'\ncharacter appended at the end of the subject which causes the problem.\n\nI checked the source and found \"%s%n%n%b\" were used to generate the\ncommit message, this works the fine when a commit has a subject as\nwell as a body, but most of my commits only have a subject under\nwhich condition a extra 'new-line' character is appended.\n\nInstead, a raw subject and body message modifier '%B' should be used.\n\nThough I think this patch should be applied by default, but the mistake\nhas been there for a long time, applying this patch may cause the patched\ngit-subtree generate a different branch for those whose subtree branch\nhas already been generated using the old git-subtree. Maybe this should\nbe explained in the help or man page, and add a condition check or a\ncompatible mode somehow.\n\nTechlive Zheng (1):\n  subtree.sh: Use raw subject and body modifier \"%B\" instead of \"%s%n%n%b\"\n\n contrib/subtree/git-subtree.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\n-- \n1.7.11.4\n"},{"id":"196771","messageId":"1344561358-2953-2-git-send-email-techlivezheng@gmail.com","threadId":"31223","inReplyTo":"1344561358-2953-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH] subtree.sh: Use raw subject and body modifier \"%B\" instead of \"%s%n%n%b\"","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2012-08-10T01:15:58Z","receivedAt":"2012-08-10T01:15:58Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"\"%s%n%n%b\" is not always equal to \"%B\". If the commit msg does not have\na body, this will append an extra new-line character to the msg title\nwhich would cause the splited commit has a new sha1 hash. In most cases,\nthis does not matter, but for a project which did not merged using this\nscript initially, the 'split' command would not genereate the same\ncommits as the orginal which may cause conflicts.\n\nSigned-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/git-subtree.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 920c664..5598210 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -296,7 +296,7 @@ copy_commit()\n \t# We're going to set some environment vars here, so\n \t# do it in a subshell to get rid of them safely later\n \tdebug copy_commit \"{$1}\" \"{$2}\" \"{$3}\"\n-\tgit log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' \"$1\" |\n+\tgit log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' \"$1\" |\n \t(\n \t\tread GIT_AUTHOR_NAME\n \t\tread GIT_AUTHOR_EMAIL\n-- \n1.7.11.4\n"},{"id":"197486","messageId":"87628df1v4.fsf@waller.obbligato.org","threadId":"31223","inReplyTo":"1344561358-2953-1-git-send-email-techlivezheng@gmail.com","subject":"Re: [PATCH/RFC] [git-subtree.sh] Use raw subject and body modifier \"%B\" instead of \"%s%n%n%b\" for commit","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2012-08-21T01:52:15Z","receivedAt":"2012-08-21T01:52:15Z","isPatch":true,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"Techlive Zheng <techlivezheng@gmail.com> writes:\n\n> I don't know if it is the right place to post this patch, I have sended\n> an email to the original author apenwarr and have no response. According\n> to <https://github.com/apenwarr/git-subtree/blob/master/THIS-REPO-IS-OBSOLETE>,\n> this is the place, but <https://github.com/git/git/blob/master/contrib/README> says\n> different, which is really confusing. Anyway, here I am.\n\nThis is the place.\n\n> Recently, I imported a foreign git project as a sub directory into a\n> main repo which I intend to maintain as primary.\n\nOk.\n\n> Due to the project I imported has its own remote repo which hosted\n> on the github, I expected after a 'git-subtree.sh split' the newly\n> generated subtree branch would be exactly identical to the original\n> branch. \n\nI would have thought so too.\n\n> Unfortunately, it is not. I have fixed the committer date and make\n> everything looks the same with the original branch, but they just did\n> not end up with same commit sha1 hash. Then, I used `git cat-file -p`\n> to view the raw output of the both commits and found that the commit\n> generate by git-subtree has a extra 'new-line' character appended at\n> the end of the subject which causes the problem.\n\nHmm.\n\n> I checked the source and found \"%s%n%n%b\" were used to generate the\n> commit message, this works the fine when a commit has a subject as\n> well as a body, but most of my commits only have a subject under\n> which condition a extra 'new-line' character is appended.\n\nAh.  Yes, we should fix this.\n\n> Instead, a raw subject and body message modifier '%B' should be used.\n\nOk.\n\n> Though I think this patch should be applied by default, but the mistake\n> has been there for a long time, applying this patch may cause the patched\n> git-subtree generate a different branch for those whose subtree branch\n> has already been generated using the old git-subtree. Maybe this should\n> be explained in the help or man page, and add a condition check or a\n> compatible mode somehow.\n\nThe problem is in the split code?  I'm not sure this is a big issue.  I\ncan run some experiments.\n\n                      -Dave\n"},{"id":"197480","messageId":"87zk5pdn43.fsf@waller.obbligato.org","threadId":"31223","inReplyTo":"1344561358-2953-2-git-send-email-techlivezheng@gmail.com","subject":"Re: [PATCH] subtree.sh: Use raw subject and body modifier \"%B\" instead of \"%s%n%n%b\"","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2012-08-21T01:56:12Z","receivedAt":"2012-08-21T01:56:12Z","isPatch":true,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"Techlive Zheng <techlivezheng@gmail.com> writes:\n\n> \"%s%n%n%b\" is not always equal to \"%B\". If the commit msg does not have\n> a body, this will append an extra new-line character to the msg title\n> which would cause the splited commit has a new sha1 hash. In most cases,\n> this does not matter, but for a project which did not merged using this\n> script initially, the 'split' command would not genereate the same\n> commits as the orginal which may cause conflicts.\n>\n> Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>\n> ---\n>  contrib/subtree/git-subtree.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\n> index 920c664..5598210 100755\n> --- a/contrib/subtree/git-subtree.sh\n> +++ b/contrib/subtree/git-subtree.sh\n> @@ -296,7 +296,7 @@ copy_commit()\n>  \t# We're going to set some environment vars here, so\n>  \t# do it in a subshell to get rid of them safely later\n>  \tdebug copy_commit \"{$1}\" \"{$2}\" \"{$3}\"\n> -\tgit log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' \"$1\" |\n> +\tgit log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' \"$1\" |\n>  \t(\n>  \t\tread GIT_AUTHOR_NAME\n>  \t\tread GIT_AUTHOR_EMAIL\n\nThis looks good to me.  I assume this passes all the tests.  Can you add\na test for this bug so we don't regress?  Junio, I am good with this\npatch as soon as we get a test for the problem.\n\nThanks!\n\n                             -Dave\n"},{"id":"205709","messageId":"87mwwt4yp4.fsf@waller.obbligato.org","threadId":"31223","inReplyTo":"87zk5pdn43.fsf@waller.obbligato.org","subject":"Re: [PATCH] subtree.sh: Use raw subject and body modifier \"%B\" instead of \"%s%n%n%b\"","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2012-12-31T22:57:27Z","receivedAt":"2012-12-31T22:57:27Z","isPatch":true,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"greened@obbligato.org writes:\n\n> Techlive Zheng <techlivezheng@gmail.com> writes:\n>\n>> \"%s%n%n%b\" is not always equal to \"%B\". If the commit msg does not have\n>> a body, this will append an extra new-line character to the msg title\n>> which would cause the splited commit has a new sha1 hash. In most cases,\n>> this does not matter, but for a project which did not merged using this\n>> script initially, the 'split' command would not genereate the same\n>> commits as the orginal which may cause conflicts.\n>>\n>> Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>\n>> ---\n>>  contrib/subtree/git-subtree.sh | 2 +-\n>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\n>> index 920c664..5598210 100755\n>> --- a/contrib/subtree/git-subtree.sh\n>> +++ b/contrib/subtree/git-subtree.sh\n>> @@ -296,7 +296,7 @@ copy_commit()\n>>  \t# We're going to set some environment vars here, so\n>>  \t# do it in a subshell to get rid of them safely later\n>>  \tdebug copy_commit \"{$1}\" \"{$2}\" \"{$3}\"\n>> -\tgit log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' \"$1\" |\n>> +\tgit log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' \"$1\" |\n>>  \t(\n>>  \t\tread GIT_AUTHOR_NAME\n>>  \t\tread GIT_AUTHOR_EMAIL\n>\n> This looks good to me.  I assume this passes all the tests.  Can you add\n> a test for this bug so we don't regress?  Junio, I am good with this\n> patch as soon as we get a test for the problem.\n\nI've applied this patch to my working copy but I'm not finding that I\ncan recreate the original problem when the patch is disabled.\n\nI assumed the scenario you're trying to fix is:\n\n- Make some commit C to project A with a one-line message\n- work, commit, work...\n- Add project A as a subproject\n- work, commit, work...\n- Split project A off into a separate repository\n\nAfter this, commit C with the one-line message in the split-off projet\nshould have the same hash it had before project A was incorporated as a\nsubproject.\n\nAs I understad it, you saw the post-split commit having a different\nhash?\n\nIs that right?  I am not seeing that problem even without your patch.\n\nI want to make sure I understand what the problem is so I can test for\nit.\n\nThanks!\n\n                      -David\n"},{"id":"205753","messageId":"87han1wo2y.fsf@waller.obbligato.org","threadId":"31223","inReplyTo":"87mwwt4yp4.fsf@waller.obbligato.org","subject":"Re: [PATCH] subtree.sh: Use raw subject and body modifier \"%B\" instead of \"%s%n%n%b\"","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2013-01-01T03:59:17Z","receivedAt":"2013-01-01T03:59:17Z","isPatch":true,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"greened@obbligato.org writes:\n\n> I've applied this patch to my working copy but I'm not finding that I\n> can recreate the original problem when the patch is disabled.\n     ^ not\n\n                          -David\n"}]}