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>
This commit is contained in:
parent
088fab5fc4
commit
80ccaa78a8
@ -97,34 +97,11 @@ static void show_edge(struct commit *commit)
|
||||
fprintf(pack_pipe, "-%s\n", sha1_to_hex(commit->object.sha1));
|
||||
}
|
||||
|
||||
static void create_pack_file(void)
|
||||
static void do_rev_list(int create_full_pack)
|
||||
{
|
||||
/* Pipe from rev-list to pack-objects
|
||||
*/
|
||||
int lp_pipe[2];
|
||||
pid_t pid_rev_list;
|
||||
struct child_process pack_objects;
|
||||
int create_full_pack = (nr_our_refs == want_obj.nr && !have_obj.nr);
|
||||
char data[8193], progress[128];
|
||||
char abort_msg[] = "aborting due to possible repository "
|
||||
"corruption on the remote side.";
|
||||
int buffered = -1;
|
||||
const char *argv[10];
|
||||
int arg = 0;
|
||||
|
||||
if (pipe(lp_pipe) < 0)
|
||||
die("git-upload-pack: unable to create pipe");
|
||||
pid_rev_list = fork();
|
||||
if (pid_rev_list < 0)
|
||||
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);
|
||||
@ -154,6 +131,33 @@ static void create_pack_file(void)
|
||||
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
|
||||
*/
|
||||
int lp_pipe[2];
|
||||
pid_t pid_rev_list;
|
||||
struct child_process pack_objects;
|
||||
int create_full_pack = (nr_our_refs == want_obj.nr && !have_obj.nr);
|
||||
char data[8193], progress[128];
|
||||
char abort_msg[] = "aborting due to possible repository "
|
||||
"corruption on the remote side.";
|
||||
int buffered = -1;
|
||||
const char *argv[10];
|
||||
int arg = 0;
|
||||
|
||||
if (pipe(lp_pipe) < 0)
|
||||
die("git-upload-pack: unable to create pipe");
|
||||
pid_rev_list = fork();
|
||||
if (pid_rev_list < 0)
|
||||
die("git-upload-pack: unable to fork git-rev-list");
|
||||
|
||||
if (!pid_rev_list) {
|
||||
close(lp_pipe[0]);
|
||||
pack_pipe = fdopen(lp_pipe[1], "w");
|
||||
do_rev_list(create_full_pack);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user