summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorStefan Beller <stefanbeller@googlemail.com>2013-08-03 11:51:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-08-07 15:37:02 (GMT)
commit5d4d1440ba992fe27b00f8a56862543bb27561e2 (patch)
tree90fe318df08eb03c6ddcb452c1d34f9af8ddf249 /builtin/rev-parse.c
parent21e047dcadaffc09cfc958e9014e84bf2237bfe8 (diff)
downloadgit-5d4d1440ba992fe27b00f8a56862543bb27561e2.zip
git-5d4d1440ba992fe27b00f8a56862543bb27561e2.tar.gz
git-5d4d1440ba992fe27b00f8a56862543bb27561e2.tar.bz2
checkout-index: fix negations of even numbers of -n
The --no-create was parsed with OPT_BOOLEAN, which has a counting up logic implemented. Since b04ba2bb (parse-options: deprecate OPT_BOOLEAN, 2011-09-27) the OPT_BOOLEAN is deprecated and is only a define: /* Deprecated synonym */ #define OPTION_BOOLEAN OPTION_COUNTUP However the variable not_new, which can be counted up by giving --no-create multiple times, is used to set a bit in the struct checkout bitfield (defined in cache.h:969, declared at builtin/checkout-index.c:19): state.not_new = not_new; When assigning a value other than 0 or 1 to a bit, all leading digits but the last are ignored and only the last bit is used for setting the bit variable. Hence the following: # in git.git: $ git status # working directory clean rm COPYING $ git status # deleted: COPYING $ git checkout-index -a -n $ git status # deleted: COPYING # which is expected as we're telling git to not restore or create # files, however: $ git checkout-index -a -n -n $ git status # working directory clean, COPYING is restored again! # That's the bug, we're fixing here. By restraining the variable not_new to a value being definitely 0 or 1 by the macro OPT_BOOL the bug is fixed. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rev-parse.c')
0 files changed, 0 insertions, 0 deletions