Code

upload-pack: Move the revision walker into a separate function.
authorJohannes Sixt <johannes.sixt@telecom.at>
Fri, 19 Oct 2007 19:48:02 +0000 (21:48 +0200)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 21 Oct 2007 05:30:41 +0000 (01:30 -0400)
This allows us later to use start_async() with this function, and at
the same time is a nice cleanup that makes a long function
(create_pack_file()) shorter.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
upload-pack.c

index 5c0c0cc8e5ee1105584ec0128b391e7d518e4a5c..ccdc30653bdede85d351e55bb1360c3049b05fef 100644 (file)
@@ -97,6 +97,42 @@ static void show_edge(struct commit *commit)
        fprintf(pack_pipe, "-%s\n", sha1_to_hex(commit->object.sha1));
 }
 
+static void do_rev_list(int create_full_pack)
+{
+       int i;
+       struct rev_info revs;
+
+       if (create_full_pack)
+               use_thin_pack = 0; /* no point doing it */
+       init_revisions(&revs, NULL);
+       revs.tag_objects = 1;
+       revs.tree_objects = 1;
+       revs.blob_objects = 1;
+       if (use_thin_pack)
+               revs.edge_hint = 1;
+
+       if (create_full_pack) {
+               const char *args[] = {"rev-list", "--all", NULL};
+               setup_revisions(2, args, &revs, NULL);
+       } else {
+               for (i = 0; i < want_obj.nr; i++) {
+                       struct object *o = want_obj.objects[i].item;
+                       /* why??? */
+                       o->flags &= ~UNINTERESTING;
+                       add_pending_object(&revs, o, NULL);
+               }
+               for (i = 0; i < have_obj.nr; i++) {
+                       struct object *o = have_obj.objects[i].item;
+                       o->flags |= UNINTERESTING;
+                       add_pending_object(&revs, o, NULL);
+               }
+               setup_revisions(0, NULL, &revs, NULL);
+       }
+       prepare_revision_walk(&revs);
+       mark_edges_uninteresting(revs.commits, &revs, show_edge);
+       traverse_commit_list(&revs, show_commit, show_object);
+}
+
 static void create_pack_file(void)
 {
        /* Pipe from rev-list to pack-objects
@@ -119,41 +155,9 @@ static void create_pack_file(void)
                die("git-upload-pack: unable to fork git-rev-list");
 
        if (!pid_rev_list) {
-               int i;
-               struct rev_info revs;
-
                close(lp_pipe[0]);
                pack_pipe = fdopen(lp_pipe[1], "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;
-               revs.blob_objects = 1;
-               if (use_thin_pack)
-                       revs.edge_hint = 1;
-
-               if (create_full_pack) {
-                       const char *args[] = {"rev-list", "--all", NULL};
-                       setup_revisions(2, args, &revs, NULL);
-               } else {
-                       for (i = 0; i < want_obj.nr; i++) {
-                               struct object *o = want_obj.objects[i].item;
-                               /* why??? */
-                               o->flags &= ~UNINTERESTING;
-                               add_pending_object(&revs, o, NULL);
-                       }
-                       for (i = 0; i < have_obj.nr; i++) {
-                               struct object *o = have_obj.objects[i].item;
-                               o->flags |= UNINTERESTING;
-                               add_pending_object(&revs, o, NULL);
-                       }
-                       setup_revisions(0, NULL, &revs, NULL);
-               }
-               prepare_revision_walk(&revs);
-               mark_edges_uninteresting(revs.commits, &revs, show_edge);
-               traverse_commit_list(&revs, show_commit, show_object);
+               do_rev_list(create_full_pack);
                exit(0);
        }