Commit Graph

29 Commits

Author SHA1 Message Date
Thiago Farina
1f986c4ac4 Update the usage bundle string.
"git bundle -h" gives a single long line that is hard to read.  Rewrite it
into a multi-line format similar to the one used by other commands, e.g
"git stash -h".

Signed-off-by: Thiago Farina <tfransosi@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-18 19:47:15 -07:00
Heikki Orsila
34baebcee1 Start conforming code to "git subcmd" style
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-08-30 13:50:48 -07:00
SZEDER Gábor
af05d67939 Always set *nongit_ok in setup_git_directory_gently()
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>
2008-03-26 15:41:35 -07:00
Johannes Schindelin
30415d50cc Move bundle specific stuff into bundle.[ch]
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-09-19 03:22:30 -07:00
Junio C Hamano
4b37666ccb builtin-bundle create - use lock_file
"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-13 13:04:18 -07:00
Mark Levedahl
21a02980f9 builtin-bundle - use buffered reads for bundle header
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-10 22:33:44 -07:00
Mark Levedahl
442b67a559 builtin-bundle.c - use stream buffered input for rev-list
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-10 22:20:35 -07:00
Junio C Hamano
c06793a4ed allow git-bundle to create bottomless bundle
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-10 22:19:15 -07:00
Junio C Hamano
7fa8254f94 allow git-bundle to create bottomless bundle
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-08-10 22:19:06 -07:00
Peter Hagervall
baffc0e770 Make every builtin-*.c file #include "builtin.h"
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-07-14 22:44:09 -07:00
Johan Herland
8a912bcb25 Ensure return value from xread() is always stored into an ssize_t
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-05-15 21:16:03 -07:00
Theodore Ts'o
46efd2d93c Rename warn() to warning() to fix symbol conflicts on BSD and Mac OS
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-31 01:11:11 -07:00
Shawn O. Pearce
b1daf300d0 Replace fork_with_pipe in bundle with run_command
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-12 23:40:17 -07:00
Johannes Schindelin
34572ed2c8 git-bundle: only die if pack would be empty, warn if ref is skipped
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-11 23:55:46 -07:00
Johannes Schindelin
2e578f9a4f git-bundle: prevent overwriting existing bundles
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-08 22:59:07 -08:00
Johannes Schindelin
d58c6184e3 git-bundle: die if a given ref is not included in bundle
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-08 22:58:03 -08:00
Johannes Schindelin
263703fff3 git-bundle: handle thin packs in subcommand "unbundle"
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-08 22:57:51 -08:00
Johannes Schindelin
9e64d109f9 git-bundle: Make thin packs
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-07 18:02:10 -08:00
Johannes Schindelin
18449ab0e9 git-bundle: avoid packing objects which are in the prerequisites
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-07 17:38:48 -08:00
Johannes Schindelin
8315588b59 bundle: fix wrong check of read_header()'s return value & add tests
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-06 22:06:46 -08:00
Junio C Hamano
80e25ceece git-bundle: make verify a bit more chatty.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-06 01:08:34 -08:00
Junio C Hamano
c2dea5a11c git-bundle: various fixups
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-06 01:08:34 -08:00
Junio C Hamano
2b064697a5 revision traversal: retire BOUNDARY_SHOW
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-06 01:08:34 -08:00
Junio C Hamano
c044aa18f6 git-bundle: fix pack generation.
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-03-05 23:28:36 -08:00
Junio C Hamano
64d99e9c5a bundle: reword missing prerequisite error message
As suggested by Mark Levedahl.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-24 01:16:58 -08:00
Johannes Schindelin
239296770d git-bundle: record commit summary in the prerequisite data 2007-02-22 22:30:33 -08:00
Johannes Schindelin
fb9a54150d git-bundle: avoid fork() in verify_bundle()
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-22 22:30:33 -08:00
Johannes Schindelin
fa257b0554 git-bundle: assorted fixes
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-22 22:30:33 -08:00
Johannes Schindelin
2e0afafebd Add git-bundle: move objects and references by archive
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>
2007-02-22 22:30:33 -08:00