{"thread":{"id":"49415","subject":"[PATCH] submodule.c: Make get_superproject_working_tree() work when supermodule has unmerged changes of the submodule reference","startedAt":"2018-09-24T21:25:46Z","lastAt":"2018-09-25T01:24:21Z","messageCount":2,"participants":["Sam McKelvie","Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"358794","messageId":"20180924212352.41909-1-smckelvie@xevo.com","threadId":"49415","inReplyTo":null,"subject":"[PATCH] submodule.c: Make get_superproject_working_tree() work when supermodule has unmerged changes of the submodule reference","fromName":"Sam McKelvie","fromEmail":"sammck@gmail.com","sentAt":"2018-09-24T21:23:52Z","receivedAt":"2018-09-24T21:25:46Z","isPatch":true,"sender":{"key":"sammck@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7035152?v=4"},"body":"    Previously, \"fatal: BUG: returned path string doesn't match cwd?\" is displayed and\n    git-rev-parse aborted.\n\n    The problem is due to the fact that when a merge of the submodule reference is in progress,\n    \"git --stage —full-name <submodule-relative-path>” returns three seperate entries for the\n    submodule (one for each stage) rather than a single entry; e.g.,\n\n    $ git ls-files --stage --full-name submodule-child-test\n    160000 dbbd2766fa330fa741ea59bb38689fcc2d283ac5 1       submodule-child-test\n    160000 f174d1dbfe863a59692c3bdae730a36f2a788c51 2       submodule-child-test\n    160000 e6178f3a58b958543952e12824aa2106d560f21d 3       submodule-child-test\n\n    The code in get_superproject_working_tree() expected exactly one entry to be returned;\n    this patch makes it use the first entry if multiple entries are returned.\n\n    Signed-off-by: Sam McKelvie <smckelvie@xevo.com>\n---\n submodule.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 33de6ee5f..5b9d5ad7e 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -1885,7 +1885,7 @@ const char *get_superproject_working_tree(void)\n \t\t * We're only interested in the name after the tab.\n \t\t */\n \t\tsuper_sub = strchr(sb.buf, '\\t') + 1;\n-\t\tsuper_sub_len = sb.buf + sb.len - super_sub - 1;\n+\t\tsuper_sub_len = strlen(super_sub);\n \n \t\tif (super_sub_len > cwd_len ||\n \t\t    strcmp(&cwd[cwd_len - super_sub_len], super_sub))\n-- \n2.19.0.605.g01d371f74.dirty\n\n"},{"id":"358813","messageId":"CAGZ79kZa-d3kPXp=q-YezffF68BUZzXv_tUaOKCi8=9SHy6jrA@mail.gmail.com","threadId":"49415","inReplyTo":"20180924212352.41909-1-smckelvie@xevo.com","subject":"Re: [PATCH] submodule.c: Make get_superproject_working_tree() work when supermodule has unmerged changes of the submodule reference","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-09-25T01:24:07Z","receivedAt":"2018-09-25T01:24:21Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, Sep 24, 2018 at 2:25 PM Sam McKelvie <sammck@gmail.com> wrote:\n\nThanks for writing a patch!\nI wonder if we can shorten the subject and make it a bit more concise,\nhow about\n\n    submodule: Alllow staged changes for get_superproject_working_tree\n\nor\n\n    rev-parse: allow staged submodule in --show-superproject-working-tree\n\n\n>     Previously, \"fatal: BUG: returned path string doesn't match cwd?\" is displayed and\n>     git-rev-parse aborted.\n\nUsually it is hard to read, continuing from the commit title to the body\nof the commit message, as the title may be displayed differently or\nsomewhere else, so it would be good to restate it or rather state the\ncommand that is broken, which we are trying to fix.\n\n    Invoking 'git rev-parse --show-superproject-working-tree' exits with\n\n        fatal: BUG ...\n\n    instead of displaying the superproject working tree when ....\n\n>     The problem is due to the fact that when a merge of the submodule reference is in progress,\n>     \"git --stage —full-name <submodule-relative-path>” returns three seperate entries for the\n\n\"ls-files\" is missing in that git invocation?\n\n>     submodule (one for each stage) rather than a single entry; e.g.,\n>\n>     $ git ls-files --stage --full-name submodule-child-test\n>     160000 dbbd2766fa330fa741ea59bb38689fcc2d283ac5 1       submodule-child-test\n>     160000 f174d1dbfe863a59692c3bdae730a36f2a788c51 2       submodule-child-test\n>     160000 e6178f3a58b958543952e12824aa2106d560f21d 3       submodule-child-test\n>\n>     The code in get_superproject_working_tree() expected exactly one entry to be returned;\n>     this patch makes it use the first entry if multiple entries are returned.\n\nThe code looks good.\n\nI wonder if we want to add a test for it, see t/t1500-rev-parse.sh\n(at the very end 'showing the superproject correctly').\n\n>\n>     Signed-off-by: Sam McKelvie <smckelvie@xevo.com>\n\nSide note: the commit message seems to be indented,\nbut the patch applies fine, which makes me curious:\nHow did you produce&send the patch?\n(Usually a patch would not apply as white spaces are\nmangled in the code for example in some email setups)\n(If I had to guess I could imagine that it is the output of\ngit-show as that indents the commit message usually,\nsee git-format-patch for a better tool)\n\nThanks for writing the patch!\nStefan\n"}]}