git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] list-object: add get_commit_count function
@ 2015-07-02  5:38 Lawrence Siebert
  2015-07-02  5:38 ` [PATCH 2/4] log: add --count option to git log Lawrence Siebert
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Lawrence Siebert @ 2015-07-02  5:38 UTC (permalink / raw)
  To: git; +Cc: gitster, Lawrence Siebert

Moving commit counting from rev-list into list-object which is a step
toward letting git log do counting as well.

Signed-off-by: Lawrence Siebert <lawrencesiebert@gmail.com>
---
 builtin/rev-list.c | 12 ++----------
 list-objects.c     | 14 ++++++++++++++
 list-objects.h     |  1 +
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index ff84a82..7b091db 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -388,16 +388,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 
 	traverse_commit_list(&revs, show_commit, show_object, &info);
 
-	if (revs.count) {
-		if (revs.left_right && revs.cherry_mark)
-			printf("%d\t%d\t%d\n", revs.count_left, revs.count_right, revs.count_same);
-		else if (revs.left_right)
-			printf("%d\t%d\n", revs.count_left, revs.count_right);
-		else if (revs.cherry_mark)
-			printf("%d\t%d\n", revs.count_left + revs.count_right, revs.count_same);
-		else
-			printf("%d\n", revs.count_left + revs.count_right);
-	}
+	if (revs.count) 
+		get_commit_count(&revs);  
 
 	return 0;
 }
diff --git a/list-objects.c b/list-objects.c
index 41736d2..6f76301 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -234,3 +234,17 @@ void traverse_commit_list(struct rev_info *revs,
 	object_array_clear(&revs->pending);
 	strbuf_release(&base);
 }
+
+void get_commit_count(struct rev_info * revs) {
+	if (revs->count) {
+		if (revs->left_right && revs->cherry_mark)
+			printf("%d\t%d\t%d\n", revs->count_left, revs->count_right, revs->count_same);
+		else if (revs->left_right)
+			printf("%d\t%d\n", revs->count_left, revs->count_right);
+		else if (revs->cherry_mark)
+			printf("%d\t%d\n", revs->count_left + revs->count_right, revs->count_same);
+		else
+			printf("%d\n", revs->count_left + revs->count_right);
+	}
+	return;
+}
diff --git a/list-objects.h b/list-objects.h
index 136a1da..d28c1f3 100644
--- a/list-objects.h
+++ b/list-objects.h
@@ -7,5 +7,6 @@ void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, voi
 
 typedef void (*show_edge_fn)(struct commit *);
 void mark_edges_uninteresting(struct rev_info *, show_edge_fn);
+void get_commit_count(struct rev_info * revs);
 
 #endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-07-03 18:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-02  5:38 [PATCH 1/4] list-object: add get_commit_count function Lawrence Siebert
2015-07-02  5:38 ` [PATCH 2/4] log: add --count option to git log Lawrence Siebert
2015-07-02  9:14   ` Remi Galan Alfonso
2015-07-02 23:45     ` Lawrence Siebert
2015-07-02  5:38 ` [PATCH 3/4] log --count: added test Lawrence Siebert
2015-07-02  9:09   ` Remi Galan Alfonso
2015-07-02  5:38 ` [PATCH 4/4] git-log: update man documentation for --count Lawrence Siebert
2015-07-02  9:13 ` [PATCH 1/4] list-object: add get_commit_count function Remi Galan Alfonso
2015-07-03 17:49 ` Junio C Hamano
2015-07-03 18:36   ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).