{"thread":{"id":"26822","subject":"[PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts","startedAt":"2011-03-22T08:56:16Z","lastAt":"2011-03-24T06:58:57Z","messageCount":4,"participants":["Nicolas Morey-Chaisemartin","Jens Lehmann","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"164025","messageId":"4D886430.3080300@kalray.eu","threadId":"26822","inReplyTo":null,"subject":"[PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts","fromName":"Nicolas Morey-Chaisemartin","fromEmail":"nmorey@kalray.eu","sentAt":"2011-03-22T08:56:16Z","receivedAt":"2011-03-22T08:56:16Z","isPatch":true,"sender":{"key":"devel-git@morey-chaisemartin.com","avatar":"https://avatars.githubusercontent.com/u/108326?v=4"},"body":"During a merge with conflict on a submodule, the submodule appears 3 times in git ls-files (stage 1,2,3) which caused the submodule to be used 3 times in git submodule init, sync, update and status command.\nThis patch filters the results of git ls-files to generate a single entry for conflicting submodules with a 0 SHA1 and 'U' as stage.\nAfter this patch:\n- init and sync behave as previously but only once per submodule\n- update skips submodule with merge conflicts\n- status now display a null SHA1 prefixed by 'U' for submodule with merge conflicts\n\nSigned-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>\n---\n git-submodule.sh |   29 ++++++++++++++++++++++++++++-\n 1 files changed, 28 insertions(+), 1 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 3a13397..7f6b3cf 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -72,7 +72,24 @@ resolve_relative_url ()\n #\n module_list()\n {\n-\tgit ls-files --error-unmatch --stage -- \"$@\" | sane_grep '^160000 '\n+\tgit ls-files --error-unmatch --stage -- \"$@\" |\n+\tperl -e '\n+\tmy %unmerged = ();\n+\tmy ($null_sha1) = (\"0\" x 40);\n+\twhile (<STDIN>) {\n+\t\tchomp;\n+\t\tmy ($mode, $sha1, $stage, $path) =\n+\t\t\t/^([0-7]+) ([0-9a-f]{40}) ([0-3])\\t(.*)$/;\n+\t\tnext unless $mode eq \"160000\";\n+\t\tif ($stage ne \"0\") {\n+\t\t\tif (!$unmerged{$path}++) {\n+\t\t\t\tprint \"$mode $null_sha1 U\\t$path\\n\";\n+\t\t\t}\n+\t\t\tnext;\n+\t\t}\n+\t\tprint \"$_\\n\";\n+\t}\n+\t'\n }\n \n #\n@@ -427,6 +444,11 @@ cmd_update()\n \tmodule_list \"$@\" |\n \twhile read mode sha1 stage path\n \tdo\n+\t\tif test \"$stage\" = U\n+\t\tthen\n+\t\t\techo >&2 \"Skipping unmerged submodule $path\"\n+\t\t\tcontinue\n+\t\tfi\n \t\tname=$(module_name \"$path\") || exit\n \t\turl=$(git config submodule.\"$name\".url)\n \t\tupdate_module=$(git config submodule.\"$name\".update)\n@@ -770,6 +792,11 @@ cmd_status()\n \t\tname=$(module_name \"$path\") || exit\n \t\turl=$(git config submodule.\"$name\".url)\n \t\tdisplaypath=\"$prefix$path\"\n+\t\tif test \"$stage\" = U\n+\t\tthen\n+\t\t\tsay \"U$sha1 $displaypath\"\n+\t\t\tcontinue\n+\t\tfi\n \t\tif test -z \"$url\" || ! test -d \"$path\"/.git -o -f \"$path\"/.git\n \t\tthen\n \t\t\tsay \"-$sha1 $displaypath\"\n-- \n1.7.4\n"},{"id":"164080","messageId":"4D88F6EF.3020804@web.de","threadId":"26822","inReplyTo":"4D886430.3080300@kalray.eu","subject":"Re: [PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2011-03-22T19:22:23Z","receivedAt":"2011-03-22T19:22:23Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Thanks, that fixes it nicely!\n\nAm 22.03.2011 09:56, schrieb Nicolas Morey-Chaisemartin:\n> During a merge with conflict on a submodule, the submodule appears 3 times in git ls-files (stage 1,2,3) which caused the submodule to be used 3 times in git submodule init, sync, update and status command.\n> This patch filters the results of git ls-files to generate a single entry for conflicting submodules with a 0 SHA1 and 'U' as stage.\n\nNit: Usually we wrap commit messages at about 72 characters.\n\n> After this patch:\n> - init and sync behave as previously but only once per submodule\n> - update skips submodule with merge conflicts\n> - status now display a null SHA1 prefixed by 'U' for submodule with merge conflicts\n\nA test case would be nice (t7405 looks like the right spot for one).\n"},{"id":"164091","messageId":"7voc52kf3t.fsf@alter.siamese.dyndns.org","threadId":"26822","inReplyTo":"4D88F6EF.3020804@web.de","subject":"Re: [PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-22T21:41:26Z","receivedAt":"2011-03-22T21:41:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jens Lehmann <Jens.Lehmann@web.de> writes:\n\n> Thanks, that fixes it nicely!\n>\n> Am 22.03.2011 09:56, schrieb Nicolas Morey-Chaisemartin:\n>> During a merge with conflict on a submodule, the submodule appears 3 times in git ls-files (stage 1,2,3) which caused the submodule to be used 3 times in git submodule init, sync, update and status command.\n>> This patch filters the results of git ls-files to generate a single entry for conflicting submodules with a 0 SHA1 and 'U' as stage.\n>\n> Nit: Usually we wrap commit messages at about 72 characters.\n\nAlso it is very dissapointing to see that none of the careful thinking\nthat was needed while deciding what each subcommand should do was copied\nfrom <7vhbb1320t.fsf@alter.siamese.dyndns.org> -- did I just waste my\ntime trying to guide this topic forward?\n\n>> After this patch:\n>> - init and sync behave as previously but only once per submodule\n>> - update skips submodule with merge conflicts\n>> - status now display a null SHA1 prefixed by 'U' for submodule with merge conflicts\n>\n> A test case would be nice (t7405 looks like the right spot for one).\n"},{"id":"164205","messageId":"4D8AEBB1.5010501@morey-chaisemartin.com","threadId":"26822","inReplyTo":"7voc52kf3t.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts","fromName":"Nicolas Morey-Chaisemartin","fromEmail":"devel-git@morey-chaisemartin.com","sentAt":"2011-03-24T06:58:57Z","receivedAt":"2011-03-24T06:58:57Z","isPatch":true,"sender":{"key":"devel-git@morey-chaisemartin.com","avatar":"https://avatars.githubusercontent.com/u/108326?v=4"},"body":"On 03/22/2011 10:41 PM, Junio C Hamano wrote:\n> Jens Lehmann <Jens.Lehmann@web.de> writes:\n>\n>> Thanks, that fixes it nicely!\n>>\n>> Am 22.03.2011 09:56, schrieb Nicolas Morey-Chaisemartin:\n>>> During a merge with conflict on a submodule, the submodule appears 3 times in git ls-files (stage 1,2,3) which caused the submodule to be used 3 times in git submodule init, sync, update and status command.\n>>> This patch filters the results of git ls-files to generate a single entry for conflicting submodules with a 0 SHA1 and 'U' as stage.\n>> Nit: Usually we wrap commit messages at about 72 characters.\n> Also it is very dissapointing to see that none of the careful thinking\n> that was needed while deciding what each subcommand should do was copied\n> from <7vhbb1320t.fsf@alter.siamese.dyndns.org> -- did I just waste my\n> time trying to guide this topic forward?\n>\nSorry about that. I wasn't sure how much details you put in commit logs. I guess it wasn't enough.\nI'll fix this as soon as I have added a test case for the 'U' status\n"}]}