{"thread":{"id":"11945","subject":"[PATCH v2 05/11] Add \"skip_unmerged\" option to unpack_trees.","startedAt":"2008-02-07T16:40:02Z","lastAt":"2008-02-07T16:40:02Z","messageCount":1,"participants":["Daniel Barkalow"],"isPatch":true,"patchVersion":2,"patchTotal":11},"messages":[{"id":"67825","messageId":"alpine.LNX.1.00.0802071129130.13593@iabervon.org","threadId":"11945","inReplyTo":null,"subject":"[PATCH v2 05/11] Add \"skip_unmerged\" option to unpack_trees.","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-07T16:40:02Z","receivedAt":"2008-02-07T16:40:02Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"This option allows the caller to reset everything that isn't unmerged,\nleaving the unmerged things to be resolved. If, after a merge of\n\"working\" and \"HEAD\", this is used with \"HEAD\" (reset, !update), the\nresult will be that all of the changes from \"local\" are in the working\ntree but not added to the index (either with the index clean but\nunchanged, or with the index unmerged, depending on whether there are\nconflicts).\n\nThis will be used in checkout -m.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n unpack-trees.c |   20 +++++++++++++++++---\n unpack-trees.h |    1 +\n 2 files changed, 18 insertions(+), 3 deletions(-)\n\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 99aa45f..f9c4829 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -85,6 +85,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,\n \t\tint any_dirs = 0;\n \t\tchar *cache_name;\n \t\tint ce_stage;\n+\t\tint skip_entry = 0;\n \n \t\t/* Find the first name in the input. */\n \n@@ -153,6 +154,8 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,\n \t\t\tany_files = 1;\n \t\t\tsrc[0] = active_cache[o->pos];\n \t\t\tremove = o->pos;\n+\t\t\tif (o->skip_unmerged && ce_stage(src[0]))\n+\t\t\t\tskip_entry = 1;\n \t\t}\n \n \t\tfor (i = 0; i < len; i++) {\n@@ -181,6 +184,12 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,\n \t\t\t\tcontinue;\n \t\t\t}\n \n+\t\t\tif (skip_entry) {\n+\t\t\t\tsubposns[i] = df_conflict_list;\n+\t\t\t\tposns[i] = posns[i]->next;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n \t\t\tif (!o->merge)\n \t\t\t\tce_stage = 0;\n \t\t\telse if (i + 1 < o->head_idx)\n@@ -205,7 +214,13 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,\n \t\t\tposns[i] = posns[i]->next;\n \t\t}\n \t\tif (any_files) {\n-\t\t\tif (o->merge) {\n+\t\t\tif (skip_entry) {\n+\t\t\t\to->pos++;\n+\t\t\t\twhile (o->pos < active_nr &&\n+\t\t\t\t       !strcmp(active_cache[o->pos]->name,\n+\t\t\t\t\t       src[0]->name))\n+\t\t\t\t\to->pos++;\n+\t\t\t} else if (o->merge) {\n \t\t\t\tint ret;\n \n #if DBRT_DEBUG > 1\n@@ -731,9 +746,8 @@ int threeway_merge(struct cache_entry **stages,\n \t * If we have an entry in the index cache, then we want to\n \t * make sure that it matches head.\n \t */\n-\tif (index && !same(index, head)) {\n+\tif (index && !same(index, head))\n \t\treturn o->gently ? -1 : reject_merge(index);\n-\t}\n \n \tif (head) {\n \t\t/* #5ALT, #15 */\ndiff --git a/unpack-trees.h b/unpack-trees.h\nindex 83d1229..a2df544 100644\n--- a/unpack-trees.h\n+++ b/unpack-trees.h\n@@ -16,6 +16,7 @@ struct unpack_trees_options {\n \tint trivial_merges_only;\n \tint verbose_update;\n \tint aggressive;\n+\tint skip_unmerged;\n \tint gently;\n \tconst char *prefix;\n \tint pos;\n-- \n1.5.4\n"}]}