{"thread":{"id":"13853","subject":"[PATCH] http-push.c: remove duplicated code","startedAt":"2008-06-07T18:39:20Z","lastAt":"2008-06-07T18:39:20Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"79064","messageId":"7vhcc5nl7r.fsf@gitster.siamese.dyndns.org","threadId":"13853","inReplyTo":null,"subject":"[PATCH] http-push.c: remove duplicated code","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-07T18:39:20Z","receivedAt":"2008-06-07T18:39:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"An earlier commit aa1dbc9 (Update http-push functionality, 2006-03-07)\nborrowed some code from rev-list.c.\n\nThis copy and paste made sense back then, because mark_edges_uninteresting(),\nand its helper mark_edge_parents_uninteresting(), accessed a file scope\nstatic variable  \"revs\" in rev-list.c, and http-push.c did not have nor care\nabout such a variable.\n\nBut these days they are already properly libified and live in list-objects.c\nand they take \"revs\" as as an argument.  Make use of them and lose 20 or\nso lines.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * Only compile tested.  I do not use http-push myself nor have a readily\n   usable test environment for it, but the patch looks obvious enough.\n\n   I cc'ed Nick, the original author, even though we haven't seen him here\n   for quite some time...\n\n http-push.c |   29 +++--------------------------\n 1 files changed, 3 insertions(+), 26 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex c93e781..665712a 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -9,6 +9,7 @@\n #include \"revision.h\"\n #include \"exec_cmd.h\"\n #include \"remote.h\"\n+#include \"list-objects.h\"\n \n #include <expat.h>\n \n@@ -1878,31 +1879,6 @@ static int ref_newer(const unsigned char *new_sha1,\n \treturn found;\n }\n \n-static void mark_edge_parents_uninteresting(struct commit *commit)\n-{\n-\tstruct commit_list *parents;\n-\n-\tfor (parents = commit->parents; parents; parents = parents->next) {\n-\t\tstruct commit *parent = parents->item;\n-\t\tif (!(parent->object.flags & UNINTERESTING))\n-\t\t\tcontinue;\n-\t\tmark_tree_uninteresting(parent->tree);\n-\t}\n-}\n-\n-static void mark_edges_uninteresting(struct commit_list *list)\n-{\n-\tfor ( ; list; list = list->next) {\n-\t\tstruct commit *commit = list->item;\n-\n-\t\tif (commit->object.flags & UNINTERESTING) {\n-\t\t\tmark_tree_uninteresting(commit->tree);\n-\t\t\tcontinue;\n-\t\t}\n-\t\tmark_edge_parents_uninteresting(commit);\n-\t}\n-}\n-\n static void add_remote_info_ref(struct remote_ls_ctx *ls)\n {\n \tstruct strbuf *buf = (struct strbuf *)ls->userData;\n@@ -2408,6 +2384,7 @@ int main(int argc, char **argv)\n \t\t}\n \t\tinit_revisions(&revs, setup_git_directory());\n \t\tsetup_revisions(commit_argc, commit_argv, &revs, NULL);\n+\t\trevs.edge_hint = 0; /* just in case */\n \t\tfree(new_sha1_hex);\n \t\tif (old_sha1_hex) {\n \t\t\tfree(old_sha1_hex);\n@@ -2418,7 +2395,7 @@ int main(int argc, char **argv)\n \t\tpushing = 0;\n \t\tif (prepare_revision_walk(&revs))\n \t\t\tdie(\"revision walk setup failed\");\n-\t\tmark_edges_uninteresting(revs.commits);\n+\t\tmark_edges_uninteresting(revs.commits, &revs, NULL);\n \t\tobjects_to_send = get_delta(&revs, ref_lock);\n \t\tfinish_all_active_slots();\n \n"}]}