upload-pack: Move the revision walker into a separate function.
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>
Johannes Sixt committed
Oct 19, 2007 at 21:48 UTC
80ccaa78a8b95ad3b4f6e24dc35a9aa3cae5fd86
1 file changed
+37
-33
upload-pack.c
+37
-33
@@ -97,6 +97,42 @@ static void show_edge(struct commit *commit)
97
fprintf(pack_pipe, "-%s\n", sha1_to_hex(commit->object.sha1));
98
}
99
100
+static void do_rev_list(int create_full_pack)
101
+{
102
+ int i;
103
+ struct rev_info revs;
104
+
105
+ if (create_full_pack)
106
+ use_thin_pack = 0; /* no point doing it */
107
+ init_revisions(&revs, NULL);
108
+ revs.tag_objects = 1;
109
+ revs.tree_objects = 1;
110
+ revs.blob_objects = 1;
111
+ if (use_thin_pack)
112
+ revs.edge_hint = 1;
113
+
114
+ if (create_full_pack) {
115
+ const char *args[] = {"rev-list", "--all", NULL};
116
+ setup_revisions(2, args, &revs, NULL);
117
+ } else {
118
+ for (i = 0; i < want_obj.nr; i++) {
119
+ struct object *o = want_obj.objects[i].item;
120
+ /* why??? */
121
+ o->flags &= ~UNINTERESTING;
122
+ add_pending_object(&revs, o, NULL);
123
+ }
124
+ for (i = 0; i < have_obj.nr; i++) {
125
+ struct object *o = have_obj.objects[i].item;
126
+ o->flags |= UNINTERESTING;
127
+ add_pending_object(&revs, o, NULL);
128
+ }
129
+ setup_revisions(0, NULL, &revs, NULL);
130
+ }
131
+ prepare_revision_walk(&revs);
132
+ mark_edges_uninteresting(revs.commits, &revs, show_edge);
133
+ traverse_commit_list(&revs, show_commit, show_object);
134
+}
135
+
136
static void create_pack_file(void)
137
{
138
/* Pipe from rev-list to pack-objects
@@ -119,41 +155,9 @@ static void create_pack_file(void)
155
die("git-upload-pack: unable to fork git-rev-list");
156
157
if (!pid_rev_list) {
122
- int i;
123
- struct rev_info revs;
124
-
158
close(lp_pipe[0]);
159
pack_pipe = fdopen(lp_pipe[1], "w");
127
-
128
- if (create_full_pack)
129
- use_thin_pack = 0; /* no point doing it */
130
- init_revisions(&revs, NULL);
131
- revs.tag_objects = 1;
132
- revs.tree_objects = 1;
133
- revs.blob_objects = 1;
134
- if (use_thin_pack)
135
- revs.edge_hint = 1;
136
-
137
- if (create_full_pack) {
138
- const char *args[] = {"rev-list", "--all", NULL};
139
- setup_revisions(2, args, &revs, NULL);
140
- } else {
141
- for (i = 0; i < want_obj.nr; i++) {
142
- struct object *o = want_obj.objects[i].item;
143
- /* why??? */
144
- o->flags &= ~UNINTERESTING;
145
- add_pending_object(&revs, o, NULL);
146
- }
147
- for (i = 0; i < have_obj.nr; i++) {
148
- struct object *o = have_obj.objects[i].item;
149
- o->flags |= UNINTERESTING;
150
- add_pending_object(&revs, o, NULL);
151
- }
152
- setup_revisions(0, NULL, &revs, NULL);
153
- }
154
- prepare_revision_walk(&revs);
155
- mark_edges_uninteresting(revs.commits, &revs, show_edge);
156
- traverse_commit_list(&revs, show_commit, show_object);
160
+ do_rev_list(create_full_pack);
161
exit(0);
162
}
163