summaryrefslogtreecommitdiff
path: root/builtin-bundle.c
AgeCommit message (Collapse)AuthorFilesLines
2008-08-30Start conforming code to "git subcmd" styleLibravatar Heikki Orsila1-2/+2
User notifications are presented as 'git cmd', and code comments are presented as '"cmd"' or 'git's cmd', rather than 'git-cmd'. Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-26Always set *nongit_ok in setup_git_directory_gently()Libravatar SZEDER Gábor1-1/+1
setup_git_directory_gently() only modified the value of its *nongit_ok argument if we were not in a git repository. Now it will always set it to 0 when we are inside a repository. Also remove now unnecessary initializations in the callers of this function. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-19Move bundle specific stuff into bundle.[ch]Libravatar Johannes Schindelin1-359/+6
The transport specific stuff was moved into libgit.a, and the bundle specific stuff will not be left behind. This is a big code move, with one exception: the function unbundle() no longer outputs the list of refs. You have to call list_bundle_refs() yourself for that. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-13builtin-bundle create - use lock_fileLibravatar Junio C Hamano1-8/+10
"git bundle create" left an invalid, partially written bundle if an error occured during creation. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-10builtin-bundle - use buffered reads for bundle headerLibravatar Mark Levedahl1-24/+13
This eliminates all use of byte-at-a-time reading of data in this function: as Junio noted, a bundle file is seekable so we can reset the file position to the first part of the pack-file using lseek after reading the header. Signed-off-by: Mark Levedahl <mdl123@verizon.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-10builtin-bundle.c - use stream buffered input for rev-listLibravatar Mark Levedahl1-2/+5
git-bundle create on cygwin was nearly unusable due to 1 character at a time (unbuffered) reading from an exec'ed process. Fix by using fdopen to get a buffered stream. Results for "time git bundle create test.bdl v1.0.3..v1.5.2" are: before this patch: cygwin linux real 1m38.828s 0m3.578s user 0m12.122s 0m2.896s sys 1m28.215s 0m0.692s after this patch: real 0m3.688s 0m2.835s user 0m3.075s 0m2.731s sys 0m1.075s 0m0.149s Signed-off-by: Mark Levedahl <mdl123@verizon.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-10allow git-bundle to create bottomless bundleLibravatar Junio C Hamano1-0/+33
Mark Levedahl <mlevedahl@gmail.com> writes: > Junio C Hamano wrote: >> While "git bundle" was a useful way to sneakernet incremental >> changes, we did not allow: >> > Thanks - I've been thinking for months I could fix this bug, never > figured it out and didn't want to nag Dscho one more time. I confirm > that this allows creation of bundles with arbitrary refs, not just > those under refs/heads. Yahoo! Actually, there is another bug nearby. If you do: git bundle create v2.6-20-v2.6.22.bndl v2.6.20..v2.6.22 the bundle records that it requires v2.6.20^0 commit (correct) and gives you tag v2.6.22 (incorrect); the bug is that the object it lists in fact is the commit v2.6.22^0, not the tag. This is because the revision range operation .. is always about set of commits, but the code near where my patch touches does not validate that the sha1 value obtained from dwim_ref() against the commit object name e->item->sha1 before placing the head information in the commit. The attached patch attempts to fix this problem. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-10allow git-bundle to create bottomless bundleLibravatar Junio C Hamano1-1/+9
While "git bundle" was a useful way to sneakernet incremental changes, we did not allow: $ git bundle create v2.6.20.bndl v2.6.20 to create a bundle that contains the whole history to a well-known good revision. Such a bundle can be mirrored everywhere, and people can prime their repository with it to reduce the load on the repository that serves near the tip of the development. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-14Make every builtin-*.c file #include "builtin.h"Libravatar Peter Hagervall1-0/+1
Make every builtin-*.c file #include "builtin.h". Also takes care of some declaration/definition mismatches. Signed-off-by: Peter Hagervall <hager@cs.umu.se> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-05-15Ensure return value from xread() is always stored into an ssize_tLibravatar Johan Herland1-1/+1
This patch fixes all calls to xread() where the return value is not stored into an ssize_t. The patch should not have any effect whatsoever, other than putting better/more appropriate type names on variables. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-31Rename warn() to warning() to fix symbol conflicts on BSD and Mac OSLibravatar Theodore Ts'o1-2/+2
This fixes a problem reported by Randal Schwartz: >I finally tracked down all the (albeit inconsequential) errors I was getting >on both OpenBSD and OSX. It's the warn() function in usage.c. There's >warn(3) in BSD-style distros. It'd take a "great rename" to change it, but if >someone with better C skills than I have could do that, my linker and I would >appreciate it. It was annoying to me, too, when I was doing some mergetool testing on Mac OS X, so here's a fix. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: "Randal L. Schwartz" <merlyn@stonehenge.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-12Replace fork_with_pipe in bundle with run_commandLibravatar Shawn O. Pearce1-99/+30
Now that the run_command family supports all of the redirection modes needed by builtin-bundle, we can use those functions rather than the underlying POSIX primitives. This should help to make the bundle command slightly more portable to other systems, like Windows. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-11git-bundle: only die if pack would be empty, warn if ref is skippedLibravatar Johannes Schindelin1-3/+8
A use case for git-bundle expected to be quite common is this: $ git bundle create daily.bundle --since=10.days.ago --all The expected outcome is _not_ to error out if only a couple of the refs were not changed during the last 10 days. This patch complains loudly about refs which are skipped due to the pack not containing the corresponding objects, but dies only if no objects would be in the pack _at all_. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-08git-bundle: prevent overwriting existing bundlesLibravatar Johannes Schindelin1-2/+2
Not only does it prevent accidentally losing older bundles, but it also fixes a subtle bug: when writing into an existing bundle, git-pack-objects would not truncate the bundle. Therefore, fetching from the bundle would trigger an error in unpack-objects: "fatal: pack has junk at the end". Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-08git-bundle: die if a given ref is not included in bundleLibravatar Johannes Schindelin1-4/+2
The earlier patch tried to be nice by just warning, but it seems more likely that the user wants to adjust the parameters. Also, it prevents a bundle containing _all_ revisions in the case when the user only gave one ref, but also rev-list options which excluded the ref. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-08git-bundle: handle thin packs in subcommand "unbundle"Libravatar Johannes Schindelin1-1/+2
The patch to make the packs in a bundle thin forgot the receiving side. D'oh. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-07git-bundle: Make thin packsLibravatar Johannes Schindelin1-59/+26
Thin packs are way smaller, but they rely on the receiving end to have the base objects. However, Git's pack protocol also uses thin packs by default. So make the packs contained in bundles thin, since bundles are just another transport. The patch looks a bit bigger than intended, mainly because --thin _implies_ that pack-objects should run its own rev-list. Therefore, this patch removes all the stuff we used to roll rev-list ourselves. This commit also changes behaviour slightly: since we now know early enough if a specified ref is _not_ contained in the pack, we can avoid putting that ref into the pack. So, we don't die() here, but warn() instead, and skip that ref. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-07git-bundle: avoid packing objects which are in the prerequisitesLibravatar Johannes Schindelin1-3/+12
When saying something like "--since=1.day.ago" or "--max-count=5", git-bundle finds the boundary commits which are recorded as prerequisites. However, it failed to tell pack-objects _not_ to pack the objects which are in these. Fix that. And add a test for that. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-06bundle: fix wrong check of read_header()'s return value & add testsLibravatar Johannes Schindelin1-1/+3
If read_header() fails, it returns <0, not 0. Further, an open(/dev/null) was not checked for errors. Also, this adds two tests to make sure that the bundle file looks correct, by checking if it has the header has the expected form, and that the pack contains the right amount of objects. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-06git-bundle: make verify a bit more chatty.Libravatar Junio C Hamano1-20/+35
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-06git-bundle: various fixupsLibravatar Junio C Hamano1-13/+33
verify_bundle() returned with an error early only when all prerequisite commits were missing. It should error out much earlier when some are missing. When the rev-list is limited in ways other than revision range (e.g. --max-count or --max-age), create_bundle() listed all positive refs given from the command line as if they are available, but resulting pack may not have some of them. Add a logic to make sure all of them are included, and error out otherwise. Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-06revision traversal: retire BOUNDARY_SHOWLibravatar Junio C Hamano1-2/+4
This removes the flag internally used by revision traversal to decide which commits are indeed boundaries and renames it to CHILD_SHOWN. builtin-bundle uses the symbol for its verification, but I think the logic it uses it is wrong. The flag is still useful but it is local to the git-bundle, so it is renamed to PREREQ_MARK. Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-05git-bundle: fix pack generation.Libravatar Junio C Hamano1-0/+6
The handcrafted built-in rev-list lookalike forgot to mark the trees and blobs contained in the boundary commits uninteresting, resulting in unnecessary objects in the pack. Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-24bundle: reword missing prerequisite error messageLibravatar Junio C Hamano1-1/+1
As suggested by Mark Levedahl. Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-22git-bundle: record commit summary in the prerequisite dataLibravatar Johannes Schindelin1-3/+4
2007-02-22git-bundle: avoid fork() in verify_bundle()Libravatar Johannes Schindelin1-27/+48
We can use the revision walker easily for checking if the prerequisites are met, instead of fork()ing off a rev-list, which would list only the first unmet prerequisite. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-22git-bundle: assorted fixesLibravatar Johannes Schindelin1-47/+60
This patch fixes issues mentioned by Junio, Nico and Simon: - I forgot to convert the usage string when removing the "--" from the subcommands, - a style fix in the bundle_header, - use xread() instead of read(), - use write_or_die() instead of write(), - make the bundle header extensible, - fail if the whitespace after a sha1 of a reference is missing, - close() the fds passed to a subprocess, - in verify_bundle(), do not use "rev-list --stdin", but rather pass the revs directly (avoiding a fork()), - fix a corrupted comment in show_object(), and - fix the size check in index_pack. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-22Add git-bundle: move objects and references by archiveLibravatar Johannes Schindelin1-0/+389
Some workflows require use of repositories on machines that cannot be connected, preventing use of git-fetch / git-push to transport objects and references between the repositories. git-bundle provides an alternate transport mechanism, effectively allowing git-fetch and git-pull to operate using sneakernet transport. `git-bundle create` allows the user to create a bundle containing one or more branches or tags, but with specified basis assumed to exist on the target repository. At the receiving end, git-bundle acts like git-fetch-pack, allowing the user to invoke git-fetch or git-pull using the bundle file as the URL. git-fetch and git-ls-remote determine they have a bundle URL by checking that the URL points to a file, but are otherwise unchanged in operation with bundles. The original patch was done by Mark Levedahl <mdl123@verizon.net>. It was updated to make git-bundle a builtin, and get rid of the tar format: now, the first line is supposed to say "# v2 git bundle", the next lines either contain a prerequisite ("-" followed by the hash of the needed commit), or a ref (the hash of a commit, followed by the name of the ref), and finally the pack. As a result, the bundle argument can be "-" now. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>