summaryrefslogtreecommitdiff
path: root/builtin
AgeCommit message (Collapse)Author
2013-12-11fetch: add --update-shallow to accept refs that update .git/shallowNguyễn Thái Ngọc Duy
The same steps are done as in when --update-shallow is not given. The only difference is we now add all shallow commits in "ours" and "theirs" to .git/shallow (aka "step 8"). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-11fetch: support fetching from a shallow repositoryNguyễn Thái Ngọc Duy
This patch just put together pieces from the 8 steps patch. We stop at step 7 and reject refs that require new shallow commits. Note that, by rejecting refs that require new shallow commits, we leave dangling objects in the repo, which become "object islands" by the next "git fetch" of the same source. If the first fetch our "ours" set is zero and we do practically nothing at step 7, "ours" is full at the next fetch and we may need to walk through commits for reachability test. Room for improvement. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-11clone: support remote shallow repositoryNguyễn Thái Ngọc Duy
Cloning from a shallow repository does not follow the "8 steps for new .git/shallow" because if it does we need to get through step 6 for all refs. That means commit walking down to the bottom. Instead the rule to create .git/shallow is simpler and, more importantly, cheap: if a shallow commit is found in the pack, it's probably used (i.e. reachable from some refs), so we add it. Others are dropped. One may notice this method seems flawed by the word "probably". A shallow commit may not be reachable from any refs at all if it's attached to an object island (a group of objects that are not reachable by any refs). If that object island is not complete, a new fetch request may send more objects to connect it to some ref. At that time, because we incorrectly installed the shallow commit in this island, the user will not see anything after that commit (fsck is still ok). This is not desired. Given that object islands are rare (C Git never sends such islands for security reasons) and do not really harm the repository integrity, a tradeoff is made to surprise the user occasionally but work faster everyday. A new option --strict could be added later that follows exactly the 8 steps. "git prune" can also learn to remove dangling objects _and_ the shallow commits that are attached to them from .git/shallow. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-11connect.c: teach get_remote_heads to parse "shallow" linesNguyễn Thái Ngọc Duy
No callers pass a non-empty pointer as shallow_points at this stage. As a result, all clients still refuse to talk to shallow repository on the other end. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-11make the sender advertise shallow commits to the receiverNguyễn Thái Ngọc Duy
If either receive-pack or upload-pack is called on a shallow repository, shallow commits (*) will be sent after the ref advertisement (but before the packet flush), so that the receiver has the full "shape" of the sender's commit graph. This will be needed for the receiver to update its .git/shallow if necessary. This breaks the protocol for all clients trying to push to a shallow repo, or fetch from one. Which is basically the same end result as today's "is_repository_shallow() && die()" in receive-pack and upload-pack. New clients will be made aware of shallow upstream and can make use of this information. The sender must send all shallow commits that are sent in the following pack. It may send more shallow commits than necessary. upload-pack for example may choose to advertise no shallow commits if it knows in advance that the pack it's going to send contains no shallow commits. But upload-pack is the server, so we choose the cheaper way, send full .git/shallow and let the client deal with it. Smart HTTP is not affected by this patch. Shallow support on smart-http comes later separately. (*) A shallow commit is a commit that terminates the revision walker. It is usually put in .git/shallow in order to keep the revision walker from going out of bound because there is no guarantee that objects behind this commit is available. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-11clone: prevent --reference to a shallow repositoryNguyễn Thái Ngọc Duy
If we borrow objects from another repository, we should also pay attention to their $GIT_DIR/shallow (and even info/grafts). But current alternates code does not. Reject alternate repos that are shallow because we do not do it right. In future the alternate code may be updated to check $GIT_DIR/shallow properly so that this restriction could be lifted. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-11send-pack: forbid pushing from a shallow repositoryNguyễn Thái Ngọc Duy
send-pack can send a pack with loose ends to the server. receive-pack before 6d4bb38 (fetch: verify we have everything we need before updating our ref - 2011-09-01) does not detect this and keeps the pack anyway, which corrupts the repository, at least from fsck point of view. send-pack will learn to safely push from a shallow repository later. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-11remote.h: replace struct extra_have_objects with struct sha1_arrayNguyễn Thái Ngọc Duy
The latter can do everything the former can and is used in many more places. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-18Merge branch 'nd/literal-pathspecs'Junio C Hamano
Fixes a regression on 'master' since v1.8.4. * nd/literal-pathspecs: pathspec: stop --*-pathspecs impact on internal parse_pathspec() uses
2013-11-18Merge branch 'jx/branch-vv-always-compare-with-upstream'Junio C Hamano
Hot-fix for a regression. * jx/branch-vv-always-compare-with-upstream: branch: fix --verbose output column alignment
2013-11-18branch: fix --verbose output column alignmentTorstein Hegge
Commit f2e0873 (branch: report invalid tracking branch as gone) removed an early return from fill_tracking_info() in the path taken when 'git branch -v' lists a branch in sync with its upstream. This resulted in an unconditionally added space in front of the subject line: $ git branch -v * master f5eb3da commit pushed to upstream topic f935eb6 unpublished topic Instead, only add the trailing space if a decoration have been added. To catch this kind of whitespace breakage in the tests, be a bit less smart when filtering the output through sed. Signed-off-by: Torstein Hegge <hegge@resisty.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-06Merge branch 'fc/trivial'Junio C Hamano
A random collection of style fixes and minor doc updates. * fc/trivial: setup: trivial style fixes run-command: trivial style fixes diff: trivial style fix revision: trivial style fixes pretty: trivial style fix describe: trivial style fixes transport-helper: trivial style fix sha1-name: trivial style cleanup branch: trivial style fix revision: add missing include doc/pull: clarify the illustrations t: replace pulls with merges merge: simplify ff-only option
2013-11-01Merge branch 'jk/reset-p-current-head-fix'Junio C Hamano
"git reset -p HEAD" has codepath to special case it from resetting to contents of other commits, but recent change broke it. * jk/reset-p-current-head-fix: reset: pass real rev name to add--interactive add-interactive: handle unborn branch in patch mode
2013-11-01Merge branch 'jk/for-each-ref-skip-parsing'Junio C Hamano
* jk/for-each-ref-skip-parsing: for-each-ref: avoid loading objects to print %(objectname)
2013-11-01Merge branch 'jl/submodule-mv'Junio C Hamano
Moving a regular file in a repository with a .gitmodules file was producing a warning 'Could not find section in .gitmodules where path=<filename>'. * jl/submodule-mv: mv: Fix spurious warning when moving a file in presence of submodules
2013-10-31diff: trivial style fixFelipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-31describe: trivial style fixesFelipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-31branch: trivial style fixFelipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-31merge: simplify ff-only optionFelipe Contreras
No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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-30Merge branch 'nd/gc-lock-against-each-other'Junio C Hamano
* nd/gc-lock-against-each-other: gc: remove gc.pid file at end of execution
2013-10-30Merge branch 'mm/checkout-auto-track-fix'Junio C Hamano
"git checkout topic", when there is not yet a local "topic" branch but there is a unique remote-tracking branch for a remote "topic" branch, pretended as if "git checkout -t -b topic remote/$r/topic" (for that unique remote $r) was run. This hack however was not implemented for "git checkout topic --". * mm/checkout-auto-track-fix: checkout: proper error message on 'git checkout foo bar --' checkout: allow dwim for branch creation for "git checkout $branch --"
2013-10-30Merge branch 'fc/styles'Junio C Hamano
C coding style fixes. * fc/styles: block-sha1/sha1.c: have SP around arithmetic operators base85.c: have SP around arithmetic operators archive.c: have SP around arithmetic operators alloc.c: have SP around arithmetic operators abspath.c: have SP around arithmetic operators alias: have SP around arithmetic operators C: have space around && and || operators
2013-10-30for-each-ref: avoid loading objects to print %(objectname)Jeff King
If you ask for-each-ref to print each ref and its object, like: git for-each-ref --format='%(objectname) %(refname)' this should involve little more work than looking at the ref files (and packed-refs) themselves. However, for-each-ref will actually load each object from disk just to print its sha1. For most repositories, this isn't a big deal, but it can be noticeable if you have a large number of refs to print. Here are best-of-five timings for the command above on a repo with ~10K refs: [before] real 0m0.112s user 0m0.092s sys 0m0.016s [after] real 0m0.014s user 0m0.012s sys 0m0.000s This patch checks for %(objectname) and %(objectname:short) before we actually parse the object (and the rest of the code is smart enough to avoid parsing if we have filled all of our placeholders). Note that we can't simply move the objectname parsing code into the early loop. If the "deref" form %(*objectname) is used, then we do need to parse the object in order to peel the tag. So instead of moving the code, we factor it out into a separate function that can be called for both cases. While we're at it, we add some basic tests for the dereferenced placeholders, which were not tested at all before. This helps ensure we didn't regress that case. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-28pathspec: stop --*-pathspecs impact on internal parse_pathspec() usesNguyễn Thái Ngọc Duy
Normally parse_pathspec() is used on command line arguments where it can do fancy thing like parsing magic on each argument or adding magic for all pathspecs based on --*-pathspecs options. There's another use of parse_pathspec(), where pathspec is needed, but the input is known to be pure paths. In this case we usually don't want --*-pathspecs to interfere. And we definitely do not want to parse magic in these paths, regardless of --literal-pathspecs. Add new flag PATHSPEC_LITERAL_PATH for this purpose. When it's set, --*-pathspecs are ignored, no magic is parsed. And if the caller allows PATHSPEC_LITERAL (i.e. the next calls can take literal magic), then PATHSPEC_LITERAL will be set. This fixes cases where git chokes when GIT_*_PATHSPECS are set because parse_pathspec() indicates it won't take any magic. But GIT_*_PATHSPECS add them anyway. These are export GIT_LITERAL_PATHSPECS=1 git blame -- something git log --follow something git log --merge "git ls-files --with-tree=path" (aka parse_pathspec() in overlay_tree_on_cache()) is safe because the input is empty, and producing one pathspec due to PATHSPEC_PREFER_CWD does not take any magic into account. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-25reset: pass real rev name to add--interactiveJeff King
The add--interactive --patch mode adjusts the UI based on whether we are pulling changes from HEAD or elsewhere (in the former case it asks to unstage the reverse hunk, rather than apply the forward hunk). Commit 166ec2e taught reset to work on an unborn branch, but in doing so, switched to always providing add--interactive with the sha1 rather than the symbolic name. This meant we always used the "apply" interface, even for "git reset -p HEAD". We can fix this by passing the symbolic name to add--interactive. Since it understands unborn branches these days, we do not even have to cover this special case ourselves; we can simply pass HEAD. The tests in t7105 now check that the right interface is used in each circumstance (and notice the regression from 166ec2e we are fixing). The test in t7106 checks that we get this right for the unborn case, too (not a regression, since it didn't work at all before, but a nice improvement). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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-10-23Merge branch 'hu/cherry-pick-previous-branch'Junio C Hamano
"git cherry-pick" without further options would segfault. Could use a follow-up to handle '-' after argv[1] better. * hu/cherry-pick-previous-branch: cherry-pick: handle "-" after parsing options
2013-10-23Merge branch 'mg/more-textconv'Junio C Hamano
Make "git grep" and "git show" pay attention to --textconv when dealing with blob objects. * mg/more-textconv: grep: honor --textconv for the case rev:path grep: allow to use textconv filters t7008: demonstrate behavior of grep with textconv cat-file: do not die on --textconv without textconv filters show: honor --textconv for blobs diff_opt: track whether flags have been set explicitly t4030: demonstrate behavior of show with textconv
2013-10-23Merge branch 'jc/pack-objects'Junio C Hamano
* jc/pack-objects: pack-objects: shrink struct object_entry
2013-10-18Merge branch 'sb/repack-in-c'Junio C Hamano
Rewrite "git repack" in C. * sb/repack-in-c: repack: improve warnings about failure of renaming and removing files repack: retain the return value of pack-objects repack: rewrite the shell script in C
2013-10-18Merge branch 'jk/clone-progress-to-stderr'Junio C Hamano
Some progress and diagnostic messages from "git clone" were incorrectly sent to the standard output stream, not to the standard error stream. * jk/clone-progress-to-stderr: clone: always set transport options clone: treat "checking connectivity" like other progress clone: send diagnostic messages to stderr
2013-10-18checkout: proper error message on 'git checkout foo bar --'Matthieu Moy
The previous code was detecting the presence of "--" by looking only at argument 1. As a result, "git checkout foo bar --" was interpreted as an ambiguous file/revision list, and errored out with: error: pathspec 'foo' did not match any file(s) known to git. error: pathspec 'bar' did not match any file(s) known to git. error: pathspec '--' did not match any file(s) known to git. This patch fixes it by walking through the argument list to find the "--", and now complains about the number of references given. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-18checkout: allow dwim for branch creation for "git checkout $branch --"Matthieu Moy
The "--" notation disambiguates files and branches, but as a side-effect of the previous implementation, also disabled the branch auto-creation when $branch does not exist. A possible scenario is then: git checkout $branch => fails if $branch is both a ref and a file, and suggests -- git checkout $branch -- => refuses to create the $branch This patch allows the second form to create $branch, and since the -- is provided, it does not look for file named $branch. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-18gc: remove gc.pid file at end of executionJonathan Nieder
This file isn't really harmful, but isn't useful either, and can create minor annoyance for the user: * It's confusing, as the presence of a *.pid file often implies that a process is currently running. A user running "ls .git/" and finding this file may incorrectly guess that a "git gc" is currently running. * Leaving this file means that a "git gc" in an already gc-ed repo is no-longer a no-op. A user running "git gc" in a set of repositories, and then synchronizing this set (e.g. rsync -av, unison, ...) will see all the gc.pid files as changed, which creates useless noise. This patch unlinks the file after the garbage collection is done, so that gc.pid is actually present only during execution. Future versions of Git may want to use the information left in the gc.pid file (e.g. for policies like "don't attempt to run a gc if one has already been ran less than X hours ago"). If so, this patch can safely be reverted. For now, let's not bother the users. Explained-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Improved-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-17Merge branch 'jk/trailing-slash-in-pathspec'Junio C Hamano
Code refactoring. * jk/trailing-slash-in-pathspec: reset: handle submodule with trailing slash rm: re-use parse_pathspec's trailing-slash removal
2013-10-17Merge branch 'ap/commit-author-mailmap' into maintJunio C Hamano
* ap/commit-author-mailmap: commit: search author pattern against mailmap
2013-10-16C: have space around && and || operatorsJunio C Hamano
Correct all hits from git grep -e '\(&&\|||\)[^ ]' -e '[^ ]\(&&\|||\)' -- '*.c' i.e. && or || operators that are followed by anything but a SP, or that follow something other than a SP or a HT, so that these operators have a SP around it when necessary. We usually refrain from making this kind of a tree-wide change in order to avoid unnecessary conflicts with other "real work" patches, but in this case, the end result does not have a potentially cumbersome tree-wide impact, while this is a tree-wide cleanup. Fixes to compat/regex/regcomp.c and xdiff/xemit.c are to replace a HT immediately after && with a SP. This is based on Felipe's patch to bultin/symbolic-ref.c; I did all the finding out what other files in the whole tree need to be fixed and did the fix and also the log message while reviewing that single liner, so any screw-ups in this version are mine. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-15Merge branch 'maint'Junio C Hamano
* maint: git-prune-packed.txt: fix reference to GIT_OBJECT_DIRECTORY clone --branch: refuse to clone if upstream repo is empty
2013-10-14clone --branch: refuse to clone if upstream repo is emptyRalf Thielow
Since 920b691 (clone: refuse to clone if --branch points to bogus ref) we refuse to clone with option "-b" if the specified branch does not exist in the (non-empty) upstream. If the upstream repository is empty, the branch doesn't exist, either. So refuse the clone too. Reported-by: Robert Mitwicki <robert.mitwicki@opensoftware.pl> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com> Acked-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2013-10-14Merge branch 'po/remote-set-head-usage'Jonathan Nieder
* po/remote-set-head-usage: remote set-head -h: add long options to synopsis remote doc: document long forms of set-head options
2013-10-14mv: Fix spurious warning when moving a file in presence of submodulesJens Lehmann
In commit 0656781fa "git mv" learned to update the submodule path in the .gitmodules file when moving a submodule in the work tree. But since that commit update_path_in_gitmodules() gets called no matter if we moved a submodule or a regular file, which is wrong and leads to a bogus warning when moving a regular file in a repo containing a .gitmodules file: warning: Could not find section in .gitmodules where path=<filename> Fix that by only calling update_path_in_gitmodules() when moving a submodule. To achieve that, we introduce the special SUBMODULE_WITH_GITDIR define to distinguish the cases where we also have to connect work tree and git directory from those where we only need to update the .gitmodules setting. A test for submodules using a .git directory together with a .gitmodules file has been added to t7001. Even though newer git versions will always use a gitfile when cloning submodules, repositories cloned with older git versions will still use this layout. Reported-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2013-10-10cherry-pick: handle "-" after parsing optionsJeff King
Currently, we only try converting argv[1] from "-" into "@{-1}". This means we do not notice "-" when used together with an option. Worse, when "git cherry-pick" is run with no options, we segfault. Fix this by doing the substitution after we have checked that there is something in argv to cherry-pick and know any remaining options are meant for the revision-listing machinery. This still does not handle "-" after the first non-cherry-pick option. For example, git cherry-pick foo~2 - bar~5 and git cherry-pick --no-merges - will still dump usage. Reported-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2013-09-27remote set-head -h: add long options to synopsisPhilip Oakley
Document --auto and --delete alongside their short forms -a and -d in the first line of 'git remote set-head -h' output. Signed-off-by: Philip Oakley <philipoakley@iee.org> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2013-09-25Merge branch 'cc/replace-with-the-same-type'Jonathan Nieder
* cc/replace-with-the-same-type: Doc: 'replace' merge and non-merge commits t6050-replace: use some long option names replace: allow long option names Documentation/replace: add Creating Replacement Objects section t6050-replace: add test to clean up all the replace refs t6050-replace: test that objects are of the same type Documentation/replace: state that objects must be of the same type replace: forbid replacing an object with one of a different type
2013-09-25Merge branch 'jk/shortlog-tolerate-broken-commit'Jonathan Nieder
* jk/shortlog-tolerate-broken-commit: shortlog: ignore commits with missing authors
2013-09-24clone: add a period after "done" to end the sentenceSebastian Schuberth
We have a period in other places after "done" (see e.g. clone_local), so we should have one here, too. Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2013-09-20Merge branch 'dw/check-ignore-sans-index'Junio C Hamano
"git check-ignore" follows the same rule as "git add" and "git status" in that the ignore/exclude mechanism does not take effect on paths that are already tracked. With "--no-index" option, it can be used to diagnose which paths that should have been ignored have been mistakenly added to the index. * dw/check-ignore-sans-index: check-ignore: Add option to ignore index contents
2013-09-20Merge branch 'mm/commit-template-squelch-advice-messages'Junio C Hamano
From the commit log template, remove irrelevant "advice" messages that are shared with "git status" output. * mm/commit-template-squelch-advice-messages: commit: disable status hints when writing to COMMIT_EDITMSG wt-status: turn advice_status_hints into a field of wt_status commit: factor status configuration is a helper function
2013-09-20Merge branch 'bk/refs-multi-update'Junio C Hamano
Give "update-refs" a "--stdin" option to read multiple update requests and perform them in an all-or-none fashion. * bk/refs-multi-update: update-ref: add test cases covering --stdin signature update-ref: support multiple simultaneous updates refs: add update_refs for multiple simultaneous updates refs: add function to repack without multiple refs refs: factor delete_ref loose ref step into a helper refs: factor update_ref steps into helpers refs: report ref type from lock_any_ref_for_update reset: rename update_refs to reset_refs