aboutsummaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-10-17 13:25:19 -0700
committerJunio C Hamano <gitster@pobox.com>2016-10-17 13:25:20 -0700
commitdec040192fde87fb3249a3d53f802decd84fa7b7 (patch)
tree7c73c3807033b62c98368ff2d3ca8ecbf20177b9 /sha1_name.c
parentaf9a70c8de7b1d45ecd0bbb1379c5c3e911a9dcd (diff)
parentea0fc3b4176a424a2b20eb76a6a503dc4d59cebb (diff)
downloadgit-dec040192fde87fb3249a3d53f802decd84fa7b7.tar.gz
git-dec040192fde87fb3249a3d53f802decd84fa7b7.tar.xz
Merge branch 'jk/alt-odb-cleanup'
Codepaths involved in interacting alternate object store have been cleaned up. * jk/alt-odb-cleanup: alternates: use fspathcmp to detect duplicates sha1_file: always allow relative paths to alternates count-objects: report alternates via verbose mode fill_sha1_file: write into a strbuf alternates: store scratch buffer as strbuf fill_sha1_file: write "boring" characters alternates: use a separate scratch space alternates: encapsulate alt->base munging alternates: provide helper for allocating alternate alternates: provide helper for adding to alternates list link_alt_odb_entry: refactor string handling link_alt_odb_entry: handle normalize_path errors t5613: clarify "too deep" recursion tests t5613: do not chdir in main process t5613: whitespace/style cleanups t5613: use test_must_fail t5613: drop test_valid_repo function t5613: drop reachable_via function
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 3b647fd7c..409283614 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -91,25 +91,18 @@ static void find_short_object_filename(struct disambiguate_state *ds)
* alt->name/alt->base while iterating over the
* object databases including our own.
*/
- const char *objdir = get_object_directory();
- size_t objdir_len = strlen(objdir);
- fakeent = xmalloc(st_add3(sizeof(*fakeent), objdir_len, 43));
- memcpy(fakeent->base, objdir, objdir_len);
- fakeent->name = fakeent->base + objdir_len + 1;
- fakeent->name[-1] = '/';
+ fakeent = alloc_alt_odb(get_object_directory());
}
fakeent->next = alt_odb_list;
xsnprintf(hex, sizeof(hex), "%.2s", ds->hex_pfx);
for (alt = fakeent; alt && !ds->ambiguous; alt = alt->next) {
+ struct strbuf *buf = alt_scratch_buf(alt);
struct dirent *de;
DIR *dir;
- /*
- * every alt_odb struct has 42 extra bytes after the base
- * for exactly this purpose
- */
- xsnprintf(alt->name, 42, "%.2s/", ds->hex_pfx);
- dir = opendir(alt->base);
+
+ strbuf_addf(buf, "%.2s/", ds->hex_pfx);
+ dir = opendir(buf->buf);
if (!dir)
continue;