@matheusbsbs / matheus-bagliano / commits / d633c882db
Fork 0

http-push.c: remove duplicated code

An earlier commit aa1dbc9 (Update http-push functionality, 2006-03-07) borrowed some code from rev-list.c. This copy and paste made sense back then, because mark_edges_uninteresting(), and its helper mark_edge_parents_uninteresting(), accessed a file scope static variable "revs" in rev-list.c, and http-push.c did not have nor care about such a variable. But these days they are already properly libified and live in list-objects.c and they take "revs" as as an argument. Make use of them and lose 20 or so lines. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jun 7, 2008 at 11:39 UTC d633c882db7cc79bf2d33df99cb0d1c2ef28c15d
1 file changed +3 -26
http-push.c
+3 -26
@@ -9,6 +9,7 @@
9 #include "revision.h"
10 #include "exec_cmd.h"
11 #include "remote.h"
12 +#include "list-objects.h"
13
14 #include <expat.h>
15
@@ -1878,31 +1879,6 @@ static int ref_newer(const unsigned char *new_sha1,
1879 return found;
1880 }
1881
1881 -static void mark_edge_parents_uninteresting(struct commit *commit)
1882 -{
1883 - struct commit_list *parents;
1884 -
1885 - for (parents = commit->parents; parents; parents = parents->next) {
1886 - struct commit *parent = parents->item;
1887 - if (!(parent->object.flags & UNINTERESTING))
1888 - continue;
1889 - mark_tree_uninteresting(parent->tree);
1890 - }
1891 -}
1892 -
1893 -static void mark_edges_uninteresting(struct commit_list *list)
1894 -{
1895 - for ( ; list; list = list->next) {
1896 - struct commit *commit = list->item;
1897 -
1898 - if (commit->object.flags & UNINTERESTING) {
1899 - mark_tree_uninteresting(commit->tree);
1900 - continue;
1901 - }
1902 - mark_edge_parents_uninteresting(commit);
1903 - }
1904 -}
1905 -
1882 static void add_remote_info_ref(struct remote_ls_ctx *ls)
1883 {
1884 struct strbuf *buf = (struct strbuf *)ls->userData;
@@ -2408,6 +2384,7 @@ int main(int argc, char **argv)
2384 }
2385 init_revisions(&revs, setup_git_directory());
2386 setup_revisions(commit_argc, commit_argv, &revs, NULL);
2387 + revs.edge_hint = 0; /* just in case */
2388 free(new_sha1_hex);
2389 if (old_sha1_hex) {
2390 free(old_sha1_hex);
@@ -2418,7 +2395,7 @@ int main(int argc, char **argv)
2395 pushing = 0;
2396 if (prepare_revision_walk(&revs))
2397 die("revision walk setup failed");
2421 - mark_edges_uninteresting(revs.commits);
2398 + mark_edges_uninteresting(revs.commits, &revs, NULL);
2399 objects_to_send = get_delta(&revs, ref_lock);
2400 finish_all_active_slots();
2401