Skip to content

Commit bf5eca8

Browse files
committed
Merge branch 'ps/pack-check-pack-first' into seen
The packfile registration code used to check ".pack" file the last after checking ".keep" and other files; the ordering is reversed. * ps/pack-check-pack-first: packfile: avoid access(3p) calls for missing packs
2 parents 7640e46 + 0bfb127 commit bf5eca8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packfile.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,12 @@ struct packed_git *add_packed_git(struct repository *r, const char *path,
737737
p = alloc_packed_git(r, alloc);
738738
memcpy(p->pack_name, path, path_len);
739739

740+
xsnprintf(p->pack_name + path_len, alloc - path_len, ".pack");
741+
if (stat(p->pack_name, &st) || !S_ISREG(st.st_mode)) {
742+
free(p);
743+
return NULL;
744+
}
745+
740746
xsnprintf(p->pack_name + path_len, alloc - path_len, ".keep");
741747
if (!access(p->pack_name, F_OK))
742748
p->pack_keep = 1;
@@ -749,11 +755,8 @@ struct packed_git *add_packed_git(struct repository *r, const char *path,
749755
if (!access(p->pack_name, F_OK))
750756
p->is_cruft = 1;
751757

758+
/* Restore the final packfile name. */
752759
xsnprintf(p->pack_name + path_len, alloc - path_len, ".pack");
753-
if (stat(p->pack_name, &st) || !S_ISREG(st.st_mode)) {
754-
free(p);
755-
return NULL;
756-
}
757760

758761
/* ok, it looks sane as far as we can check without
759762
* actually mapping the pack file.

0 commit comments

Comments
 (0)