From 2e0afafebd8c5a1a8cdddb0714073461229ecfef Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 22 Feb 2007 01:59:14 +0100 Subject: 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 . 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 Signed-off-by: Junio C Hamano --- index-pack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'index-pack.c') diff --git a/index-pack.c b/index-pack.c index 72e0962415..24bbdcd82f 100644 --- a/index-pack.c +++ b/index-pack.c @@ -457,8 +457,8 @@ static void parse_pack_objects(unsigned char *sha1) /* If input_fd is a file, we should have reached its end now. */ if (fstat(input_fd, &st)) die("cannot fstat packfile: %s", strerror(errno)); - if (S_ISREG(st.st_mode) && st.st_size != consumed_bytes) - die("pack has junk at the end"); + if (input_fd && S_ISREG(st.st_mode) && st.st_size != consumed_bytes) + die("pack has junk at the end: 0%o, %d, %d %d", st.st_mode, (int)st.st_size, (int)consumed_bytes, input_fd); if (!nr_deltas) return; -- cgit v1.2.1 From fa257b0554d5cea91c2bba98c2017336e0890b36 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 22 Feb 2007 19:14:14 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- index-pack.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'index-pack.c') diff --git a/index-pack.c b/index-pack.c index 24bbdcd82f..64d75f8c4d 100644 --- a/index-pack.c +++ b/index-pack.c @@ -457,8 +457,9 @@ static void parse_pack_objects(unsigned char *sha1) /* If input_fd is a file, we should have reached its end now. */ if (fstat(input_fd, &st)) die("cannot fstat packfile: %s", strerror(errno)); - if (input_fd && S_ISREG(st.st_mode) && st.st_size != consumed_bytes) - die("pack has junk at the end: 0%o, %d, %d %d", st.st_mode, (int)st.st_size, (int)consumed_bytes, input_fd); + if (S_ISREG(st.st_mode) && + lseek(input_fd, 0, SEEK_CUR) - input_len != st.st_size) + die("pack has junk at the end"); if (!nr_deltas) return; -- cgit v1.2.1