summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-03-05 21:13:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-03-05 21:13:08 (GMT)
commitcbc8d6d8f8e858072faa2f8fd03d0f255fe0c288 (patch)
tree348aa7a55aa16299c5935e18bbe69acdc5129f10 /sha1_file.c
parentf5a191d3dcbd0deaae9eba2a141e0f086ea0eb20 (diff)
parentb0a4264277b7968741580093e7ea1e366943d297 (diff)
downloadgit-cbc8d6d8f8e858072faa2f8fd03d0f255fe0c288.zip
git-cbc8d6d8f8e858072faa2f8fd03d0f255fe0c288.tar.gz
git-cbc8d6d8f8e858072faa2f8fd03d0f255fe0c288.tar.bz2
Merge branch 'jk/prune-mtime' into maint
In v2.2.0, we broke "git prune" that runs in a repository that borrows from an alternate object store. * jk/prune-mtime: sha1_file: fix iterating loose alternate objects for_each_loose_file_in_objdir: take an optional strbuf path
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 30995e6..69a60ec 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -3359,31 +3359,42 @@ static int for_each_file_in_obj_subdir(int subdir_nr,
return r;
}
-int for_each_loose_file_in_objdir(const char *path,
+int for_each_loose_file_in_objdir_buf(struct strbuf *path,
each_loose_object_fn obj_cb,
each_loose_cruft_fn cruft_cb,
each_loose_subdir_fn subdir_cb,
void *data)
{
- struct strbuf buf = STRBUF_INIT;
- size_t baselen;
+ size_t baselen = path->len;
int r = 0;
int i;
- strbuf_addstr(&buf, path);
- strbuf_addch(&buf, '/');
- baselen = buf.len;
-
for (i = 0; i < 256; i++) {
- strbuf_addf(&buf, "%02x", i);
- r = for_each_file_in_obj_subdir(i, &buf, obj_cb, cruft_cb,
+ strbuf_addf(path, "/%02x", i);
+ r = for_each_file_in_obj_subdir(i, path, obj_cb, cruft_cb,
subdir_cb, data);
- strbuf_setlen(&buf, baselen);
+ strbuf_setlen(path, baselen);
if (r)
break;
}
+ return r;
+}
+
+int for_each_loose_file_in_objdir(const char *path,
+ each_loose_object_fn obj_cb,
+ each_loose_cruft_fn cruft_cb,
+ each_loose_subdir_fn subdir_cb,
+ void *data)
+{
+ struct strbuf buf = STRBUF_INIT;
+ int r;
+
+ strbuf_addstr(&buf, path);
+ r = for_each_loose_file_in_objdir_buf(&buf, obj_cb, cruft_cb,
+ subdir_cb, data);
strbuf_release(&buf);
+
return r;
}
@@ -3396,9 +3407,16 @@ static int loose_from_alt_odb(struct alternate_object_database *alt,
void *vdata)
{
struct loose_alt_odb_data *data = vdata;
- return for_each_loose_file_in_objdir(alt->base,
- data->cb, NULL, NULL,
- data->data);
+ struct strbuf buf = STRBUF_INIT;
+ int r;
+
+ /* copy base not including trailing '/' */
+ strbuf_add(&buf, alt->base, alt->name - alt->base - 1);
+ r = for_each_loose_file_in_objdir_buf(&buf,
+ data->cb, NULL, NULL,
+ data->data);
+ strbuf_release(&buf);
+ return r;
}
int for_each_loose_object(each_loose_object_fn cb, void *data)