Thread (34 messages) 34 messages, 3 authors, 2016-06-15

Re: [PATCH 22/24] Let usage() take a printf-style format

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:42

Jonathan Nieder [off-list ref] writes:
merge-recursive and diff --no-index are not able to use usage()
because their usage strings depend on the circumstances in which
they are called.
Since die() and warn() are already printf-like, it may be tempting
to do this, but this is wrong.

I do not want to vet all the existing call sites to usage() of make sure
that all of them _happen_ to pass constant strings that do not have any
'%' in them.

Much more importantly, without a patch to future-proof all existing
callsites to modify from

	usage(blame_usage);

to

	usage("%s", blame_usage);

everybody needs to remember that some *_usage strings are special and have
to double % in it forever, which is a maintenance nightmare.

Besides, the majority of usage strings are _expected_ to be constant.
That is an important difference from die/warn whose purpose is to diagnose
and give appropriate message to the situation (hence they benefit from
formatting).

I've renamed this to usagef() and updated your two callers to use it in
the version I queued to 'pu'.

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