{"thread":{"id":"11349","subject":"[PATCH] Improved submodule merge support","startedAt":"2007-12-18T19:50:28Z","lastAt":"2007-12-18T20:21:56Z","messageCount":2,"participants":["Finn Arne Gangstad","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"63658","messageId":"20071218195028.GA25510@pvv.org","threadId":"11349","inReplyTo":null,"subject":"[PATCH] Improved submodule merge support","fromName":"Finn Arne Gangstad","fromEmail":"finnag@pvv.org","sentAt":"2007-12-18T19:50:28Z","receivedAt":"2007-12-18T19:50:28Z","isPatch":true,"sender":{"key":"finnag@pvv.org","avatar":"https://gravatar.com/avatar/b421ddd58c3f0f93aa473e17b98bb8d53c221fef741746bc8cb59fae4ec6d95e?d=mp&s=160"},"body":"Currently merging submodules from a super module does not work at\nall, here is an example:\n\n$ git merge change1\nUpdating 41dee71..6dbd2d9\nFast forward\n sub-module |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\n$ git merge change2\nfatal: cannot read object 4a0b570e9b7c6fd36f964eb6ef55263834462235 'sub-module'\nMerge with strategy recursive failed.\n\n$ git status\n# On branch mergetest\nnothing to commit (working directory clean)\n\n$ git submodule status\n 4a0b570e9b7c6fd36f964eb6ef55263834462235 sub-module (undefined)\n\nSo - the merge simply failed, and git status has no clue what happened.\n\n\nWith the following patch, this happens instead:\n\n$ git merge change1\nUpdating 41dee71..6dbd2d9\nFast forward\n sub-module |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\n$ git merge change2\nAuto-merged sub-module\nCONFLICT (submodule): Merge conflict in sub-module - needs b65e6131a2705620a0b08a4ecc44427b9059e4e3\nAutomatic merge failed; fix conflicts and then commit the result.\n\n$ git status\nsub-module: needs merge\n# On branch mergetest\n# Changed but not updated:\n#   (use \"git add <file>...\" to update what will be committed)\n#\n#       unmerged:   sub-module\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\n$ git submodule status\n 11253a619a520fa4b2e2c2f83cb5c897170faafd sub-module (undefined)\n 4a0b570e9b7c6fd36f964eb6ef55263834462235 sub-module (undefined)\n b65e6131a2705620a0b08a4ecc44427b9059e4e3 sub-module (undefined)\n\n\nTo resolve this:\n\n$ cd sub-module\n$ git merge b65e6131a27\n$ cd ..\n$ git add sub-module\n$ git commit -m 'merged sub-module blablabla'\n$ git submodule status\n eb66300641185297648b2a71e41a66b2053fdae0 sub-module (undefined)\n\n\nSo it actually works in some sense, and you see what you need to merge\naftwards in the submodule.\n\n- Finn Arne\n\n\n-- >8 --\nImproved submodule merge support\n\nWhen merging conflicting submodule changes from a supermodule, generate\na conflict message saying what went wrong. Also leave the tree in a state\nwhere git status shows the conflict, and git submodule status gives the user\nenough information to do the merge manally. Previously this would just fail.\n\nSigned-off-by: Finn Arne Gangstad <finnag@pvv.org>\n---\n merge-recursive.c |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2a58dad..33ccc40 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -549,6 +549,10 @@ static void update_file_flags(const unsigned char *sha,\n \t\tvoid *buf;\n \t\tunsigned long size;\n \n+\t\tif (S_ISGITLINK(mode))\n+\t\t\tdie(\"cannot read object %s '%s': It is a submodule!\",\n+\t\t\t    sha1_to_hex(sha), path);\n+\n \t\tbuf = read_sha1_file(sha, &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"cannot read object %s '%s'\", sha1_to_hex(sha), path);\n@@ -1463,10 +1467,13 @@ static int process_entry(const char *path, struct stage_data *entry,\n \t\tmfi = merge_file(&o, &a, &b,\n \t\t\t\t branch1, branch2);\n \n+\t\tclean_merge = mfi.clean;\n \t\tif (mfi.clean)\n \t\t\tupdate_file(1, mfi.sha, mfi.mode, path);\n+\t\telse if (S_ISGITLINK(mfi.mode))\n+\t\t\toutput(1, \"CONFLICT (submodule): Merge conflict in %s \"\n+\t\t\t       \"- needs %s\", path, sha1_to_hex(b.sha1));\n \t\telse {\n-\t\t\tclean_merge = 0;\n \t\t\toutput(1, \"CONFLICT (%s): Merge conflict in %s\",\n \t\t\t\t\treason, path);\n \n-- \n1.5.4.rc0.67.gf9c5\n"},{"id":"63663","messageId":"Pine.LNX.4.64.0712182018190.23902@racer.site","threadId":"11349","inReplyTo":"20071218195028.GA25510@pvv.org","subject":"Re: [PATCH] Improved submodule merge support","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-12-18T20:21:56Z","receivedAt":"2007-12-18T20:21:56Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 18 Dec 2007, Finn Arne Gangstad wrote:\n\n> diff --git a/merge-recursive.c b/merge-recursive.c\n> index 2a58dad..33ccc40 100644\n> --- a/merge-recursive.c\n> +++ b/merge-recursive.c\n> @@ -1463,10 +1467,13 @@ static int process_entry(const char *path, struct stage_data *entry,\n>  \t\tmfi = merge_file(&o, &a, &b,\n>  \t\t\t\t branch1, branch2);\n>  \n> +\t\tclean_merge = mfi.clean;\n>  \t\tif (mfi.clean)\n>  \t\t\tupdate_file(1, mfi.sha, mfi.mode, path);\n> +\t\telse if (S_ISGITLINK(mfi.mode))\n> +\t\t\toutput(1, \"CONFLICT (submodule): Merge conflict in %s \"\n> +\t\t\t       \"- needs %s\", path, sha1_to_hex(b.sha1));\n>  \t\telse {\n> -\t\t\tclean_merge = 0;\n>  \t\t\toutput(1, \"CONFLICT (%s): Merge conflict in %s\",\n>  \t\t\t\t\treason, path);\n>  \n\nIt took me a little while to find that the unilateral assignment to \nclean_merge does not break things.  But as it was only set to 1 at the \nbeginning of the function, and no loops are involved, this change is \ncorrect.\n\nCiao,\nDscho\n"}]}