summaryrefslogtreecommitdiff
path: root/builtin-clone.c
AgeCommit message (Collapse)Author
2009-02-01Merge branch 'jk/signal-cleanup'Junio C Hamano
* jk/signal-cleanup: t0005: use SIGTERM for sigchain test pager: do wait_for_pager on signal death refactor signal handling for cleanup functions chain kill signals for cleanup functions diff: refactor tempfile cleanup handling Windows: Fix signal numbers
2009-01-23Allow cloning an empty repositorySverre Rabbelier
Cloning an empty repository manually (that is, doing 'git init' and then doing all configuration by hand) can be a lot of work. Save the user this work by allowing the cloning of empty repositories. Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-22refactor signal handling for cleanup functionsJeff King
The current code is very inconsistent about which signals are caught for doing cleanup of temporary files and lock files. Some callsites checked only SIGINT, while others checked a variety of death-dealing signals. This patch factors out those signals to a single function, and then calls it everywhere. For some sites, that means this is a simple clean up. For others, it is an improvement in that they will now properly clean themselves up after a larger variety of signals. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-22chain kill signals for cleanup functionsJeff King
If a piece of code wanted to do some cleanup before exiting (e.g., cleaning up a lockfile or a tempfile), our usual strategy was to install a signal handler that did something like this: do_cleanup(); /* actual work */ signal(signo, SIG_DFL); /* restore previous behavior */ raise(signo); /* deliver signal, killing ourselves */ For a single handler, this works fine. However, if we want to clean up two _different_ things, we run into a problem. The most recently installed handler will run, but when it removes itself as a handler, it doesn't put back the first handler. This patch introduces sigchain, a tiny library for handling a stack of signal handlers. You sigchain_push each handler, and use sigchain_pop to restore whoever was before you in the stack. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-11Allow cloning to an existing empty directoryAlexander Potashev
The die() message updated accordingly. The previous behaviour was to only allow cloning when the destination directory doesn't exist. [jc: added trivial tests] Signed-off-by: Alexander Potashev <aspotashev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-05remove trailing LF in die() messagesAlexander Potashev
LF at the end of format strings given to die() is redundant because die already adds one on its own. Signed-off-by: Alexander Potashev <aspotashev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-25builtin_clone: use strbuf in cmd_clone()Miklos Vajna
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-25builtin-clone: use strbuf in clone_local() and copy_or_link_directory()Miklos Vajna
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-25builtin-clone: use strbuf in guess_dir_name()Miklos Vajna
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-19Merge branch 'mv/clonev'Junio C Hamano
* mv/clonev: Implement git clone -v
2008-10-12Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializerBrandon Casey
Many call sites use strbuf_init(&foo, 0) to initialize local strbuf variable "foo" which has not been accessed since its declaration. These can be replaced with a static initialization using the STRBUF_INIT macro which is just as readable, saves a function call, and takes up fewer lines. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-10-09Implement git clone -vMiklos Vajna
The new -v option forces the progressbar, even in case the output is not a terminal. This can be useful if the caller is an IDE or wrapper which wants to scrape the progressbar from stderr and show its information in a different format. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-25Merge branch 'jc/alternate-push'Shawn O. Pearce
* jc/alternate-push: push: receiver end advertises refs from alternate repositories push: prepare sender to receive extended ref information from the receiver receive-pack: make it a builtin is_directory(): a generic helper function
2008-09-20builtin-clone: fix typoFabrizio Chiarello
Signed-off-by: Fabrizio Chiarello <ponch@autistici.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-09-09is_directory(): a generic helper functionJunio C Hamano
A simple "grep -e stat --and -e S_ISDIR" revealed there are many open-coded implementations of this function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-09-03clone: fix creation of explicitly named target directoryClemens Buchacher
'git clone <repo> path/' (note the trailing slash) fails, because the entire path is interpreted as leading directories. So when mkdir tries to create the actual path, it already exists. This makes sure trailing slashes are removed. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-09-02Bring local clone's origin URL in line with that of a remote cloneJohan Herland
On a local clone, "git clone" would use the fully DWIMmed path as the origin URL in the resulting repo. This was slightly inconsistent with the case of a remote clone where the _given_ URL was used as the origin URL (because the DWIMming was done remotely, and was therefore not available to "git clone"). This behaviour caused problems when cloning a local non-bare repo with relative submodule URLs, because these submodule URLs would then be resolved against the DWIMmed URL (e.g. "/repo/.git") instead of the given URL (e.g. "/repo"). This patch teaches "git clone" to use the _given_ URL - instead of the DWIMmed path - as the origin URL. This causes relative submodule URLs to be resolved correctly, as long the _given_ URL indicates the correct directory against which the submodule URLs should be resolved. The patch also updates a testcase that contained the old-style origin URLs. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-08clone --mirror: avoid storing repeated tagsJohannes Schindelin
With --mirror, clone asks for refs/* already, so it does not need to ask for ref/tags/*, too. Noticed by Cesar Eduardo Barros. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-03clone --bare: Add ".git" suffix to the directory name to clone intoJohannes Schindelin
We have a tradition that bare repositories live in directories ending in ".git". To make this more a convention than just a tradition, teach "git clone --bare" to add a ".git" suffix to the directory name. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-02clone: Add an option to set up a mirrorJohannes Schindelin
The command line $ git clone --mirror $URL is now a short-hand for $ git clone --bare $URL $ (cd $(basename $URL) && git remote add --mirror origin $URL) Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-26Propagate -u/--upload-pack option of "git clone" to transport.Steve Haslam
The -u option to override the remote system's path to git-upload-pack was being ignored by "git clone"; caused by a missing call to transport_set_option to set TRANS_OPT_UPLOADPACK. Presumably this crept in when git-clone was converted from shell to C. Signed-off-by: Steve Haslam <shaslam@lastminute.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-19builtin-clone: rewrite guess_dir_name()Johannes Sixt
The function has to do three small and independent tasks, but all of them were crammed into a single loop. This rewrites the function entirely by unrolling these tasks. We also now use is_dir_sep(c) instead of c == '/' to increase portability. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-13Make usage strings dash-lessStephan Beyer
When you misuse a git command, you are shown the usage string. But this is currently shown in the dashed form. So if you just copy what you see, it will not work, when the dashed form is no longer supported. This patch makes git commands show the dash-less version. For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh generates a dash-less usage string now. Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-09Merge branch 'maint'Junio C Hamano
* maint: Start preparing release notes for 1.5.6.3 git-submodule - Fix bugs in adding an existing repo as a module bash: offer only paths after '--' Remove unnecessary pack-*.keep file after successful git-clone make deleting a missing ref more quiet
2008-07-08Remove unnecessary pack-*.keep file after successful git-cloneShawn O. Pearce
Once a clone is successful we no longer need to hold onto the .keep file created by the transport. Delete the file so we can later repack the complete repository. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-07Merge branch 'qq/maint'Junio C Hamano
* qq/maint: mailinfo: feed the correct line length to decode_transfer_encoding() git-clone: remove leftover debugging fprintf().
2008-07-07git-clone: remove leftover debugging fprintf().Alex Riesen
Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-01Merge branch 'js/maint-clone-insteadof'Junio C Hamano
* js/maint-clone-insteadof: clone: respect the settings in $HOME/.gitconfig and /etc/gitconfig clone: respect url.insteadOf setting in global configs
2008-06-30clone: respect the settings in $HOME/.gitconfig and /etc/gitconfigJohannes Schindelin
After initializing the config in the newly-created repository, we need to unset GIT_CONFIG so that the global configs are read again. Noticed by Pieter de Bie. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-27clone: respect url.insteadOf setting in global configsJohannes Schindelin
When we call "git clone" with a url that has a rewrite rule in either $HOME/.gitconfig or /etc/gitconfig, the URL can be different from what the command line expects it to be. So, let's use the URL as the remote structure has it, not the literal string from the command line. Noticed by Pieter de Bie. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-25Merge branch 'jh/clone-packed-refs'Junio C Hamano
* jh/clone-packed-refs: Teach "git clone" to pack refs Prepare testsuite for a "git clone" that packs refs Move pack_refs() and friends into libgit Incorporate fetched packs in future object traversal
2008-06-25clone: create intermediate directories of destination repoJeff King
The shell version used to use "mkdir -p" to create the repo path, but the C version just calls "mkdir". Let's replicate the old behavior. We have to create the git and worktree leading dirs separately; while most of the time, the worktree dir contains the git dir (as .git), the user can override this using GIT_WORK_TREE. We can reuse safe_create_leading_directories, but we need to make a copy of our const buffer to do so. Since merge-recursive uses the same pattern, we can factor this out into a global function. This has two other cleanup advantages for merge-recursive: 1. mkdir_p wasn't a very good name. "mkdir -p foo/bar" actually creates bar, but this function just creates the leading directories. 2. mkdir_p took a mode argument, but it was completely ignored. Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-25clone: create intermediate directories of destination repoJeff King
The shell version used to use "mkdir -p" to create the repo path, but the C version just calls "mkdir". Let's replicate the old behavior. We have to create the git and worktree leading dirs separately; while most of the time, the worktree dir contains the git dir (as .git), the user can override this using GIT_WORK_TREE. We can reuse safe_create_leading_directories, but we need to make a copy of our const buffer to do so. Since merge-recursive uses the same pattern, we can factor this out into a global function. This has two other cleanup advantages for merge-recursive: 1. mkdir_p wasn't a very good name. "mkdir -p foo/bar" actually creates bar, but this function just creates the leading directories. 2. mkdir_p took a mode argument, but it was completely ignored. Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-19Teach "git clone" to pack refsJohan Herland
In repos with many refs, it is unlikely that most refs will ever change. This fact is already exploited by "git gc" by executing "git pack-refs" to consolidate all refs into a single file. When cloning a repo with many refs, it does not make sense to create the loose refs in the first place, just to have the next "git gc" consolidate them into one file. Instead, make "git clone" create the packed refs file immediately, and forego the loose refs completely. Signed-off-by: Johan Herland <johan@herland.net> Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-06Use nonrelative paths instead of absolute paths for cloned repositoriesDaniel Barkalow
Particularly for the "alternates" file, if one will be created, we want a path that doesn't depend on the current directory, but we want to retain any symlinks in the path as given and any in the user's view of the current directory when the path was given. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-28clone: make sure we support the transport typeJeff King
If we use an unsupported transport (e.g., http when curl support is not compiled in), transport_get reports an error to the user, but we still get a transport object. We need to manually check and abort the clone process at that point, or we end up with a segfault. Noticed by Thomas Rast. Signed-off-by: Jeff King <peff@peff.net> Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-25Merge branch 'js/config-cb'v1.5.6-rc0Junio C Hamano
* js/config-cb: Provide git_config with a callback-data parameter Conflicts: builtin-add.c builtin-cat-file.c
2008-05-21clone: fall back to copying if hardlinking failsDaniel Barkalow
Note that it stops trying hardlinks if any fail. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-19builtin-clone.c: Need to closedir() in copy_or_link_directory()Brandon Casey
So not to leak file descriptors, close the directory after opening it. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-15builtin-clone: fix initial checkoutJohannes Schindelin
Somewhere in the process of finishing up builtin-clone, the update of the working tree was lost. This was due to not using the option "merge" for unpack_trees(). Breakage noticed by Kevin Ballard. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Tested-by: Jeff King <peff@peff.net> Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-05Build in cloneDaniel Barkalow
Thanks to Johannes Schindelin for various comments and improvements, including supporting cloning full bundles. Signed-off-by: Junio C Hamano <gitster@pobox.com>