summaryrefslogtreecommitdiff
path: root/builtin
AgeCommit message (Collapse)Author
2011-05-20receive-pack: eliminate duplicate .have refsJeff King
When receiving a push, we advertise ref tips from any alternate repositories, in case that helps the client send a smaller pack. Since these refs don't actually exist in the destination repository, we don't transmit the real ref names, but instead use the pseudo-ref ".have". If your alternate has a large number of duplicate refs (for example, because it is aggregating objects from many related repositories, some of which will have the same tags and branch tips), then we will send each ".have $sha1" line multiple times. This is a pointless waste of bandwidth, as we are simply repeating the same fact to the client over and over. This patch eliminates duplicate .have refs early on. It does so efficiently by sorting the complete list and skipping duplicates. This has the side effect of re-ordering the .have lines by ascending sha1; this isn't a problem, though, as the original order was meaningless. There is a similar .have system in fetch-pack, but it does not suffer from the same problem. For each alternate ref we consider in fetch-pack, we actually open the object and mark it with the SEEN flag, so duplicates are automatically culled. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-20refactor refs_from_alternate_cb to allow passing extra dataJeff King
The foreach_alt_odb function triggers a callback for each alternate object db we have, with room for a single void pointer as data. Currently, we always call refs_from_alternate_cb as the callback function, and then pass another callback (to receive each ref individually) as the void pointer. This has two problems: 1. C technically forbids stuffing a function pointer into a "void *". In practice, this probably doesn't matter on any architectures git runs on, but it never hurts to follow the letter of the law. 2. There is no room for an extra data pointer. Indeed, the alternate_ref_fn that refs_from_alternate_cb calls takes a void* for data, but we always pass it NULL. Instead, let's properly stuff our function pointer into a data struct, which also leaves room for an extra caller-supplied data pointer. And to keep things simple for existing callers, let's make a for_each_alternate_ref function that takes care of creating the extra struct. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-20fetch: avoid repeated commits in mark_completeJeff King
We add every local ref to a list so that we can mark them and all of their ancestors back to a certain cutoff point. However, if some refs point to the same commit, we will end up adding them to the list many times. Furthermore, since commit_lists are stored as linked lists, we must do an O(n) traversal of the list in order to find the right place to insert each commit. This makes building the list O(n^2) in the number of refs. For normal repositories, this isn't a big deal. We have a few hundreds refs at most, and most of them are unique. But consider an "alternates" repo that serves as an object database for many other similar repos. For reachability, it needs to keep a copy of the refs in each child repo. This means it may have a large number of refs, many of which point to the same commits. By noting commits we have already added to the list, we can shrink the size of "n" in such a repo to the number of unique commits, which is on the order of what a normal repo would contain (it's actually more than a normal repo, since child repos may have branches at different states, but in practice it tends to be much smaller than the list with duplicates). Here are the results on one particular giant repo (containing objects for all Rails forks on GitHub): $ git for-each-ref | wc -l 112514 [before] $ git fetch --no-tags ../remote.git 63.52user 0.12system 1:03.68elapsed 99%CPU (0avgtext+0avgdata 137648maxresident)k 1856inputs+48outputs (11major+19603minor)pagefaults 0swaps $ git fetch --no-tags ../remote.git 6.15user 0.08system 0:06.25elapsed 99%CPU (0avgtext+0avgdata 123856maxresident)k 0inputs+40outputs (0major+18872minor)pagefaults 0swaps Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-19show: --ignore-missingJunio C Hamano
Instead of barfing, simply ignore bad object names seen in the input. This is useful when reading from "git notes list" output that may refer to objects that have already been garbage collected. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-19notes remove: --stdin reads from the standard inputJunio C Hamano
Teach the command to read object names to remove from the standard input, in addition to the object names given from the command line. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-19notes remove: --ignore-missingJunio C Hamano
Depending on the application, it is not necessarily an error for an object to lack a note, especially if the only thing the caller wants to make sure is that notes are cleared for an object. By passing this option from the command line, the "git notes remove" command considers it a success if the object did not have any note to begin with. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-19notes remove: allow removing more than oneJunio C Hamano
While "xargs -n1 git notes rm" is certainly a possible way to remove notes from many objects, this would create one notes "commit" per removal, which is not quite suitable for seasonal housekeeping. Allow taking more than one on the command line, and record their removal as a single atomic event if everthing goes well. Even though the old code insisted that "git notes rm" must be given only one object (or zero, in which case it would default to HEAD), this condition was not tested. Add tests to handle the new case where we feed multiple objects, and also make sure if there is a bad input, no change is recorded. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-18ls-remote: the --exit-code option reports "no matching refs"Michael Schubert
The "git ls-remote" uses its exit status to indicate if it successfully talked with the remote repository. A new option "--exit-code" makes the command exit with status "2" when there is no refs to be listed, even when the command successfully talked with the remote repository. This way, the caller can tell if we failed to contact the remote, or the remote did not have what we wanted to see. Of course, you can inspect the output from the command, which has been and will continue to be a valid way to check the same thing. Signed-off-by: Michael Schubert <mschub@elegosoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-18Add log.abbrevCommit config variableJay Soffian
Add log.abbrevCommit config variable as a convenience for users who often use --abbrev-commit with git log and friends. Allow the option to be overridden with --no-abbrev-commit. Per 635530a2fc and 4f62c2bc57, the config variable is ignored when log is given "--pretty=raw". (Also, a drive-by spelling correction in git log's short help.) Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-18"git log -h": typofix misspelled 'suppress'Jay Soffian
Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-18config: Give error message when not changing a multivarMichael J Gruber
When trying to set a multivar with "git config var value", "git config" issues warning: remote.repoor.push has multiple values leaving the user under the impression that the operation succeeded, unless one checks the return value. Instead, make it warning: remote.repoor.push has multiple values error: cannot overwrite multiple values with a single value Use a regexp, --add or --set-all to change remote.repoor.push. to be clear and helpful. Note: The "warning" is raised through other code paths also so that it needs to remain a warning for these (which do not raise the error). Only the caller can determine how to go on from that. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-17packed_object_info_detail(): do not return a stringJunio C Hamano
Instead return an integer that can be given to typename() if the caller wants a string, just like everybody else does. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-16Merge branch 'ci/commit--interactive-atomic'Junio C Hamano
* ci/commit--interactive-atomic: Test atomic git-commit --interactive Add commit to list of config.singlekey commands Add support for -p/--patch to git-commit Allow git commit --interactive with paths t7501.8: feed a meaningful command Use a temporary index for git commit --interactive
2011-05-16Merge branch 'mg/merge-ff-config'Junio C Hamano
* mg/merge-ff-config: tests: check git does not barf on merge.ff values for future versions of git merge: introduce merge.ff configuration variable Conflicts: t/t7600-merge.sh
2011-05-16Merge branch 'vr/merge-base-doc' into maintJunio C Hamano
* vr/merge-base-doc: Restructure documentation for git-merge-base. Documentation: update to git-merge-base --octopus
2011-05-16Merge branch 'jc/fix-add-u-unmerged' into maintJunio C Hamano
* jc/fix-add-u-unmerged: Fix "add -u" that sometimes fails to resolve unmerged paths Conflicts: builtin/add.c
2011-05-16Merge branch 'jc/maint-branch-mergeoptions' into maintJunio C Hamano
* jc/maint-branch-mergeoptions: merge: make branch.<name>.mergeoptions correctly override merge.<option> Conflicts: builtin/merge.c
2011-05-16Merge branch 'jc/maint-add-p-overlapping-hunks' into maintJunio C Hamano
* jc/maint-add-p-overlapping-hunks: t3701: add-p-fix makes the last test to pass "add -p": work-around an old laziness that does not coalesce hunks add--interactive.perl: factor out repeated --recount option t3701: Editing a split hunk in an "add -p" session add -p: 'q' should really quit
2011-05-16revert: allow reverting a root commitJeff King
Although it is probably an uncommon operation, there is no reason to disallow it, as it works just fine. It is the reverse of a cherry-pick of a root commit, which is already allowed. We do have to tweak one check on whether we have a merge commit, which assumed we had at least one parent. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-16cherry-pick: handle root commits with external strategiesJeff King
The merge-recursive strategy already handles root commits; it cherry-picks the difference between the empty tree and the root commit's tree. However, for external strategies, we dereference NULL and segfault while building the argument list. Instead, let's handle this by passing the empty tree sha1 to the merge script. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-15Merge branches 'jc/convert', 'jc/bigfile' and 'jc/replacing' into jc/streamingJunio C Hamano
* jc/convert: convert: make it harder to screw up adding a conversion attribute convert: make it safer to add conversion attributes convert: give saner names to crlf/eol variables, types and functions convert: rename the "eol" global variable to "core_eol" * jc/bigfile: Bigfile: teach "git add" to send a large file straight to a pack index_fd(): split into two helper functions index_fd(): turn write_object and format_check arguments into one flag * jc/replacing: read_sha1_file(): allow selective bypassing of replacement mechanism inline lookup_replace_object() calls read_sha1_file(): get rid of read_sha1_file_repl() madness t6050: make sure we test not just commit replacement Declare lookup_replace_object() in cache.h, not in commit.h
2011-05-15Merge branch 'cn/format-patch-quiet' into maintJunio C Hamano
* cn/format-patch-quiet: format-patch: document --quiet option format-patch: don't pass on the --quiet flag
2011-05-15read_sha1_file(): get rid of read_sha1_file_repl() madnessJunio C Hamano
Most callers want to silently get a replacement object, and they do not care what the real name of the replacement object is. Worse yet, no sane interface to return the underlying object without replacement is provided. Remove the function and make only the few callers that want the name of the replacement object find it themselves. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-15Merge branch 'maint'Junio C Hamano
* maint: add, merge, diff: do not use strcasecmp to compare config variable names
2011-05-15add, merge, diff: do not use strcasecmp to compare config variable namesJonathan Nieder
The config machinery already makes section and variable names lowercase when parsing them, so using strcasecmp for comparison just feels wasteful. No noticeable change intended. Noticed-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-13Merge branch 'bf/commit-template-no-cleanup'Junio C Hamano
* bf/commit-template-no-cleanup: Do not strip empty lines / trailing spaces from a commit message template
2011-05-13Merge branch 'rr/rerere-libify-clear-gc'Junio C Hamano
* rr/rerere-libify-clear-gc: rerere: libify rerere_clear() and rerere_gc()
2011-05-13Merge branch 'js/maint-send-pack-stateless-rpc-deadlock-fix'Junio C Hamano
* js/maint-send-pack-stateless-rpc-deadlock-fix: send-pack: unbreak push over stateless rpc send-pack: avoid deadlock when pack-object dies early
2011-05-13Merge branch 'jc/fix-add-u-unmerged'Junio C Hamano
* jc/fix-add-u-unmerged: Fix "add -u" that sometimes fails to resolve unmerged paths
2011-05-13Merge branch 'cn/log-parse-opt'Junio C Hamano
* cn/log-parse-opt: log: convert to parse-options
2011-05-13Merge branch 'js/blame-parsename' into maintJunio C Hamano
* js/blame-parsename: t/annotate-tests: Use echo & cat instead of sed blame: tolerate bogus e-mail addresses a bit better
2011-05-11Merge branch 'jc/maint-branch-mergeoptions'Junio C Hamano
* jc/maint-branch-mergeoptions: merge: make branch.<name>.mergeoptions correctly override merge.<option> Conflicts: builtin/merge.c
2011-05-11Merge branch 'jc/maint-add-p-overlapping-hunks'Junio C Hamano
* jc/maint-add-p-overlapping-hunks: t3701: add-p-fix makes the last test to pass "add -p": work-around an old laziness that does not coalesce hunks add--interactive.perl: factor out repeated --recount option t3701: Editing a split hunk in an "add -p" session add -p: 'q' should really quit
2011-05-11Do not strip empty lines / trailing spaces from a commit message templateBoris Faure
Templates should be just that: A form that the user fills out, and forms have blanks. If people are attached to not having extra whitespace in the editor, they can simply clean up their templates. Added test with editor adding even more whitespace. Signed-off-by: Boris Faure <billiob@gmail.com> Based-on-patch-by:Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-10grep: use get_pathspec() correctlyJunio C Hamano
When there is no remaining string in argv, get_pathspec(prefix, argv) will return a two-element array that has prefix as the first element, so there is no need to re-roll that logic in the code that uses get_pathspec(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-10tag: disallow '-' as tag nameMichael Schubert
Disallow '-' as tag name, as well as tag names starting with '-', as it would be cumbersome to "git checkout tags/-" because "git checkout -" is to switch to the previous branch. Add strbuf_check_tag_ref() as helper to check a refname for a tag. Signed-off-by: Michael Schubert <mschub@elegosoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-10git-grep: do not die upon -F/-P when grep.extendedRegexp is set.Junio C Hamano
The previous one made "git grep -P" fail when grep.extendedRegexp is enabled. That is a no-starter. The option on the command line should just make the command ignore the configured default. The handling of "-F" in the existing code has the same problem. Instead of saying -G/-F/-E/-P incompatible with each other, just allow the last one win. That way, you can have "[alias] gr = grep -P" and use Pcre for everyday work e.g. "git gr ':i?foo'", and append -G to the aliased command line to override it e.g. "git gr -G '[Ff][Oo][Oo]'". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-10Add support for -p/--patch to git-commitConrad Irwin
The --interactive flag is already shared by git add and git commit, share the -p and --patch flags too. Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-10Allow git commit --interactive with pathsConrad Irwin
Make git commit --interactive feel more like git add --interactive by allowing the user to restrict the list of files they have to deal with. A test in t7501 used to ensure that this is not allowed; no need for that anymore. Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-09git-grep: Bail out when -P is used with -F or -EMichał Kiedrowicz
This patch makes git-grep die() when -P is used on command line together with -E/--extended-regexp or -F/--fixed-strings. This also makes it bail out when grep.extendedRegexp is enabled. But `git grep -G -P pattern` and `git grep -E -G -P pattern` still work because -G and -E set opts.regflags during parse_options() and there is no way to detect `-G` or `-E -G`. Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-09git-grep: Learn PCREMichał Kiedrowicz
This patch teaches git-grep the --perl-regexp/-P options (naming borrowed from GNU grep) in order to allow specifying PCRE regexes on the command line. PCRE has a number of features which make them more handy to use than POSIX regexes, like consistent escaping rules, extended character classes, ungreedy matching etc. git isn't build with PCRE support automatically. USE_LIBPCRE environment variable must be enabled (like `make USE_LIBPCRE=YesPlease`). Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-09blame: add --line-porcelain output formatJeff King
This is just like --porcelain, except that we always output the commit information for each line, not just the first time it is referenced. This can make quick and dirty scripts much easier to write; see the example added to the blame documentation. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-09blame: refactor porcelain outputJeff King
This is in preparation for adding more porcelain output options. The three changes are: 1. emit_porcelain now receives the format option flags 2. emit_one_suspect_detail takes an optional "repeat" parameter to suppress the "show only once" behavior 3. The code for emitting porcelain suspect is factored into its own function for repeatability. There should be no functional changes. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-09index_fd(): turn write_object and format_check arguments into one flagJunio C Hamano
The "format_check" parameter tucked after the existing parameters is too ugly an afterthought to live in any reasonable API. Combine it with the other boolean parameter "write_object" into a single "flags" parameter. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-08rerere: libify rerere_clear() and rerere_gc()Junio C Hamano
This moves the two features from builtin/rerere.c to a more library-ish portion of the codebase. No behaviour change. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-08Use a temporary index for git commit --interactiveConrad Irwin
Change the behaviour of git commit --interactive so that when you abort the commit (by leaving the commit message empty) the index remains unchanged. Hitherto an aborted commit --interactive has added the selected hunks to the index regardless of whether the commit succeeded or not. Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-06merge: introduce merge.ff configuration variableJunio C Hamano
This variable gives the default setting for --ff, --no-ff or --ff-only options of "git merge" command. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-06Merge branch 'jc/maint-branch-mergeoptions' into mg/merge-ff-configJunio C Hamano
* jc/maint-branch-mergeoptions: merge: make branch.<name>.mergeoptions correctly override merge.<option>
2011-05-06Merge branch 'js/blame-parsename'Junio C Hamano
* js/blame-parsename: t/annotate-tests: Use echo & cat instead of sed blame: tolerate bogus e-mail addresses a bit better
2011-05-06Merge branch 'nd/struct-pathspec'Junio C Hamano
* nd/struct-pathspec: pathspec: rename per-item field has_wildcard to use_wildcard Improve tree_entry_interesting() handling code Convert read_tree{,_recursive} to support struct pathspec Reimplement read_tree_recursive() using tree_entry_interesting()