{"thread":{"id":"56073","subject":"Bug with branches/merges in submodules","startedAt":"2021-07-07T13:20:25Z","lastAt":"2021-07-14T12:25:40Z","messageCount":4,"participants":["Mel Dafert","Philippe Blain"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"429420","messageId":"E9E32A45-DA88-47CB-B7F9-F01F9BEC394C@dafert.at","threadId":"56073","inReplyTo":null,"subject":"Bug with branches/merges in submodules","fromName":"Mel Dafert","fromEmail":"mel@dafert.at","sentAt":"2021-07-07T13:13:46Z","receivedAt":"2021-07-07T13:20:25Z","isPatch":false,"sender":{"key":"mel@dafert.at","avatar":null},"body":"Hello,\nI ran into a bug where commits are omitted from `git submodule summary`\nand friends when the submodule contains merge commits.\nOriginally using 2.30.2, I can also reproduce this with a fresh build on the\n`next` branch (see attached bugreport).\nI would assume that this is not intentional, however I cannot find any relevant\ninformation on this.\nFeel free to contact me for extra details.\nBest regards,\nMel\n\nThank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\nSet up a submodule that has branches/merge commits:\n```bash\n# create repository \"child\"\nmkdir child-repo\ncd child-repo\ngit init\ntouch initial.txt\ngit add initial.txt\ngit commit -m \"initial child\"\ncd ..\n# create repository \"parent\"\nmkdir parent\ncd parent\ngit init\n# add submodule \"child\" to repository \"parent\"\ngit submodule add ../child-repo/ child\ngit commit -am \"initial parent\"\ncd child\n# make two commits in separate branches in \"child\"\ngit switch -c \"secondary\"\ntouch s1.txt\ngit add s1.txt\ngit commit -m \"s1\"\ngit switch master\ntouch m1.txt\ngit add m1.txt\ngit commit -m \"m1\"\n# merge branch \"secondary\" into \"master\" in \"child\" - this creates a merge commit\ngit merge secondary --no-edit\ncd ..\n```\nRun `git diff --submodule=log` inside the \"parent\" repository.\n\nWhat did you expect to happen? (Expected behavior)\n`git diff --submodule=log` should show all three commits added to the \"child\"\nsubmodule:\n```\nSubmodule child XXXXXXX..YYYYYYY\n> Merge branch 'secondary'\n> m1\n> s1\n```\n\nWhat happened instead? (Actual behavior)\n`git diff --submodule=log` only shows commits from one ancestor of the merge\ncommit:\n```\nSubmodule child XXXXXXX..YYYYYYY\n> Merge branch 'secondary'\n> m1\n```\n\nWhat's different between what you expected and what actually happened?\nAll the commits added to the \"secondary\" branch are missing in\n`git diff --submodule=log`.\n\nAnything else you want to add:\nThe commit range shown by `git diff --submodule=log` is correct:\n`cd child; git log XXXXXXX..YYYYYYY` shows the correct list of commits.\n\nThis bug also affects `git submodule summary`, and `git show --submodule=log`\nafter the changes have been committed.\n\n\n[System Info]\ngit version:\ngit version 2.32.0.262.g8c582fcd64\ncpu: x86_64\nbuilt from commit: 8c582fcd643d12802e0a6d7e307890aa5b6b26e1\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.11.0-22-generic #23-Ubuntu SMP Thu Jun 17 00:34:23 UTC 2021 x86_64\ncompiler info: gnuc: 10.3\nlibc info: glibc: 2.33\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n"},{"id":"429584","messageId":"b519a79a-5e35-bb40-71d3-0fb3c65320d7@gmail.com","threadId":"56073","inReplyTo":"E9E32A45-DA88-47CB-B7F9-F01F9BEC394C@dafert.at","subject":"Re: Bug with branches/merges in submodules","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2021-07-09T21:18:31Z","receivedAt":"2021-07-09T21:18:36Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Mel!\n\nThanks for writing in! Responses inline below.\n\nLe 2021-07-07 à 09:13, Mel Dafert a écrit :\n> Hello,\n> I ran into a bug where commits are omitted from `git submodule summary`\n> and friends when the submodule contains merge commits.\n> Originally using 2.30.2, I can also reproduce this with a fresh build on the\n> `next` branch (see attached bugreport).\n> I would assume that this is not intentional, however I cannot find any relevant\n> information on this.\n\nYou are right that the doc seems to be quiet about that [1], [2].\n\n\n> Feel free to contact me for extra details.\n> Best regards,\n> Mel\n> \n\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n> \n> What did you do before the bug happened? (Steps to reproduce your issue)\n> Set up a submodule that has branches/merge commits:\n> ```bash\n> # create repository \"child\"\n> mkdir child-repo\n> cd child-repo\n> git init\n> touch initial.txt\n> git add initial.txt\n> git commit -m \"initial child\"\n> cd ..\n> # create repository \"parent\"\n> mkdir parent\n> cd parent\n> git init\n> # add submodule \"child\" to repository \"parent\"\n> git submodule add ../child-repo/ child\n> git commit -am \"initial parent\"\n> cd child\n> # make two commits in separate branches in \"child\"\n> git switch -c \"secondary\"\n> touch s1.txt\n> git add s1.txt\n> git commit -m \"s1\"\n> git switch master\n> touch m1.txt\n> git add m1.txt\n> git commit -m \"m1\"\n> # merge branch \"secondary\" into \"master\" in \"child\" - this creates a merge commit\n> git merge secondary --no-edit\n> cd ..\n> ```\n> Run `git diff --submodule=log` inside the \"parent\" repository.\n> \n> What did you expect to happen? (Expected behavior)\n> `git diff --submodule=log` should show all three commits added to the \"child\"\n> submodule:\n> ```\n> Submodule child XXXXXXX..YYYYYYY\n>> Merge branch 'secondary'\n>> m1\n>> s1\n> ```\n> \n> What happened instead? (Actual behavior)\n> `git diff --submodule=log` only shows commits from one ancestor of the merge\n> commit:\n> ```\n> Submodule child XXXXXXX..YYYYYYY\n>> Merge branch 'secondary'\n>> m1\n> ```\n> \n> What's different between what you expected and what actually happened?\n> All the commits added to the \"secondary\" branch are missing in\n> `git diff --submodule=log`.\n> \n> Anything else you want to add:\n> The commit range shown by `git diff --submodule=log` is correct:\n> `cd child; git log XXXXXXX..YYYYYYY` shows the correct list of commits.\n> \n> This bug also affects `git submodule summary`, and `git show --submodule=log`\n> after the changes have been committed.\n\nThanks for the reproducer. The behaviour for 'git log/show/diff' is due this line [3]\nand the behaviour for 'git submodule summary' to these lines [4] [5].\n\nFor 'git diff' and friends, it goes back to the addition of the '--submodule=log'\noption in 752c0c2492 (Add the --submodule option to the diff option family, 2009-10-19).\n(authored CC'ed). The use of '--first-parent' was discussed on the list\nwhen this was implemented [6]. I did not read the whole thing.\n\nFor 'git submodule summary', it goes back to the addition of the subcommand\nin 1cb639e6b0 (git-submodule summary: show commit summary, 2008-03-11). (author also CC'ed).\nThe justification of the use of '--first-parent' was not really discussed\nas far as I could tell [7].\n\n\nI personnally think it would be a good addition to be able to choose\nif yes or no '--first-parent' should be used.\n\nCheers,\n\nPhilippe.\n\n\n[1] https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-summary--cached--files-n--summary-limitltngtcommit--ltpathgt82308203\n[2] https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---submoduleltformatgt\n[3] https://github.com/git/git/blob/d486ca60a51c9cb1fe068803c3f540724e95e83a/submodule.c#L453\n[4] https://github.com/git/git/blob/d486ca60a51c9cb1fe068803c3f540724e95e83a/builtin/submodule--helper.c#L1020-L1021\n[5] https://github.com/git/git/blob/d486ca60a51c9cb1fe068803c3f540724e95e83a/builtin/submodule--helper.c#L1117-L1118\n[6] https://lore.kernel.org/git/67a884457aeaead275612be10902a80726b2a7db.1254668669u.git.johannes.schindelin@gmx.de/t/#u\n[7] https://lore.kernel.org/git/?q=f%3Ayin+s%3A%280+submodule+summary+NOT%3ARe+%29+\n"},{"id":"430012","messageId":"6502FFC0-E19B-41FA-B152-885B339360F0@dafert.at","threadId":"56073","inReplyTo":"b519a79a-5e35-bb40-71d3-0fb3c65320d7@gmail.com","subject":"Re: Bug with branches/merges in submodules","fromName":"Mel Dafert","fromEmail":"mel@dafert.at","sentAt":"2021-07-14T11:07:37Z","receivedAt":"2021-07-14T11:07:37Z","isPatch":false,"sender":{"key":"mel@dafert.at","avatar":null},"body":"Hello Philippe,\nThank you for your reply, and the points to the mailing list.\n\n>Thanks for the reproducer. The behaviour for 'git log/show/diff' is due this line\n>and the behaviour for 'git submodule summary' to these lines.\n>\n>For 'git diff' and friends, it goes back to the addition of the '--submodule=log'\n>option in 752c0c2492 (Add the --submodule option to the diff option family, 2009-10-19).\n>(authored CC'ed). The use of '--first-parent' was discussed on the list\n>when this was implemented. I did not read the whole thing.\n>\n>For 'git submodule summary', it goes back to the addition of the subcommand\n>in 1cb639e6b0 (git-submodule summary: show commit summary, 2008-03-11). (author also CC'ed).\n>The justification of the use of '--first-parent' was not really discussed\n>as far as I could tell.\n>\n>\n>I personnally think it would be a good addition to be able to choose\n>if yes or no '--first-parent' should be used\n\nThe discussion you found [1] also suggested that as a future option.\n\nIn the original implementation, the first mention is [2], where the length of the\nmessage is discussed - I (and later discussions) assume that this just\nhappened to be the preference of the author.\n\nI would thus like to correct myself, and refile this as a feature request - it would\nbe very helpful to me to have this as an option, possibly even with one that can be set in the config, similar to\n'diff.submodule=log'.\n\nI would be open to implementing this - I might need some mentoring, however, as\nthis would be my first time contributing (and reading the git codebase).\n\nRegards,\nMel\n\n[1] https://lore.kernel.org/git/67a884457aeaead275612be10902a80726b2a7db.1254668669u.git.johannes.schindelin@gmx.de/t/#u\n[2] https://lore.kernel.org/git/46dff0320803061750x70d059a2yaf1e5751e9c62150@mail.gmail.com/\n"},{"id":"430035","messageId":"20c07aef-d3e4-0ab6-e6f4-f9179f3950a2@gmail.com","threadId":"56073","inReplyTo":"6502FFC0-E19B-41FA-B152-885B339360F0@dafert.at","subject":"Re: Bug with branches/merges in submodules","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2021-07-14T12:25:36Z","receivedAt":"2021-07-14T12:25:40Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Mel,\n\nLe 2021-07-14 à 07:07, Mel Dafert a écrit :\n> Hello Philippe,\n> Thank you for your reply, and the points to the mailing list.\n> \n> \n> I would thus like to correct myself, and refile this as a feature request - it would\n> be very helpful to me to have this as an option, possibly even with one that can be set in the config, similar to\n> 'diff.submodule=log'.\n> \n> I would be open to implementing this - I might need some mentoring, however, as\n> this would be my first time contributing (and reading the git codebase).\n\nThat would great! The page \"Hacking Git\" [1] has several pointers to interesting\nressources to learn about the code and the contribution process. One of these is\nthe \"My First Contribution\" tutorial. [2]\n\nCheers,\n\nPhilippe.\n\n[1] https://git.github.io/Hacking-Git/\n[2] https://git-scm.com/docs/MyFirstContribution\n"}]}