summaryrefslogtreecommitdiff
path: root/builtin
AgeCommit message (Collapse)AuthorFilesLines
2013-09-17Merge branch 'fc/trivial'Libravatar Junio C Hamano2-12/+9
* fc/trivial: pull: use $curr_branch_short more add: trivial style cleanup reset: trivial style cleanup branch: trivial style fix reset: trivial refactoring
2013-09-17Merge branch 'fc/fast-export'Libravatar Junio C Hamano1-40/+47
Code simpification. * fc/fast-export: fast-export: refactor get_tags_and_duplicates() fast-export: make extra_refs global
2013-09-17Merge branch 'ap/commit-author-mailmap'Libravatar Junio C Hamano1-1/+7
"git commit --author=$name", when $name is not in the canonical "A. U. Thor <au.thor@example.xz>" format, looks for a matching name from existing history, but did not consult mailmap to grab the preferred author name. * ap/commit-author-mailmap: commit: search author pattern against mailmap
2013-09-17Merge branch 'jk/free-tree-buffer'Libravatar Junio C Hamano3-11/+10
* jk/free-tree-buffer: clear parsed flag when we free tree buffers
2013-09-12Merge branch 'jk/config-int-range-check'Libravatar Junio C Hamano1-3/+4
"git config" did not provide a way to set or access numbers larger than a native "int" on the platform; it now provides 64-bit signed integers on all platforms. * jk/config-int-range-check: git-config: always treat --int as 64-bit internally config: make numeric parsing errors more clear config: set errno in numeric git_parse_* functions config: properly range-check integer values config: factor out integer parsing from range checks
2013-09-11Merge branch 'jc/ls-files-killed-optim'Libravatar Junio C Hamano1-0/+2
"git ls-files -k" needs to crawl only the part of the working tree that may overlap the paths in the index to find killed files, but shared code with the logic to find all the untracked files, which made it unnecessarily inefficient. * jc/ls-files-killed-optim: dir.c::test_one_path(): work around directory_exists_in_index_icase() breakage t3010: update to demonstrate "ls-files -k" optimization pitfalls ls-files -k: a directory only can be killed if the index has a non-directory dir.c: use the cache_* macro to access the current index
2013-09-11Merge branch 'nd/push-no-thin'Libravatar Junio C Hamano2-4/+9
"git push --no-thin" was a no-op by mistake. * nd/push-no-thin: push: respect --no-thin
2013-09-09Merge branch 'nd/magic-pathspec'Libravatar Junio C Hamano2-14/+1
Use "struct pathspec" interface in more places, instead of array of characters, the latter of which cannot express magic pathspecs (e.g. ":(icase)makefile" that matches both Makefile and makefile). * nd/magic-pathspec: add: lift the pathspec magic restriction on "add -p" pathspec: catch prepending :(prefix) on pathspec with short magic
2013-09-09Merge branch 'jc/transport-do-not-use-connect-twice-in-fetch'Libravatar Junio C Hamano1-33/+56
The auto-tag-following code in "git fetch" tries to reuse the same transport twice when the serving end does not cooperate and does not give tags that point to commits that are asked for as part of the primary transfer. Unfortunately, Git-aware transport helper interface is not designed to be used more than once, hence this does not work over smart-http transfer. * jc/transport-do-not-use-connect-twice-in-fetch: builtin/fetch.c: Fix a sparse warning fetch: work around "transport-take-over" hack fetch: refactor code that fetches leftover tags fetch: refactor code that prepares a transport fetch: rename file-scope global "transport" to "gtransport" t5802: add test for connect helper
2013-09-09Merge branch 'jc/url-match'Libravatar Junio C Hamano1-21/+119
Allow section.<urlpattern>.var configuration variables to be treated as a "virtual" section.var given a URL, and use the mechanism to enhance http.* configuration variables. This is a reroll of Kyle J. McKay's work. * jc/url-match: builtin/config.c: compilation fix config: "git config --get-urlmatch" parses section.<url>.key builtin/config: refactor collect_config() config: parse http.<url>.<variable> using urlmatch config: add generic callback wrapper to parse section.<url>.key config: add helper to normalize and match URLs http.c: fix parsing of http.sslCertPasswordProtected variable
2013-09-09Merge branch 'jl/submodule-mv'Libravatar Junio C Hamano18-320/+360
"git mv A B" when moving a submodule A does "the right thing", inclusing relocating its working tree and adjusting the paths in the .gitmodules file. * jl/submodule-mv: (53 commits) rm: delete .gitmodules entry of submodules removed from the work tree mv: update the path entry in .gitmodules for moved submodules submodule.c: add .gitmodules staging helper functions mv: move submodules using a gitfile mv: move submodules together with their work trees rm: do not set a variable twice without intermediate reading. t6131 - skip tests if on case-insensitive file system parse_pathspec: accept :(icase)path syntax pathspec: support :(glob) syntax pathspec: make --literal-pathspecs disable pathspec magic pathspec: support :(literal) syntax for noglob pathspec kill limit_pathspec_to_literal() as it's only used by parse_pathspec() parse_pathspec: preserve prefix length via PATHSPEC_PREFIX_ORIGIN parse_pathspec: make sure the prefix part is wildcard-free rename field "raw" to "_raw" in struct pathspec tree-diff: remove the use of pathspec's raw[] in follow-rename codepath remove match_pathspec() in favor of match_pathspec_depth() remove init_pathspec() in favor of parse_pathspec() remove diff_tree_{setup,release}_paths convert common_prefix() to use struct pathspec ...
2013-09-09Merge branch 'es/blame-L-twice'Libravatar Junio C Hamano1-43/+50
Teaches "git blame" to take more than one -L ranges. * es/blame-L-twice: line-range: reject -L line numbers less than 1 t8001/t8002: blame: add tests of -L line numbers less than 1 line-range: teach -L^:RE to search from start of file line-range: teach -L:RE to search from end of previous -L range line-range: teach -L^/RE/ to search from start of file line-range-format.txt: document -L/RE/ relative search log: teach -L/RE/ to search from end of previous -L range blame: teach -L/RE/ to search from end of previous -L range line-range: teach -L/RE/ to search relative to anchor point blame: document multiple -L support t8001/t8002: blame: add tests of multiple -L options blame: accept multiple -L ranges blame: inline one-line function into its lone caller range-set: publish API for re-use by git-blame -L line-range-format.txt: clarify -L:regex usage form git-log.txt: place each -L option variation on its own line
2013-09-09Merge branch 'jk/cat-file-batch-optim'Libravatar Junio C Hamano1-1/+30
Rework the reverted change to `cat-file --batch-check`. * jk/cat-file-batch-optim: cat-file: only split on whitespace when %(rest) is used
2013-09-09Merge branch 'es/blame-L-more'Libravatar Junio C Hamano1-2/+2
More fixes to the code to parse the "-L" option in "log" and "blame". * es/blame-L-more: blame: reject empty ranges -L,+0 and -L,-0 t8001/t8002: blame: demonstrate acceptance of bogus -L,+0 and -L,-0 blame: reject empty ranges -LX,+0 and -LX,-0 t8001/t8002: blame: demonstrate acceptance of bogus -LX,+0 and -LX,-0 log: fix -L bounds checking bug t4211: retire soon-to-be unimplementable tests t4211: log: demonstrate -L bounds checking bug blame: fix -L bounds checking bug t8001/t8002: blame: add empty file & partial-line tests t8001/t8002: blame: demonstrate -L bounds checking bug t8001/t8002: blame: decompose overly-large test
2013-09-09Merge branch 'jc/push-cas'Libravatar Junio C Hamano4-0/+42
Allow a safer "rewind of the remote tip" push than blind "--force", by requiring that the overwritten remote ref to be unchanged since the new history to replace it was prepared. The machinery is more or less ready. The "--force" option is again the big red button to override any safety, thanks to J6t's sanity (the original round allowed --lockref to defeat --force). The logic to choose the default implemented here is fragile (e.g. "git fetch" after seeing a failure will update the remote-tracking branch and will make the next "push" pass, defeating the safety pretty easily). It is suitable only for the simplest workflows, and it may hurt users more than it helps them. * jc/push-cas: push: teach --force-with-lease to smart-http transport send-pack: fix parsing of --force-with-lease option t5540/5541: smart-http does not support "--force-with-lease" t5533: test "push --force-with-lease" push --force-with-lease: tie it all together push --force-with-lease: implement logic to populate old_sha1_expect[] remote.c: add command line option parser for "--force-with-lease" builtin/push.c: use OPT_BOOL, not OPT_BOOLEAN cache.h: move remote/connect API out of it
2013-09-09Merge branch 'nd/clone-connectivity-shortcut'Libravatar Junio C Hamano1-0/+9
* nd/clone-connectivity-shortcut: smart http: use the same connectivity check on cloning
2013-09-09Merge branch 'ms/fetch-prune-configuration'Libravatar Junio C Hamano1-3/+32
Allow fetch.prune and remote.*.prune configuration variables to be set, and "git fetch" to behave as if "--prune" is given. "git fetch" that honors remote.*.prune is fine, but I wonder if we should somehow make "git push" aware of it as well. Perhaps remote.*.prune should not be just a boolean, but a 4-way "none", "push", "fetch", "both"? * ms/fetch-prune-configuration: fetch: make --prune configurable
2013-09-09git-config: always treat --int as 64-bit internallyLibravatar Jeff King1-3/+4
When you run "git config --int", the maximum size of integer you get depends on how git was compiled, and what it considers to be an "int". This is almost useful, because your scripts calling "git config" will behave similarly to git internally. But relying on this is dubious; you have to actually know how git treats each value internally (e.g., int versus unsigned long), which is not documented and is subject to change. And even if you know it is "unsigned long", we do not have a git-config option to match that behavior. Furthermore, you may simply be asking git to store a value on your behalf (e.g., configuration for a hook). In that case, the relevant range check has nothing at all to do with git, but rather with whatever scripting tools you are using (and git has no way of knowing what the appropriate range is there). Not only is the range check useless, but it is actively harmful, as there is no way at all for scripts to look at config variables with large values. For instance, one cannot reliably get the value of pack.packSizeLimit via git-config. On an LP64 system, git happily uses a 64-bit "unsigned long" internally to represent the value, but the script cannot read any value over 2G. Ideally, the "--int" option would simply represent an arbitrarily large integer. For practical purposes, however, a 64-bit integer is large enough, and is much easier to implement (and if somebody overflows it, we will still notice the problem, and not simply return garbage). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-05add: lift the pathspec magic restriction on "add -p"Libravatar Nguyễn Thái Ngọc Duy2-14/+1
Since 480ca64 (convert run_add_interactive to use struct pathspec - 2013-07-14), we have unconditionally passed :(prefix)xxx to add-interactive.perl. It implies that all commands add-interactive.perl calls must be aware of pathspec magic, or :(prefix) is barfed. The restriction to :/ only becomes unnecessary. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-04Merge branch 'sb/parseopt-boolean-removal'Libravatar Junio C Hamano40-315/+276
Convert most uses of OPT_BOOLEAN/OPTION_BOOLEAN that can use OPT_BOOL/OPTION_BOOLEAN which have much saner semantics, and turn remaining ones into OPT_SET_INT, OPT_COUNTUP, etc. as necessary. * sb/parseopt-boolean-removal: revert: use the OPT_CMDMODE for parsing, reducing code checkout-index: fix negations of even numbers of -n config parsing options: allow one flag multiple times hash-object: replace stdin parsing OPT_BOOLEAN by OPT_COUNTUP branch, commit, name-rev: ease up boolean conditions checkout: remove superfluous local variable log, format-patch: parsing uses OPT__QUIET Replace deprecated OPT_BOOLEAN by OPT_BOOL Remove deprecated OPTION_BOOLEAN for parsing arguments
2013-09-04Merge branch 'jc/parseopt-command-modes'Libravatar Junio C Hamano1-15/+12
Many commands use --dashed-option as a operation mode selector (e.g. "git tag --delete") that the user can use at most one (e.g. "git tag --delete --verify" is a nonsense) and you cannot negate (e.g. "git tag --no-delete" is a nonsense). Make it easier for users of parse_options() to enforce these restrictions. * jc/parseopt-command-modes: tag: use OPT_CMDMODE parse-options: add OPT_CMDMODE()
2013-09-04Merge branch 'sb/misc-cleanup'Libravatar Junio C Hamano1-21/+17
* sb/misc-cleanup: rm: remove unneeded null pointer check diff: fix a possible null pointer dereference diff: remove ternary operator evaluating always to true
2013-09-04Merge branch 'nd/gc-lock-against-each-other'Libravatar Junio C Hamano1-0/+67
* nd/gc-lock-against-each-other: gc: reject if another gc is running, unless --force is given
2013-09-04Merge branch 'bc/unuse-packfile'Libravatar Junio C Hamano1-1/+1
Handle memory pressure and file descriptor pressure separately when deciding to release pack windows to honor resource limits. * bc/unuse-packfile: Don't close pack fd when free'ing pack windows sha1_file: introduce close_one_pack() to close packs on fd pressure
2013-09-04Merge branch 'nd/sq-quote-buf'Libravatar Junio C Hamano2-10/+14
Code simplification as a preparatory step to something larger. * nd/sq-quote-buf: quote: remove sq_quote_print() tar-tree: remove dependency on sq_quote_print() for-each-ref, quote: convert *_quote_print -> *_quote_buf
2013-09-04Merge branch 'jc/check-x-z'Libravatar Junio C Hamano2-12/+20
"git check-ignore -z" applied the NUL termination to both its input (with --stdin) and its output, but "git check-attr -z" ignored the option on the output side. This is potentially a backward incompatible fix. Let's see if anybody screams before deciding if we want to do anything to help existing users (there may be none). * jc/check-x-z: check-attr -z: a single -z should apply to both input and output check-ignore -z: a single -z should apply to both input and output check-attr: the name of the character is NUL, not NULL check-ignore: the name of the character is NUL, not NULL
2013-09-03fast-export: refactor get_tags_and_duplicates()Libravatar Felipe Contreras1-30/+38
Split into a separate helper function get_commit() so that the part that finds the relevant commit, and the part that does something with it (handle tag object, etc.) are in different places. No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-03fast-export: make extra_refs globalLibravatar Felipe Contreras1-11/+10
There's no need to pass it around everywhere. This would make easier further refactoring that makes use of this variable. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-30add: trivial style cleanupLibravatar Felipe Contreras1-5/+5
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-30reset: trivial style cleanupLibravatar Felipe Contreras1-1/+1
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-30reset: trivial refactoringLibravatar Felipe Contreras1-6/+3
After commit 3fde386 (reset [--mixed]: use diff-based reset whether or not pathspec was given), some code can be moved to the 'reset_type == MIXED' check. Let's move the code that is specific to MIXED. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-30Merge branch 'rj/doc-rev-parse'Libravatar Junio C Hamano1-15/+13
* rj/doc-rev-parse: rev-parse(1): logically group options rev-parse: remove restrictions on some options
2013-08-28builtin/fetch.c: Fix a sparse warningLibravatar Ramsay Jones1-1/+1
Sparse issues an "'prepare_transport' was not declared. Should it be static?" warning. In order to suppress the warning, since this symbol only requires file scope, we simply add the static modifier to it's declaration. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-24commit: search author pattern against mailmapLibravatar Antoine Pelisse1-1/+7
"git commit --author=$name" sets the author to one whose name matches the given string from existing commits, when $name is not in the "Name <e-mail>" format. However, it does not honor the mailmap to use the canonical name for the author found this way. Fix it by telling the logic to find a matching existing author to honor the mailmap, and use the name and email after applying the mailmap. Signed-off-by: Antoine Pelisse <apelisse@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-15ls-files -k: a directory only can be killed if the index has a non-directoryLibravatar Junio C Hamano1-0/+2
"ls-files -o" and "ls-files -k" both traverse the working tree down to find either all untracked paths or those that will be "killed" (removed from the working tree to make room) when the paths recorded in the index are checked out. It is necessary to traverse the working tree fully when enumerating all the "other" paths, but when we are only interested in "killed" paths, we can take advantage of the fact that paths that do not overlap with entries in the index can never be killed. The treat_one_path() helper function, which is called during the recursive traversal, is the ideal place to implement an optimization. When we are looking at a directory P in the working tree, there are three cases: (1) P exists in the index. Everything inside the directory P in the working tree needs to go when P is checked out from the index. (2) P does not exist in the index, but there is P/Q in the index. We know P will stay a directory when we check out the contents of the index, but we do not know yet if there is a directory P/Q in the working tree to be killed, so we need to recurse. (3) P does not exist in the index, and there is no P/Q in the index to require P to be a directory, either. Only in this case, we know that everything inside P will not be killed without recursing. Note that this helper is called by treat_leading_path() that decides if we need to traverse only subdirectories of a single common leading directory, which is essential for this optimization to be correct. This caller checks each level of the leading path component from shallower directory to deeper ones, and that is what allows us to only check if the path appears in the index. If the call to treat_one_path() weren't there, given a path P/Q/R, the real traversal may start from directory P/Q/R, even when the index records P as a regular file, and we would end up having to check if any leading subpath in P/Q/R, e.g. P, appears in the index. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-13push: respect --no-thinLibravatar Nguyễn Thái Ngọc Duy2-4/+9
- From the beginning of push.c in 755225d, 2006-04-29, "thin" option was enabled by default but could be turned off with --no-thin. - Then Shawn changed the default to 0 in favor of saving server resources in a4503a1, 2007-09-09. --no-thin worked great. - One day later, in 9b28851 Daniel extracted some code from push.c to create transport.c. He (probably accidentally) flipped the default value from 0 to 1 in transport_get(). From then on --no-thin is effectively no-op because git-push still expects the default value to be false and only calls transport_set_option() when "thin" variable in push.c is true (which is unnecessary). Correct the code to respect --no-thin by calling transport_set_option() in both cases. receive-pack learns about --reject-thin-pack-for-testing option, which only is for testing purposes, hence no document update. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-09rm: remove unneeded null pointer checkLibravatar Stefan Beller1-21/+17
As of 7612a1efdb (2006-06-09 git-rm: honor -n flag.) the variable 'pathspec' seems to be assumed to be never NULL after calling get_pathspec There was a NULL pointer check after the seen = NULL assignment, which was removed by that commit. So if pathspec would be NULL now, we'd segfault in the line accessing the pathspec: for (i = 0; pathspec[i] ; i++) A few lines later, 'pathspec' still cannot be NULL, but that check was overlooked, hence removing it now. As the null pointer check was removed, it makes no sense to assign NULL to seen and 3 lines later another value as there are no conditions in between. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-09builtin/config.c: compilation fixLibravatar Junio C Hamano1-1/+1
Do not feed a random string as the first parameter to die(); use "%s" as the format string instead. Do the same for test-urlmatch-normalization.c while saving a single pointer variable by turning a "const char *" constant string into "const char []", which is sufficient to squelch compilation warning (the compiler can see usage[] given to die() is a constant and will never have conversion specifiers that cause trouble). But for a good measure, give them the same "%s" treatment as well. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-09gc: reject if another gc is running, unless --force is givenLibravatar Nguyễn Thái Ngọc Duy1-0/+67
This may happen when `git gc --auto` is run automatically, then the user, to avoid wait time, switches to a new terminal, keeps working and `git gc --auto` is started again because the first gc instance has not clean up the repository. This patch tries to avoid multiple gc running, especially in --auto mode. In the worst case, gc may be delayed 12 hours if a daemon reuses the pid stored in gc.pid. kill(pid, 0) support is added to MinGW port so it should work on Windows too. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-07fetch: work around "transport-take-over" hackLibravatar Junio C Hamano1-0/+13
A Git-aware "connect" transport allows the "transport_take_over" to redirect generic transport requests like fetch(), push_refs() and get_refs_list() to the native Git transport handling methods. The take-over process replaces transport->data with a fake data that these method implementations understand. While this hack works OK for a single request, it breaks when the transport needs to make more than one requests. transport->data that used to hold necessary information for the specific helper to work correctly is destroyed during the take-over process. One codepath that this matters is "git fetch" in auto-follow mode; when it does not get all the tags that ought to point at the history it got (which can be determined by looking at the peeled tags in the initial advertisement) from the primary transfer, it internally makes a second request to complete the fetch. Because "take-over" hack has already destroyed the data necessary to talk to the transport helper by the time this happens, the second request cannot make a request to the helper to make another connection to fetch these additional tags. Mark such a transport as "cannot_reuse", and use a separate transport to perform the backfill fetch in order to work around this breakage. Note that this problem does not manifest itself when running t5802, because our upload-pack gives you all the necessary auto-followed tags during the primary transfer. You would need to step through "git fetch" in a debugger, stop immediately after the primary transfer finishes and writes these auto-followed tags, remove the tag references and repack/prune the repository to convince the "find-non-local-tags" procedure that the primary transfer failed to give us all the necessary tags, and then let it continue, in order to trigger the bug in the secondary transfer this patch fixes. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-07fetch: refactor code that fetches leftover tagsLibravatar Junio C Hamano1-5/+9
Usually the upload-pack process running on the other side will give us all the reachable tags we need during the primary object transfer in do_fetch(). If that does not happen (e.g. the other side may be running a third-party implementation of upload-pack), we will run another fetch to pick up leftover tags that we know point at the commits reachable from our updated tips. Separate out the code to run this second fetch into a helper function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-07fetch: refactor code that prepares a transportLibravatar Junio C Hamano1-20/+26
Make a helper function prepare_transport() that returns a transport to talk to a given remote. The set_option() helper that used to always affect the file-scope global "gtransport" now takes a transport as its parameter. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-07fetch: rename file-scope global "transport" to "gtransport"Libravatar Junio C Hamano1-11/+11
Although many functions in this file take a "struct transport" as a parameter, "fetch_one()" assigns to the global singleton instance which is a file-scope static, in order to allow a parameterless signal handler unlock_pack() to access it. Rename the variable to gtransport to make sure these uses stand out. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-07revert: use the OPT_CMDMODE for parsing, reducing codeLibravatar Stefan Beller1-47/+15
The revert command comes with their own implementation of checking for exclusiveness of parameters. Now that the OPT_CMDMODE is in place, we can also rely on that macro instead of cooking that solution for each command itself. This commit also replaces OPT_BOOLEAN, which was deprecated by b04ba2bb (parse-options: deprecate OPT_BOOLEAN, 2011-09-27). Instead OPT_BOOL is used. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-07checkout-index: fix negations of even numbers of -nLibravatar Stefan Beller1-1/+1
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-07config parsing options: allow one flag multiple timesLibravatar Stefan Beller1-3/+3
This task emerged from b04ba2bb (parse-options: deprecate OPT_BOOLEAN, 2011-09-27). This commit introduces a change for the users, after this patch you can pass one of the config level flags multiple times: Before: $ git config --global --global --list error: only one config file at a time. usage: ... Afterwards this will work. This is due to the following check in the code: if (use_global_config + use_system_config + use_local_config + !!given_config_file + !!given_config_blob > 1) { error("only one config file at a time."); usage_with_options(builtin_config_usage, builtin_config_options); } With OPT_BOOL instead of OPT_BOOLEAN the variables use_global_config, use_system_config, use_local_config will only have the value 0 if the command line option was not passed or 1 no matter how often the respective command line option was passed. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-07hash-object: replace stdin parsing OPT_BOOLEAN by OPT_COUNTUPLibravatar Stefan Beller1-1/+1
This task emerged from b04ba2bb (parse-options: deprecate OPT_BOOLEAN, 2011-09-27). hash-object is a plumbing layer command, so better not change the input/output behavior for now. Unfortunately we have these lines relying on the count up mechanism of OPT_BOOLEAN: if (hashstdin > 1) errstr = "Multiple --stdin arguments are not supported"; Using OPT_BOOL will make "git hash-object --stdin --stdin" the same as "git hash-object --stdin", resulting in just one object, which will surprise users with an expectation to see two objects hashed. Because it is not good to silently succeed and give an unexpected result, even when the expectation is unrealistic, we use COUNTUP to explicitly catch such an error. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-07branch, commit, name-rev: ease up boolean conditionsLibravatar Stefan Beller3-3/+4
Now that the variables are set by OPT_BOOL, which makes sure to have the values being 0 or 1 after parsing, we do not need the double negation to map any other value to 1 for integer variables. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-06blame: teach -L/RE/ to search from end of previous -L rangeLibravatar Eric Sunshine1-1/+4
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-06line-range: teach -L/RE/ to search relative to anchor pointLibravatar Eric Sunshine1-1/+1
Range specification -L/RE/ for blame/log unconditionally begins searching at line one. Mailing list discussion [1] suggests that, in the presence of multiple -L options, -L/RE/ should search relative to the endpoint of the previous -L range, if any. Teach the parsing machinery underlying blame's and log's -L options to accept a start point for -L/RE/ searches. Follow-up patches will upgrade blame and log to take advantage of this ability. [1]: http://thread.gmane.org/gmane.comp.version-control.git/229755/focus=229966 Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>