Thread (1 message) 1 message, 1 author, 2021-11-09

Re: [PATCH 2/2] parse-options.c: use "enum parse_opt_result" for parse_nodash_opt()

From: Junio C Hamano <hidden>
Date: 2021-11-09 23:37:16

Ævar Arnfjörð Bjarmason [off-list ref] writes:
quoted
quoted
-	return -2;
+	return PARSE_OPT_ERROR;
 }
The current caller only checks to skip a token that yields 0 (aka
PARSE_OPT_DONE) and does not distinguish between other values, so
this won't change the behaviour of the current code, but it is 
not clear if returning -1 (aka PARSE_OPT_ERROR) is better than -2
(aka PARSE_OPT_HELP).
I think PARSE_OPT_ERROR is probably better.

It looks like the -2 return value might have been somewhat blindly
copy/pasted between 07fe54db3cd (parse-opt: do not print errors on
unknown options, return -2 intead., 2008-06-23) and 51a9949eda7
(parseopt: add PARSE_OPT_NODASH, 2009-05-07).

I.e. we use the full enum values for the code in the former, but in the
latter we're just looking for "not zero", so error/-1 seemed like a
better fit.
OK.  That sounds like a good explanation for the change, to be
recorded in the proposed log message.

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help