summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f4f78e6)
raw | patch | inline | side by side (parent: f4f78e6)
author | Nick Edelen <sirnot@gmail.com> | |
Tue, 9 Jun 2009 23:50:18 +0000 (01:50 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 10 Jun 2009 06:49:31 +0000 (23:49 -0700) |
Offload object enumeration in upload-pack to pack-objects, but fall
back on internal revision walker for shallow interaction. Aside from
architecturally making more sense, this also leaves the door open for
pack-objects to employ a revision cache mechanism. Test t5530 updated
in order to explicitly check both enumeration methods.
Signed-off-by: Nick Edelen <sirnot@gmail.com>
Acked-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
back on internal revision walker for shallow interaction. Aside from
architecturally making more sense, this also leaves the door open for
pack-objects to employ a revision cache mechanism. Test t5530 updated
in order to explicitly check both enumeration methods.
Signed-off-by: Nick Edelen <sirnot@gmail.com>
Acked-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5530-upload-pack-error.sh | patch | blob | history | |
upload-pack.c | patch | blob | history |
index f5102b902a4fa0505fee13aa18d38a211cdb42cb..757cc19ecce127ddd0cbf528f7678c2940ac1519 100755 (executable)
test_must_fail git fsck
'
-test_expect_success 'upload-pack fails due to error in pack-objects' '
+test_expect_success 'upload-pack fails due to error in pack-objects packing' '
! echo "0032want $(git rev-parse HEAD)
00000009done
0000" | git upload-pack . > /dev/null 2> output.err &&
+ grep "unable to read" output.err &&
grep "pack-objects died" output.err
'
test_expect_success 'upload-pack fails due to error in rev-list' '
! echo "0032want $(git rev-parse HEAD)
-00000009done
+0034shallow $(git rev-parse HEAD^)00000009done
0000" | git upload-pack . > /dev/null 2> output.err &&
grep "waitpid (async) failed" output.err
'
+test_expect_success 'upload-pack fails due to error in pack-objects enumeration' '
+
+ ! echo "0032want $(git rev-parse HEAD)
+00000009done
+0000" | git upload-pack . > /dev/null 2> output.err &&
+ grep "bad tree object" output.err &&
+ grep "pack-objects died" output.err
+'
+
test_expect_success 'create empty repository' '
mkdir foo &&
diff --git a/upload-pack.c b/upload-pack.c
index edc78612289c5bd774e18fe5f8e1b9ea80378a5f..397cada43b95fb4e350b4c294ccd794a75a1acb2 100644 (file)
--- a/upload-pack.c
+++ b/upload-pack.c
static int multi_ack, nr_our_refs;
static int use_thin_pack, use_ofs_delta, use_include_tag;
static int no_progress;
+static int shallow_nr;
static struct object_array have_obj;
static struct object_array want_obj;
static unsigned int timeout;
struct rev_info revs;
pack_pipe = fdopen(fd, "w");
- if (create_full_pack)
- use_thin_pack = 0; /* no point doing it */
init_revisions(&revs, NULL);
revs.tag_objects = 1;
revs.tree_objects = 1;
const char *argv[10];
int arg = 0;
- rev_list.proc = do_rev_list;
- /* .data is just a boolean: any non-NULL value will do */
- rev_list.data = create_full_pack ? &rev_list : NULL;
- if (start_async(&rev_list))
- die("git upload-pack: unable to fork git-rev-list");
+ if (shallow_nr) {
+ rev_list.proc = do_rev_list;
+ rev_list.data = 0;
+ if (start_async(&rev_list))
+ die("git upload-pack: unable to fork git-rev-list");
+ argv[arg++] = "pack-objects";
+ } else {
+ argv[arg++] = "pack-objects";
+ argv[arg++] = "--revs";
+ if (create_full_pack)
+ argv[arg++] = "--all";
+ else if (use_thin_pack)
+ argv[arg++] = "--thin";
+ }
- argv[arg++] = "pack-objects";
argv[arg++] = "--stdout";
if (!no_progress)
argv[arg++] = "--progress";
argv[arg++] = NULL;
memset(&pack_objects, 0, sizeof(pack_objects));
- pack_objects.in = rev_list.out; /* start_command closes it */
+ pack_objects.in = shallow_nr ? rev_list.out : -1;
pack_objects.out = -1;
pack_objects.err = -1;
pack_objects.git_cmd = 1;
if (start_command(&pack_objects))
die("git upload-pack: unable to fork git-pack-objects");
+ /* pass on revisions we (don't) want */
+ if (!shallow_nr) {
+ FILE *pipe_fd = fdopen(pack_objects.in, "w");
+ if (!create_full_pack) {
+ int i;
+ for (i = 0; i < want_obj.nr; i++)
+ fprintf(pipe_fd, "%s\n", sha1_to_hex(want_obj.objects[i].item->sha1));
+ fprintf(pipe_fd, "--not\n");
+ for (i = 0; i < have_obj.nr; i++)
+ fprintf(pipe_fd, "%s\n", sha1_to_hex(have_obj.objects[i].item->sha1));
+ }
+
+ fprintf(pipe_fd, "\n");
+ fflush(pipe_fd);
+ fclose(pipe_fd);
+ }
+
+
/* We read from pack_objects.err to capture stderr output for
* progress bar, and pack_objects.out to capture the pack data.
*/
error("git upload-pack: git-pack-objects died with error.");
goto fail;
}
- if (finish_async(&rev_list))
+ if (shallow_nr && finish_async(&rev_list))
goto fail; /* error was already reported */
/* flush the data */
static char line[1000];
int len, depth = 0;
+ shallow_nr = 0;
if (debug_fd)
write_in_full(debug_fd, "#S\n", 3);
for (;;) {
packet_write(1, "shallow %s",
sha1_to_hex(object->sha1));
register_shallow(object->sha1);
+ shallow_nr++;
}
result = result->next;
}
for (i = 0; i < shallows.nr; i++)
register_shallow(shallows.objects[i].item->sha1);
}
+
+ shallow_nr += shallows.nr;
free(shallows.objects);
}