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

Re: [PATCH 2/6] diff-merges: move specific diff-index "-m" handling to diff-index

From: Junio C Hamano <hidden>
Date: 2021-05-11 05:23:52

Junio C Hamano [off-list ref] writes:
This change is risky, as the loop below (which this patch moves to
parse_distinct_options()) has no knowledge of other options that
setup_revisions() helper is prepared to handle and that takes an
argument.  When parsing "git cmd --opt --cached A", setup_revisions()
may know that --opt takes an argument and eat both (i.e. the
"--cached" is not an option but an arg given to "--opt"), but the
new parse_distinct_options() helper does not; it will happily skip
"--opt" and leave it in, mistake "--cached" as an option and remove,
and instead make "A" the arg given to "--opt".
The above is not theoretical.  The series breaks

    $ git checkout master
    $ git diff-index -S --cached maint

IOW, what I predicted in the previous message with s/--opt/-S/
happens with this step.
Picking up the remnant _after_ setup_revisions() ate what it
understands would not have such a downside, as long as none of our
"distinct options" take any argument.

Can't we make "-m means something special for diff-index" without
butchering the command line processing in this step?  diff-index
does not care about --diff-merges, so letting setup_revisions()
remember only the fact that "-m" was given while parsing, and then
postprocess what "-m" means depending on the command (i.e. everybody
else would treat it as a short-hand for "--diff-merges=m" plus "we
need some form of diff output, while allowing "diff-index" to treat
it differently) should not be rocket science.

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