diff options
author | Jiang Xin <zhiyou.jx@alibaba-inc.com> | 2020-12-17 02:57:09 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-12-17 06:21:06 +0100 |
commit | 0696232390d237b64f970e538177ecfd979020d0 (patch) | |
tree | 06369b56bef2d80649ab4a862c0dc6b4f6e31273 /builtin/pack-redundant.c | |
parent | Git 2.29.2 (diff) | |
download | git-0696232390d237b64f970e538177ecfd979020d0.tar.xz git-0696232390d237b64f970e538177ecfd979020d0.zip |
pack-redundant: fix crash when one packfile in repo
Command `git pack-redundant --all` will crash if there is only one
packfile in the repository. This is because, if there is only one
packfile in local_packs, `cmp_local_packs` will do nothing and will
leave `pl->unique_objects` as uninitialized.
Also add testcases for repository with no packfile and one packfile
in t5323.
Reported-by: Daniel C. Klauer <daniel.c.klauer@web.de>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/pack-redundant.c')
-rw-r--r-- | builtin/pack-redundant.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c index 178e3409b7..690775fa82 100644 --- a/builtin/pack-redundant.c +++ b/builtin/pack-redundant.c @@ -473,6 +473,12 @@ static void cmp_local_packs(void) { struct pack_list *subset, *pl = local_packs; + /* only one packfile */ + if (!pl->next) { + llist_init(&pl->unique_objects); + return; + } + while ((subset = pl)) { while ((subset = subset->next)) cmp_two_packs(pl, subset); |