diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-05-04 18:51:29 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-05-04 18:51:29 +0200 |
commit | 8b28e2e2e4abd0e9cffe0d85afd6f0c0346bb948 (patch) | |
tree | 1d26582328b9c1075f8e84a401e76f1262eb0b0d /midx.c | |
parent | Merge branch 'jc/cocci-xstrdup-or-null-fix' (diff) | |
parent | cache: use const char * for get_object_directory() (diff) | |
download | git-8b28e2e2e4abd0e9cffe0d85afd6f0c0346bb948.tar.xz git-8b28e2e2e4abd0e9cffe0d85afd6f0c0346bb948.zip |
Merge branch 'ds/midx-normalize-pathname-before-comparison'
The path taken by "git multi-pack-index" command from the end user
was compared with path internally prepared by the tool withut first
normalizing, which lead to duplicated paths not being noticed,
which has been corrected.
* ds/midx-normalize-pathname-before-comparison:
cache: use const char * for get_object_directory()
multi-pack-index: use --object-dir real path
midx: use real paths in lookup_multi_pack_index()
Diffstat (limited to 'midx.c')
-rw-r--r-- | midx.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -1132,17 +1132,26 @@ cleanup: static struct multi_pack_index *lookup_multi_pack_index(struct repository *r, const char *object_dir) { + struct multi_pack_index *result = NULL; struct multi_pack_index *cur; + char *obj_dir_real = real_pathdup(object_dir, 1); + struct strbuf cur_path_real = STRBUF_INIT; /* Ensure the given object_dir is local, or a known alternate. */ - find_odb(r, object_dir); + find_odb(r, obj_dir_real); for (cur = get_multi_pack_index(r); cur; cur = cur->next) { - if (!strcmp(object_dir, cur->object_dir)) - return cur; + strbuf_realpath(&cur_path_real, cur->object_dir, 1); + if (!strcmp(obj_dir_real, cur_path_real.buf)) { + result = cur; + goto cleanup; + } } - return NULL; +cleanup: + free(obj_dir_real); + strbuf_release(&cur_path_real); + return result; } static int write_midx_internal(const char *object_dir, |