Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
server-info: do not list unlinked packs
author
Eric Wong
<e@80x24.org>
Thu, 23 May 2019 17:27:23 +0000
(17:27 +0000)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 28 May 2019 18:02:52 +0000
(11:02 -0700)
Having non-existent packs in objects/info/packs causes
dumb HTTP clients to abort.
v2: use single loop with ALLOC_GROW as suggested by Jeff King
Signed-off-by: Eric Wong <e@80x24.org>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
server-info.c
patch
|
blob
|
history
t/t6500-gc.sh
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
aa25c82
)
diff --git
a/server-info.c
b/server-info.c
index 41274d098bc3b07b7f0130e7b9efcc20873cf46d..92187c70db650ee0e4d5ea4bf3435e84a51c44b2 100644
(file)
--- a/
server-info.c
+++ b/
server-info.c
@@
-1,4
+1,5
@@
#include "cache.h"
#include "cache.h"
+#include "dir.h"
#include "repository.h"
#include "refs.h"
#include "object.h"
#include "repository.h"
#include "refs.h"
#include "object.h"
@@
-191,26
+192,21
@@
static void init_pack_info(const char *infofile, int force)
{
struct packed_git *p;
int stale;
{
struct packed_git *p;
int stale;
- int i = 0;
+ int i;
+ size_t alloc = 0;
for (p = get_all_packs(the_repository); p; p = p->next) {
/* we ignore things on alternate path since they are
* not available to the pullers in general.
*/
for (p = get_all_packs(the_repository); p; p = p->next) {
/* we ignore things on alternate path since they are
* not available to the pullers in general.
*/
- if (!p->pack_local)
- continue;
- i++;
- }
- num_pack = i;
- info = xcalloc(num_pack, sizeof(struct pack_info *));
- for (i = 0, p = get_all_packs(the_repository); p; p = p->next) {
- if (!p->pack_local)
+ if (!p->pack_local || !file_exists(p->pack_name))
continue;
continue;
- assert(i < num_pack);
+
+ i = num_pack++;
+ ALLOC_GROW(info, num_pack, alloc);
info[i] = xcalloc(1, sizeof(struct pack_info));
info[i]->p = p;
info[i]->old_num = -1;
info[i] = xcalloc(1, sizeof(struct pack_info));
info[i]->p = p;
info[i]->old_num = -1;
- i++;
}
if (infofile && !force)
}
if (infofile && !force)
diff --git
a/t/t6500-gc.sh
b/t/t6500-gc.sh
index 515c6735e9cb076c9f4b5a252c48216765b5076a..c0f04dc6b0e149173691e13c0194ffbd53be6ef8 100755
(executable)
--- a/
t/t6500-gc.sh
+++ b/
t/t6500-gc.sh
@@
-71,6
+71,8
@@
test_expect_success 'gc --keep-largest-pack' '
git gc --keep-largest-pack &&
( cd .git/objects/pack && ls *.pack ) >pack-list &&
test_line_count = 2 pack-list &&
git gc --keep-largest-pack &&
( cd .git/objects/pack && ls *.pack ) >pack-list &&
test_line_count = 2 pack-list &&
+ awk "/^P /{print \$2}" <.git/objects/info/packs >pack-info &&
+ test_line_count = 2 pack-info &&
test_path_is_file $BASE_PACK &&
git fsck
)
test_path_is_file $BASE_PACK &&
git fsck
)