summaryrefslogtreecommitdiff
path: root/builtin/clone.c
AgeCommit message (Collapse)Author
2012-09-14Merge branch 'rj/path-cleanup'Junio C Hamano
* rj/path-cleanup: Call mkpathdup() rather than xstrdup(mkpath(...)) Call git_pathdup() rather than xstrdup(git_path("...")) path.c: Use vsnpath() in the implementation of git_path() path.c: Don't discard the return value of vsnpath() path.c: Remove the 'git_' prefix from a file scope function
2012-09-04Call mkpathdup() rather than xstrdup(mkpath(...))Ramsay Jones
In addition to updating the xstrdup(mkpath(...)) call sites with mkpathdup(), we also fix a memory leak (in merge_3way()) caused by neglecting to free the memory allocated to the 'base_name' variable. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-20i18n: clone: 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>
2012-07-22Merge branch 'ar/clone-honor-umask-at-top' into maintJunio C Hamano
A handful of files and directories we create had tighter than necessary permission bits when the user wanted to have group writability (e.g. by setting "umask 002"). * ar/clone-honor-umask-at-top: add: create ADD_EDIT.patch with mode 0666 rerere: make rr-cache fanout directory honor umask Restore umasks influence on the permissions of work tree created by clone
2012-07-16Merge branch 'ar/clone-honor-umask-at-top'Junio C Hamano
A handful of files and directories we create had tighter than necessary permission bits when the user wanted to have group writability (e.g. by setting "umask 002"). * ar/clone-honor-umask-at-top: add: create ADD_EDIT.patch with mode 0666 rerere: make rr-cache fanout directory honor umask Restore umasks influence on the permissions of work tree created by clone
2012-07-09Restore umasks influence on the permissions of work tree created by cloneAlex Riesen
The original version of the git-clone just used mkdir(1) to create the working directories. The version rewritten in C creates all directories inside the working tree by using the mode argument of 0777 when calling mkdir(2) to let the umask take effect. But the top-level directory of the working tree is created by passing the mode argument of 0755 to mkdir(2), which results in an overly tight restriction if the user wants to make directories group writable with a looser umask like 002. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-05Merge branch 'nd/clone-single-fix'Junio C Hamano
"git clone --single-branch" to clone a single branch did not limit the cloning to the specified branch. * nd/clone-single-fix: clone: fix ref selection in --single-branch --branch=xxx
2012-06-22clone: fix ref selection in --single-branch --branch=xxxNguyễn Thái Ngọc Duy
- do not fetch HEAD - do not also fetch refs following "xxx" Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-30clone: allow --no-local to turn off local optimizationsJeff King
This is basically the same as using "file://", but is a little less subtle for the end user. It also allows relative paths to be specified. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-07Merge branch 'ef/maint-1.7.6-clone-progress-fix' into ↵Junio C Hamano
ef/maint-clone-progress-fix By Erik Faye-Lund * ef/maint-1.7.6-clone-progress-fix: clone: fix progress-regression
2012-05-07clone: fix progress-regressionErik Faye-Lund
In 5bd631b3 ("clone: support multiple levels of verbosity"), the default behavior to show progress of the implicit checkout in the clone-command regressed so that progress was only shown if the verbose-option was specified. Fix this by making option_verbosity == 0 output progress as well. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-21Merge branch 'cb/transfer-no-progress' into maintJunio C Hamano
* cb/transfer-no-progress: push/fetch/clone --no-progress suppresses progress output
2012-02-21Merge branch 'jk/git-dir-lookup' into maintJunio C Hamano
* jk/git-dir-lookup: standardize and improve lookup rules for external local repos
2012-02-20Merge branch 'cb/transfer-no-progress'Junio C Hamano
* cb/transfer-no-progress: push/fetch/clone --no-progress suppresses progress output
2012-02-14Merge branch 'jk/git-dir-lookup'Junio C Hamano
* jk/git-dir-lookup: standardize and improve lookup rules for external local repos
2012-02-13push/fetch/clone --no-progress suppresses progress outputClemens Buchacher
By default, progress output is disabled if stderr is not a terminal. The --progress option can be used to force progress output anyways. Conversely, --no-progress does not force progress output. In particular, if stderr is a terminal, progress output is enabled. This is unintuitive. Change --no-progress to force output off. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-13clone: do not add alternate references to extra_refsMichael Haggerty
Alternate references are directly (and now, correctly) handled by fetch-pack, so there is no need to inform fetch-pack about them via the extra_refs back channel. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-13clone.c: move more code into the "if (refs)" conditionalMichael Haggerty
The bahavior of a bunch of code before the "if (refs)" statement also depends on whether refs is set, so make the logic clearer by shifting this code into the if statement. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-03standardize and improve lookup rules for external local reposJeff King
When you specify a local repository on the command line of clone, ls-remote, upload-pack, receive-pack, or upload-archive, or in a request to git-daemon, we perform a little bit of lookup magic, doing things like looking in working trees for .git directories and appending ".git" for bare repos. For clone, this magic happens in get_repo_path. For everything else, it happens in enter_repo. In both cases, there are some ambiguous or confusing cases that aren't handled well, and there is one case that is not handled the same by both methods. This patch tries to provide (and test!) standard, sensible lookup rules for both code paths. The intended changes are: 1. When looking up "foo", we have always preferred a working tree "foo" (containing "foo/.git" over the bare "foo.git". But we did not prefer a bare "foo" over "foo.git". With this patch, we do so. 2. We would select directories that existed but didn't actually look like git repositories. With this patch, we make sure a selected directory looks like a git repo. Not only is this more sensible in general, but it will help anybody who is negatively affected by change (1) negatively (e.g., if they had "foo.git" next to its separate work tree "foo", and expect to keep finding "foo.git" when they reference "foo"). 3. The enter_repo code path would, given "foo", look for "foo.git/.git" (i.e., do the ".git" append magic even for a repo with working tree). The clone code path did not; with this patch, they now behave the same. In the unlikely case of a working tree overlaying a bare repo (i.e., a ".git" directory _inside_ a bare repo), we continue to treat it as a working tree (prefering the "inner" .git over the bare repo). This is mainly because the combination seems nonsensical, and I'd rather stick with existing behavior on the off chance that somebody is relying on it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-01Merge branch 'nd/clone-detached'Junio C Hamano
* nd/clone-detached: clone: fix up delay cloning conditions push: do not let configured foreign-vcs permanently clobbered clone: print advice on checking out detached HEAD clone: allow --branch to take a tag clone: refuse to clone if --branch points to bogus ref clone: --branch=<branch> always means refs/heads/<branch> clone: delay cloning until after remote HEAD checking clone: factor out remote ref writing clone: factor out HEAD update code clone: factor out checkout code clone: write detached HEAD in bare repositories t5601: add missing && cascade
2012-01-29Merge branch 'mh/ref-clone-without-extra-refs'Junio C Hamano
* mh/ref-clone-without-extra-refs: write_remote_refs(): create packed (rather than extra) refs add_packed_ref(): new function in the refs API. ref_array: keep track of whether references are sorted pack_refs(): remove redundant check
2012-01-24clone: fix up delay cloning conditionsNguyễn Thái Ngọc Duy
6f48d39 (clone: delay cloning until after remote HEAD checking - 2012-01-16) allows us to perform some checks on remote refs before the actual cloning happens. But not all transport types support this. Remote helper with "import" capability will not return complete ref information until fetch is performed and therefore the clone cannot be delayed. foreign_vcs field in struct remote was used to detect this kind of transport and save the result. This is a mistake because foreign_vcs is designed to override url-based transport detection. As a result, if the same "struct transport *" object is used on many different urls and one of them attached remote transport, the following urls will be mistakenly attached to the same transport. This fault is worked around by dad0b3d (push: do not let configured foreign-vcs permanently clobbered - 2012-01-23) To fix this, detect incomplete refs from transport_get_remote_refs() by SHA-1. Incomplete ones must have null SHA-1 (*). Then revert changes related to foreign_cvs field in 6f48d39 and dad0b3d. A good thing from this change is that cloning smart http transport can also be delayed. Earlier it falls into the same category "remote transport, no delay". (*) Theoretically if one of the remote refs happens to have null SHA-1, it will trigger false alarm and the clone will not be delayed. But that chance may be too small for us to pay attention to. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-17write_remote_refs(): create packed (rather than extra) refsMichael Haggerty
write_remote_refs() creates new packed refs from references obtained from the remote repository, which is "out of thin air" as far as the local repository is concerned. Previously it did this by creating "extra" refs, then calling pack_refs() to bake them into the packed-refs file. Instead, create packed refs (in the packed reference cache) directly, then call pack_refs(). Aside from being more logical, this is another step towards removing extra refs entirely. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-17clone: print advice on checking out detached HEADNguyễ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-01-17clone: allow --branch to take a tagNguyễn Thái Ngọc Duy
Because a tag ref cannot be put to HEAD, HEAD will become detached. This is consistent with "git checkout <tag>". This is mostly useful in shallow clone, where it allows you to clone a tag in addtion to branches. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-17clone: refuse to clone if --branch points to bogus refNguyễn Thái Ngọc Duy
It's possible that users make a typo in the branch name. Stop and let users recheck. Falling back to remote's HEAD is not documented any way. Except when using remote helper, the pack has not been transferred at this stage yet so we don't waste much bandwidth. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-17clone: --branch=<branch> always means refs/heads/<branch>Nguyễn Thái Ngọc Duy
It does not make sense to look outside refs/heads for HEAD's target (src_ref_prefix can be set to "refs/" if --mirror is used) because ref code only allows symref in form refs/heads/... Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-17clone: delay cloning until after remote HEAD checkingNguyễn Thái Ngọc Duy
This gives us an opportunity to abort the command during remote HEAD check without wasting much bandwidth. Cloning with remote-helper remains before the check because the remote helper updates mapped_refs, which is necessary for remote ref checks. foreign_vcs field is used to indicate the transport is handled by remote helper. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-17clone: factor out remote ref writingNguyễ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-01-17clone: factor out HEAD update codeNguyễn Thái Ngọc Duy
While at it, update the comment at "if (remote_head)" Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-17clone: factor out checkout codeNguyễn Thái Ngọc Duy
Read HEAD from disk instead of relying on local variable our_head_points_at, so that if earlier code fails to make HEAD properly, it'll be detected. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-17clone: write detached HEAD in bare repositoriesNguyễn Thái Ngọc Duy
If we don't write, HEAD is still at refs/heads/master as initialized by init-db, which may or may not match remote's HEAD. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-08clone: add --single-branch to fetch only one branchNguyễn Thái Ngọc Duy
When --single-branch is given, only one branch, either HEAD or one specified by --branch, will be fetched. Also only tags that point to the downloaded history are fetched. This helps most in shallow clones, where it can reduce the download to minimum and that is why it is enabled by default when --depth is given. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-21clone: the -o option has nothing to do with <branch>Carlos Martín Nieto
It is to give an alternate <name> instead of "origin" to the remote we are cloning from. Signed-off-by: Carlos Martín Nieto <cmn@elego.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-27clone: Quote user supplied path in a single quote pairRichard Hartmann
Without this patch, $ git clone foo . results in this: Cloning into .... done. With it: Cloning into '.'... done. Signed-off-by: Richard Hartmann <richih.mailinglist@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-09-23Merge branch 'jc/maint-clone-alternates' into maintJunio C Hamano
* jc/maint-clone-alternates: clone: clone from a repository with relative alternates clone: allow more than one --reference
2011-08-29Merge branch 'nd/maint-clone-gitdir'Junio C Hamano
* nd/maint-clone-gitdir: clone: allow to clone from .git file read_gitfile_gently(): rename misnamed function to read_gitfile()
2011-08-29Merge branch 'jc/maint-clone-alternates'Junio C Hamano
* jc/maint-clone-alternates: clone: clone from a repository with relative alternates clone: allow more than one --reference Conflicts: builtin/clone.c
2011-08-23clone: clone from a repository with relative alternatesJunio C Hamano
Cloning from a local repository blindly copies or hardlinks all the files under objects/ hierarchy. This results in two issues: - If the repository cloned has an "objects/info/alternates" file, and the command line of clone specifies --reference, the ones specified on the command line get overwritten by the copy from the original repository. - An entry in a "objects/info/alternates" file can specify the object stores it borrows objects from as a path relative to the "objects/" directory. When cloning a repository with such an alternates file, if the new repository is not sitting next to the original repository, such relative paths needs to be adjusted so that they can be used in the new repository. This updates add_to_alternates_file() to take the path to the alternate object store, including the "/objects" part at the end (earlier, it was taking the path to $GIT_DIR and was adding "/objects" itself), as it is technically possible to specify in objects/info/alternates file the path of a directory whose name does not end with "/objects". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-23clone: allow more than one --referenceJunio C Hamano
Also add a test to expose a long-standing bug that is triggered when cloning with --reference option from a local repository that has its own alternates. The alternate object stores specified on the command line are lost, and only alternates copied from the source repository remain. The bug will be fixed in the next patch. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-22clone: allow to clone from .git fileNguyễ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-01Merge branch 'jk/clone-detached'Junio C Hamano
* jk/clone-detached: clone: always fetch remote HEAD make copy_ref globally available consider only branches in guess_remote_head t: add tests for cloning remotes with detached HEAD
2011-06-22clone: accept config options on the command lineJeff King
Clone does all of init, "remote add", fetch, and checkout without giving the user a chance to intervene and set any configuration. This patch allows you to set config options in the newly created repository after the clone, but before we do any other operations. In many cases, this is a minor convenience over something like: git clone git://... git config core.whatever true But in some cases, it can bring extra efficiency by changing how the fetch or checkout work. For example, setting line-ending config before the checkout avoids having to re-checkout all of the contents with the correct line endings. It also provides a mechanism for passing information to remote helpers during a clone; the helpers may read the git config to influence how they operate. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-07clone: always fetch remote HEADJeff King
In most cases, fetching the remote HEAD explicitly is unnecessary. It's just a symref pointing to a branch which we are already fetching, so we will already ask for its sha1. However, if the remote has a detached HEAD, things are less certain. We do not ask for HEAD's sha1, but we do try to write it into a local detached HEAD. In most cases this is fine, as the remote HEAD is pointing to some part of the history graph that we will fetch via the refs. But if the remote HEAD points to an "orphan" commit (one which was is not an ancestor of any refs), then we will not have the object, and update_ref will complain when we try to write the detached HEAD, aborting the whole clone. This patch makes clone always explicitly ask the remote for the sha1 of its HEAD commit. In the non-detached case, this is a no-op, as we were going to ask for that sha1 anyway. In the regular detached case, this will add an extra "want" to the protocol negotiation, but will not change the history that gets sent. And in the detached orphan case, we will fetch the orphaned history so that we can write it into our local detached HEAD. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-31Merge branch 'ab/i18n-fixup' into maintJunio C Hamano
* ab/i18n-fixup: (24 commits) i18n: use test_i18n{cmp,grep} in t7600, t7607, t7611 and t7811 i18n: use test_i18n{grep,cmp} in t7508 i18n: use test_i18ngrep in t7506 i18n: use test_i18ngrep and test_i18ncmp in t7502 i18n: use test_i18ngrep in t7501 i18n: use test_i18ncmp in t7500 i18n: use test_i18ngrep in t7201 i18n: use test_i18ncmp and test_i18ngrep in t7102 and t7110 i18n: use test_i18ncmp and test_i18ngrep in t5541, t6040, t6120, t7004, t7012 and t7060 i18n: use test_i18ncmp and test_i18ngrep in t3700, t4001 and t4014 i18n: use test_i18ncmp and test_i18ngrep in t3203, t3501 and t3507 i18n: use test_i18ngrep in t2020, t2204, t3030, and t3200 i18n: use test_i18ngrep in lib-httpd and t2019 i18n: do not overuse C_LOCALE_OUTPUT (grep) i18n: use test_i18ncmp in t1200 and t2200 i18n: .git file is not a human readable message (t5601) i18n: do not overuse C_LOCALE_OUTPUT i18n: mark init-db messages for translation i18n: mark checkout plural warning for translation i18n: mark checkout --detach messages for translation ...
2011-05-25Merge branch 'maint'Junio C Hamano
* maint: init/clone: remove short option -L and document --separate-git-dir
2011-05-25init/clone: remove short option -L and document --separate-git-dirNguyen Thai Ngoc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-12i18n: mark clone nonexistent repository message for translationÆvar Arnfjörð Bjarmason
Mark the "repository '%s' does not exist" message added in v1.7.4.2~21^2 (clone: die when trying to clone missing local path) by Jeff King for translation. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-02Merge branch 'nd/init-gitdir'Junio C Hamano
* nd/init-gitdir: init, clone: support --separate-git-dir for .git file git-init.txt: move description section up Conflicts: builtin/clone.c
2011-04-02Merge branch 'ab/i18n-st'Junio C Hamano
* ab/i18n-st: (69 commits) i18n: git-shortlog basic messages i18n: git-revert split up "could not revert/apply" message i18n: git-revert literal "me" messages i18n: git-revert "Your local changes" message i18n: git-revert basic messages i18n: git-notes GIT_NOTES_REWRITE_MODE error message i18n: git-notes basic commands i18n: git-gc "Auto packing the repository" message i18n: git-gc basic messages i18n: git-describe basic messages i18n: git-clean clean.requireForce messages i18n: git-clean basic messages i18n: git-bundle basic messages i18n: git-archive basic messages i18n: git-status "renamed: " message i18n: git-status "Initial commit" message i18n: git-status "Changes to be committed" message i18n: git-status shortstatus messages i18n: git-status "nothing to commit" messages i18n: git-status basic messages ... Conflicts: builtin/branch.c builtin/checkout.c builtin/clone.c builtin/commit.c builtin/grep.c builtin/merge.c builtin/push.c builtin/revert.c t/t3507-cherry-pick-conflict.sh t/t7607-merge-overwrite.sh