From: Junio C Hamano Date: Fri, 9 Sep 2016 04:35:59 +0000 (-0700) Subject: Merge branch 'rs/merge-recursive-string-list-init' into maint X-Git-Tag: v2.9.4~8 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f14883b972f3d6b104c4d141fc3de34af9ba0b24?ds=inline;hp=-c Merge branch 'rs/merge-recursive-string-list-init' into maint A small code clean-up. * rs/merge-recursive-string-list-init: merge-recursive: use STRING_LIST_INIT_NODUP --- f14883b972f3d6b104c4d141fc3de34af9ba0b24 diff --combined merge-recursive.c index e7178bcdcc,3bba90850f..a52139eada --- a/merge-recursive.c +++ b/merge-recursive.c @@@ -42,9 -42,12 +42,9 @@@ static struct tree *shift_tree_object(s static struct commit *make_virtual_commit(struct tree *tree, const char *comment) { struct commit *commit = alloc_commit_node(); - struct merge_remote_desc *desc = xmalloc(sizeof(*desc)); - desc->name = comment; - desc->obj = (struct object *)commit; + set_merge_remote_desc(commit, comment, (struct object *)commit); commit->tree = tree; - commit->util = desc; commit->object.parsed = 1; return commit; } @@@ -199,21 -202,12 +199,21 @@@ static int add_cacheinfo(unsigned int m const char *path, int stage, int refresh, int options) { struct cache_entry *ce; - ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path, stage, - (refresh ? (CE_MATCH_REFRESH | - CE_MATCH_IGNORE_MISSING) : 0 )); + int ret; + + ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path, stage, 0); if (!ce) return error(_("addinfo_cache failed for path '%s'"), path); - return add_cache_entry(ce, options); + + ret = add_cache_entry(ce, options); + if (refresh) { + struct cache_entry *nce; + + nce = refresh_cache_entry(ce, CE_MATCH_REFRESH | CE_MATCH_IGNORE_MISSING); + if (nce != ce) + ret = add_cache_entry(nce, options); + } + return ret; } static void init_tree_desc_from_tree(struct tree_desc *desc, struct tree *tree) @@@ -406,7 -400,7 +406,7 @@@ static void record_df_conflict_files(st * and the file need to be present, then the D/F file will be * reinstated with a new unique name at the time it is processed. */ - struct string_list df_sorted_entries; + struct string_list df_sorted_entries = STRING_LIST_INIT_NODUP; const char *last_file = NULL; int last_len = 0; int i; @@@ -419,7 -413,6 +419,6 @@@ return; /* Ensure D/F conflicts are adjacent in the entries list. */ - memset(&df_sorted_entries, 0, sizeof(struct string_list)); for (i = 0; i < entries->nr; i++) { struct string_list_item *next = &entries->items[i]; string_list_append(&df_sorted_entries, next->string)->util =