summaryrefslogtreecommitdiffstats
path: root/oidset.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-06-14 08:50:37 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-14 19:26:34 +0200
commitafa2c6ddc88db766d16d471aa12b5db6bac39158 (patch)
tree9dbfa93ebba4c33ab4bbb3af6abddb6cafeb2ae5 /oidset.h
parenthash-ll: merge with "hash.h" (diff)
downloadgit-afa2c6ddc88db766d16d471aa12b5db6bac39158.tar.xz
git-afa2c6ddc88db766d16d471aa12b5db6bac39158.zip
http-fetch: don't crash when parsing packfile without a repo
The git-http-fetch(1) command accepts a `--packfile=` option, which allows the user to specify that it shall fetch a specific packfile, only. The parameter here is the hash of the packfile, which is specific to the object hash used by the repository. This requirement is implicit though via our use of `parse_oid_hex()`, which internally uses `the_repository`. The git-http-fetch(1) command allows for there to be no repository though, which only exists such that we can show usage via the "-h" option. In that case though, starting with c8aed5e8da (repository: stop setting SHA1 as the default object hash, 2024-05-07), `the_repository` does not have its object hash initialized anymore and thus we would crash when trying to parse the object ID outside of a repository. Fix this issue by dying immediately when we see a "--packfile=" parameter when outside a Git repository. This is not a functional regression as we would die later on with the same error anyway. Add a test to detect the segfault. We use the "nongit" function to do so, which we need to allow-list in `test_must_fail ()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'oidset.h')
0 files changed, 0 insertions, 0 deletions