summaryrefslogtreecommitdiff
path: root/builtin/checkout-index.c
AgeCommit message (Collapse)Author
2013-10-30Merge branch 'nd/lift-path-max'Junio C Hamano
* nd/lift-path-max: checkout_entry(): clarify the use of topath[] parameter entry.c: convert checkout_entry to use strbuf
2013-10-24checkout_entry(): clarify the use of topath[] parameterJunio C Hamano
The said function has this signature: extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath); At first glance, it might appear that the caller of checkout_entry() can specify to which path the contents are written out by the last parameter, and it is tempting to add "const" in front of its type. In reality, however, topath[] is to point at a buffer to store the temporary path generated by the callchain originating from this function, and the temporary path is always short, much shorter than the buffer prepared by its only caller in builtin/checkout-index.c. Document the code a bit to clarify so that future callers know how to use the function better. Noticed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-07checkout-index: fix negations of even numbers of -nStefan Beller
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>
2013-08-05Replace deprecated OPT_BOOLEAN by OPT_BOOLStefan Beller
This task emerged from b04ba2bb (parse-options: deprecate OPT_BOOLEAN, 2011-09-27). All occurrences of the respective variables have been reviewed and none of them relied on the counting up mechanism, but all of them were using the variable as a true boolean. This patch does not change semantics of any command intentionally. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-22Use imperative form in help usage to describe an actionNguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-20i18n: checkout-index: mark parseopt strings for translationNguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-17checkout-index: remove obsolete commentNguyễn Thái Ngọc Duy
The first paragraph about flag order is no longer true and is mentioned in git-checkout-index.txt. The rest is also mentioned in git-checkout-index.txt. Remove it and keep uptodate document in one place. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-12-13Merge branch 'jn/git-cmd-h-bypass-setup'Junio C Hamano
* jn/git-cmd-h-bypass-setup: update-index -h: show usage even with corrupt index merge -h: show usage even with corrupt index ls-files -h: show usage even with corrupt index gc -h: show usage even with broken configuration commit/status -h: show usage even with broken configuration checkout-index -h: show usage even in an invalid repository branch -h: show usage even in an invalid repository Conflicts: builtin/merge.c
2010-11-15Describe various forms of "be quiet" using OPT__QUIETJonathan Nieder
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-15add OPT__FORCERené Scharfe
Add OPT__FORCE as a helper macro in the same spirit as OPT__VERBOSE et.al. to simplify defining -f/--force options. Signed-off-by: Rene Scharfe <rene.scharfe@lstfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-15add description parameter to OPT__QUIETRené Scharfe
Allows better help text to be defined than "be quiet". Also make use of the macro in a place that already had a different description. No object code changes intended. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-22checkout-index -h: show usage even in an invalid repositoryNguyễn Thái Ngọc Duy
checkout-index loads the index before parsing options. Erroring out is counterproductive at that point if the operator is hunting for a command to recover useful data from the broken repository. [jn: new commit message, tests] Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-08Fix {update,checkout}-index usage stringsŠtěpán Němec
The `<file>' argument is optional in both cases (the man pages are already correct). Signed-off-by: Štěpán Němec <stepnem@gmail.com> Acked-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-22Move 'builtin-*' into a 'builtin/' subdirectoryLinus Torvalds
This shrinks the top-level directory a bit, and makes it much more pleasant to use auto-completion on the thing. Instead of [torvalds@nehalem git]$ em buil<tab> Display all 180 possibilities? (y or n) [torvalds@nehalem git]$ em builtin-sh builtin-shortlog.c builtin-show-branch.c builtin-show-ref.c builtin-shortlog.o builtin-show-branch.o builtin-show-ref.o [torvalds@nehalem git]$ em builtin-shor<tab> builtin-shortlog.c builtin-shortlog.o [torvalds@nehalem git]$ em builtin-shortlog.c you get [torvalds@nehalem git]$ em buil<tab> [type] builtin/ builtin.h [torvalds@nehalem git]$ em builtin [auto-completes to] [torvalds@nehalem git]$ em builtin/sh<tab> [type] shortlog.c shortlog.o show-branch.c show-branch.o show-ref.c show-ref.o [torvalds@nehalem git]$ em builtin/sho [auto-completes to] [torvalds@nehalem git]$ em builtin/shor<tab> [type] shortlog.c shortlog.o [torvalds@nehalem git]$ em builtin/shortlog.c which doesn't seem all that different, but not having that annoying break in "Display all 180 possibilities?" is quite a relief. NOTE! If you do this in a clean tree (no object files etc), or using an editor that has auto-completion rules that ignores '*.o' files, you won't see that annoying 'Display all 180 possibilities?' message - it will just show the choices instead. I think bash has some cut-off around 100 choices or something. So the reason I see this is that I'm using an odd editory, and thus don't have the rules to cut down on auto-completion. But you can simulate that by using 'ls' instead, or something similar. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>