]> git.ipfire.org Git - thirdparty/git.git/commit
checkout-index: handle "--no-index" option
authorJeff King <peff@peff.net>
Sun, 31 Jan 2016 11:29:36 +0000 (06:29 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Feb 2016 21:43:43 +0000 (13:43 -0800)
commit6a6df8aa45aa68df737d6c59d7abec499e9451da
treec77a49cf347bad89c00f7cc8869e3173ef259c96
parent5ed5f671c4193f2b9d47c08e989574903f3bf9cc
checkout-index: handle "--no-index" option

The parsing of "--index" is done in a callback, but it does
not handle an "unset" option. We don't necessarily expect
anyone to use this, but the current behavior is to treat it
exactly like "--index", which would probably be surprising.

Instead, let's just turn it into an OPT_BOOL, and handle it
after we're done parsing. This makes "--no-index" just work
(it cancels a previous "--index").

As a bonus, this makes the logic easier to follow. The old
code opened the index during the option parsing, leaving the
reader to wonder if there was some timing issue (there
isn't; none of the other options care that we've opened it).
And then if we found that "--prefix" had been given, we had
to rollback the index. Now we can simply avoid opening it in
the first place.

Note that it might make more sense for checkout-index to
complain when "--index --prefix=foo" is given (rather than
silently ignoring "--index"), but since it has been that way
since 415e96c ([PATCH] Implement git-checkout-cache -u to
update stat information in the cache., 2005-05-15), it's
safer to leave it as-is.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout-index.c