rev-parse: fix segfault with missing --path-format argument
authorWolfgang Müller <wolf@oriole.systems>
Mon, 17 May 2021 08:02:42 +0000 (10:02 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 May 2021 09:39:29 +0000 (18:39 +0900)
commit99fc555188681caeedc983b9fc982d6dc8ee2a8c
treec572e55b79db540fe660e753a8c9d9a606b28203
parent48bf2fa8bad054d66bd79c6ba903c89c704201f7
rev-parse: fix segfault with missing --path-format argument

Calling "git rev-parse --path-format" without an argument segfaults
instead of giving an error message. Commit fac60b8925 (rev-parse: add
option for absolute or relative path formatting, 2020-12-13) added the
argument parsing code but forgot to handle NULL.

Returning an error makes sense here because there is no default value we
could use. Add a test case to verify.

Signed-off-by: Wolfgang Müller <wolf@oriole.systems>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rev-parse.c
t/t1500-rev-parse.sh