All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] http-push.c: remove duplicated code
@ 2008-06-07 18:39 Junio C Hamano
  0 siblings, 0 replies; only message in thread
From: Junio C Hamano @ 2008-06-07 18:39 UTC (permalink / raw
  To: git; +Cc: Nick Hengeveld, Mike Hommey, Daniel Barkalow

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>
---

 * Only compile tested.  I do not use http-push myself nor have a readily
   usable test environment for it, but the patch looks obvious enough.

   I cc'ed Nick, the original author, even though we haven't seen him here
   for quite some time...

 http-push.c |   29 +++--------------------------
 1 files changed, 3 insertions(+), 26 deletions(-)

diff --git a/http-push.c b/http-push.c
index c93e781..665712a 100644
--- a/http-push.c
+++ b/http-push.c
@@ -9,6 +9,7 @@
 #include "revision.h"
 #include "exec_cmd.h"
 #include "remote.h"
+#include "list-objects.h"
 
 #include <expat.h>
 
@@ -1878,31 +1879,6 @@ static int ref_newer(const unsigned char *new_sha1,
 	return found;
 }
 
-static void mark_edge_parents_uninteresting(struct commit *commit)
-{
-	struct commit_list *parents;
-
-	for (parents = commit->parents; parents; parents = parents->next) {
-		struct commit *parent = parents->item;
-		if (!(parent->object.flags & UNINTERESTING))
-			continue;
-		mark_tree_uninteresting(parent->tree);
-	}
-}
-
-static void mark_edges_uninteresting(struct commit_list *list)
-{
-	for ( ; list; list = list->next) {
-		struct commit *commit = list->item;
-
-		if (commit->object.flags & UNINTERESTING) {
-			mark_tree_uninteresting(commit->tree);
-			continue;
-		}
-		mark_edge_parents_uninteresting(commit);
-	}
-}
-
 static void add_remote_info_ref(struct remote_ls_ctx *ls)
 {
 	struct strbuf *buf = (struct strbuf *)ls->userData;
@@ -2408,6 +2384,7 @@ int main(int argc, char **argv)
 		}
 		init_revisions(&revs, setup_git_directory());
 		setup_revisions(commit_argc, commit_argv, &revs, NULL);
+		revs.edge_hint = 0; /* just in case */
 		free(new_sha1_hex);
 		if (old_sha1_hex) {
 			free(old_sha1_hex);
@@ -2418,7 +2395,7 @@ int main(int argc, char **argv)
 		pushing = 0;
 		if (prepare_revision_walk(&revs))
 			die("revision walk setup failed");
-		mark_edges_uninteresting(revs.commits);
+		mark_edges_uninteresting(revs.commits, &revs, NULL);
 		objects_to_send = get_delta(&revs, ref_lock);
 		finish_all_active_slots();
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-07 18:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-07 18:39 [PATCH] http-push.c: remove duplicated code Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.