]> git.ipfire.org Git - thirdparty/git.git/commit - diff.c
diff-parseopt: restore -U (no argument) behavior
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Wed, 29 May 2019 09:11:15 +0000 (16:11 +0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 May 2019 18:04:32 +0000 (11:04 -0700)
commit8ef05193bcdda6a28cd41fa3ecd8f356061d49e0
treed320df22f655cd124361fc5b93f564437dcb65de
parent7f125ff9094bfebbb381afa19380943a088c8fcb
diff-parseopt: restore -U (no argument) behavior

Before d473e2e0e8 (diff.c: convert -U|--unified, 2019-01-27), -U and
--unified are implemented with a custom parser opt_arg() in diff.c. I
didn't check this code carefully and not realize that it's the
equivalent of PARSE_OPT_NONEG | PARSE_OPT_OPTARG.

In other words, if -U is specified without any argument, the option
should be accepted, and the default value should be used. Without
PARSE_OPT_OPTARG, parse_options() will reject this case and cause a
regression.

Reported-by: Bryan Turner <bturner@atlassian.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
t/t4013-diff-various.sh
t/t4013/diff.diff_-U1_initial..side [new file with mode: 0644]
t/t4013/diff.diff_-U2_initial..side [new file with mode: 0644]
t/t4013/diff.diff_-U_initial..side [new file with mode: 0644]