diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-04-25 16:41:13 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-25 16:41:13 +0900 |
commit | 776f3e1fb73a6440804aa3dde4ffd3b6bdf60a19 (patch) | |
tree | adc1c8098d096f35d890f874b8c1fe6fa91891fa /packfile.c | |
parent | Merge branch 'nd/diff-parseopt-4' (diff) | |
parent | update_info_refs(): drop unused force parameter (diff) | |
download | tgif-776f3e1fb73a6440804aa3dde4ffd3b6bdf60a19.tar.xz |
Merge branch 'jk/server-info-rabbit-hole'
Code clean-up around a much-less-important-than-it-used-to-be
update_server_info() funtion.
* jk/server-info-rabbit-hole:
update_info_refs(): drop unused force parameter
server-info: drop objdirlen pointer arithmetic
server-info: drop nr_alloc struct member
server-info: use strbuf to read old info/packs file
server-info: simplify cleanup in parse_pack_def()
server-info: fix blind pointer arithmetic
http: simplify parsing of remote objects/info/packs
packfile: fix pack basename computation
midx: check both pack and index names for containment
t5319: drop useless --buffer from cat-file
t5319: fix bogus cat-file argument
pack-revindex: open index if necessary
packfile.h: drop extern from function declarations
Diffstat (limited to 'packfile.c')
-rw-r--r-- | packfile.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/packfile.c b/packfile.c index d2bcb2f860..b5ec0eeddd 100644 --- a/packfile.c +++ b/packfile.c @@ -466,6 +466,16 @@ static unsigned int get_max_fd_limit(void) #endif } +const char *pack_basename(struct packed_git *p) +{ + const char *ret = strrchr(p->pack_name, '/'); + if (ret) + ret = ret + 1; /* skip past slash */ + else + ret = p->pack_name; /* we only have a base */ + return ret; +} + /* * Do not call this directly as this leaks p->pack_fd on error return; * call open_packed_git() instead. @@ -482,7 +492,7 @@ static int open_packed_git_1(struct packed_git *p) if (!p->index_data) { struct multi_pack_index *m; - const char *pack_name = strrchr(p->pack_name, '/'); + const char *pack_name = pack_basename(p); for (m = the_repository->objects->multi_pack_index; m; m = m->next) { @@ -2023,8 +2033,10 @@ int for_each_object_in_pack(struct packed_git *p, uint32_t i; int r = 0; - if (flags & FOR_EACH_OBJECT_PACK_ORDER) - load_pack_revindex(p); + if (flags & FOR_EACH_OBJECT_PACK_ORDER) { + if (load_pack_revindex(p)) + return -1; + } for (i = 0; i < p->num_objects; i++) { uint32_t pos; |