Message ID | pull.1463.v3.git.git.1680025914.gitgitgadget@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | config.c: use struct for config reading state | expand |
"Glen Choo via GitGitGadget" <gitgitgadget@gmail.com> writes: > Note to Junio: 8/8 (which renames "cs" -> "set") conflicts with > ab/config-multi-and-nonbool. I previously said that I'd rebase this, but > presumably a remerge-diff is more ergonomic + flexible (let me know if I'm > mistaken), so I'll send a remerge-diff in a reply (I don't trust GGG not to > mangle the patch :/). diff --git a/config.c b/config.c remerge CONFLICT (content): Merge conflict in config.c index b17658e1ba..159c404d0c 100644 --- a/config.c +++ b/config.c @@ -2351,15 +2351,9 @@ void read_very_early_config(config_fn_t cb, void *data) config_with_options(cb, data, NULL, &opts); } -<<<<<<< HEAD -static struct config_set_element *configset_find_element(struct config_set *set, const char *key) -||||||| c000d91638 -static struct config_set_element *configset_find_element(struct config_set *cs, const char *key) -======= RESULT_MUST_BE_USED -static int configset_find_element(struct config_set *cs, const char *key, +static int configset_find_element(struct config_set *set, const char *key, struct config_set_element **dest) ->>>>>>> gitster/ab/config-multi-and-nonbool { struct config_set_element k; struct config_set_element *found_entry; @@ -2392,15 +2386,9 @@ static int configset_add_value(struct config_reader *reader, struct key_value_info *kv_info = xmalloc(sizeof(*kv_info)); int ret; -<<<<<<< HEAD - e = configset_find_element(set, key); -||||||| c000d91638 - e = configset_find_element(cs, key); -======= - ret = configset_find_element(cs, key, &e); + ret = configset_find_element(set, key, &e); if (ret) return ret; ->>>>>>> gitster/ab/config-multi-and-nonbool /* * Since the keys are being fed by git_config*() callback mechanism, they * are already normalized. So simply add them without any further munging. @@ -2510,40 +2498,21 @@ int git_configset_get_value(struct config_set *set, const char *key, const char * queried key in the files of the configset, the value returned will be the last * value in the value list for that key. */ -<<<<<<< HEAD - values = git_configset_get_value_multi(set, key); -||||||| c000d91638 - values = git_configset_get_value_multi(cs, key); -======= - if ((ret = git_configset_get_value_multi(cs, key, &values))) + if ((ret = git_configset_get_value_multi(set, key, &values))) return ret; ->>>>>>> gitster/ab/config-multi-and-nonbool assert(values->nr > 0); *value = values->items[values->nr - 1].string; return 0; } -<<<<<<< HEAD -const struct string_list *git_configset_get_value_multi(struct config_set *set, const char *key) -||||||| c000d91638 -const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key) -======= -int git_configset_get_value_multi(struct config_set *cs, const char *key, +int git_configset_get_value_multi(struct config_set *set, const char *key, const struct string_list **dest) ->>>>>>> gitster/ab/config-multi-and-nonbool -{ -<<<<<<< HEAD - struct config_set_element *e = configset_find_element(set, key); - return e ? &e->value_list : NULL; -||||||| c000d91638 - struct config_set_element *e = configset_find_element(cs, key); - return e ? &e->value_list : NULL; -======= +{ struct config_set_element *e; int ret; - if ((ret = configset_find_element(cs, key, &e))) + if ((ret = configset_find_element(set, key, &e))) return ret; else if (!e) return 1; @@ -2557,12 +2526,12 @@ static int check_multi_string(struct string_list_item *item, void *util) return item->string ? 0 : config_error_nonbool(util); } -int git_configset_get_string_multi(struct config_set *cs, const char *key, +int git_configset_get_string_multi(struct config_set *set, const char *key, const struct string_list **dest) { int ret; - if ((ret = git_configset_get_value_multi(cs, key, dest))) + if ((ret = git_configset_get_value_multi(set, key, dest))) return ret; if ((ret = for_each_string_list((struct string_list *)*dest, check_multi_string, (void *)key))) @@ -2571,17 +2540,16 @@ int git_configset_get_string_multi(struct config_set *cs, const char *key, return 0; } -int git_configset_get(struct config_set *cs, const char *key) +int git_configset_get(struct config_set *set, const char *key) { struct config_set_element *e; int ret; - if ((ret = configset_find_element(cs, key, &e))) + if ((ret = configset_find_element(set, key, &e))) return ret; else if (!e) return 1; return 0; ->>>>>>> gitster/ab/config-multi-and-nonbool } int git_configset_get_string(struct config_set *set, const char *key, char **dest)
Glen Choo <chooglen@google.com> writes: > "Glen Choo via GitGitGadget" <gitgitgadget@gmail.com> writes: > >> Note to Junio: 8/8 (which renames "cs" -> "set") conflicts with >> ab/config-multi-and-nonbool. I previously said that I'd rebase this, but >> presumably a remerge-diff is more ergonomic + flexible (let me know if I'm >> mistaken), so I'll send a remerge-diff in a reply (I don't trust GGG not to >> mangle the patch :/). A patch that is indented by two places would not be mechanically applicable anyway and even without such indentation, the hunk-side markers like c000d91638, gitster/ab/config-multi-and-nonbool, etc. you have in the patch would be different from conflicts I would see, so it wouldn't be very useful. There should probably be a mode where remerge-diff would omit these labels to help mechanical application of such a "patch". In any case, remerge-diff certainly helps eyeballing the result. In this case, because the difference between v2 and v3 does not overlap with the area that v2 (or v3 for that matter) would conflict with other topics in flight, my rerere database can clealy reuse the recorded resolution for conflicts between this iteration and the topics in flight just fine. I'll push out the integration result after I am done with other topics. Thanks.
Junio C Hamano <gitster@pobox.com> writes: > Glen Choo <chooglen@google.com> writes: > >> "Glen Choo via GitGitGadget" <gitgitgadget@gmail.com> writes: >> >>> Note to Junio: 8/8 (which renames "cs" -> "set") conflicts with >>> ab/config-multi-and-nonbool. I previously said that I'd rebase this, but >>> presumably a remerge-diff is more ergonomic + flexible (let me know if I'm >>> mistaken), so I'll send a remerge-diff in a reply (I don't trust GGG not to >>> mangle the patch :/). > > A patch that is indented by two places would not be mechanically > applicable anyway and even without such indentation, the hunk-side > markers like c000d91638, gitster/ab/config-multi-and-nonbool, etc. > you have in the patch would be different from conflicts I would see, > so it wouldn't be very useful. There should probably be a mode > where remerge-diff would omit these labels to help mechanical > application of such a "patch". Ah, bummer :( I was thinking about that as well. remerge-diff actually outputs left and right in "--format=reference", which I then manually modified to reflect the conflicted version in the working tree, giving the final result here. I wonder what remerge-diff or "git apply" could do instead.