{"thread":{"id":"5187","subject":"[PATCH] merge-recur: try to merge older merge bases first","startedAt":"2006-08-09T20:30:58Z","lastAt":"2006-08-09T20:30:58Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"25050","messageId":"Pine.LNX.4.63.0608092221590.13885@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"5187","inReplyTo":null,"subject":"[PATCH] merge-recur: try to merge older merge bases first","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-08-09T20:30:58Z","receivedAt":"2006-08-09T20:30:58Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nIt seems to be the only sane way to do it: when a two-head merge is\ndone, and the merge-base and one of the two branches agree, the\nmerge assumes that the other branch has something new.\n\nIf we start creating virtual commits from newer merge-bases, and go\nback to older merge-bases, and then merge with newer commits again,\nchances are that a patch is lost, _because_ the merge-base and the\nhead agree on it. Unlikely, yes, but it happened to me.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n merge-recursive.c |   16 +++++++++++++-\n 1 files changed, 13 insertions(+), 1 deletion(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex f5b547b..2d3ab4f 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -1191,6 +1191,17 @@ static int merge_trees(struct tree *head\n \treturn clean;\n }\n \n+static struct commit_list *reverse_commit_list(struct commit_list *list)\n+{\n+\tstruct commit_list *next = NULL, *current, *backup;\n+\tfor (current = list; current; current = backup) {\n+\t\tbackup = current->next;\n+\t\tcurrent->next = next;\n+\t\tnext = current;\n+\t}\n+\treturn next;\n+}\n+\n /*\n  * Merge the commits h1 and h2, return the resulting virtual\n  * commit object and a flag indicating the cleaness of the merge.\n@@ -1216,7 +1227,8 @@ int merge(struct commit *h1,\n \tif (ancestor)\n \t\tcommit_list_insert(ancestor, &ca);\n \telse\n-\t\tca = get_merge_bases(h1, h2, 1);\n+\t\tca = reverse_commit_list(get_merge_bases(h1, h2, 1));\n+\t\t//ca = get_merge_bases(h1, h2, 1);\n \n \toutput(\"found %u common ancestor(s):\", commit_list_count(ca));\n \tfor (iter = ca; iter; iter = iter->next)\n-- \n1.4.2.rc3.g29d0-dirty\n"}]}