Web lists-archives.com

[PATCH 143/194] object: add repository argument to parse_commit_gently




Add a repository argument to allow callers of parse_commit_gently to
be more specific about which repository to handle. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.

The included coccinelle semantic patch will adapt any new callers in
the diff produced by `make coccicheck`.

Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
---
 commit.c                              | 2 +-
 commit.h                              | 5 +++--
 contrib/coccinelle/object_store.cocci | 9 +++++++++
 revision.c                            | 4 ++--
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/commit.c b/commit.c
index 3a990b7078..93a4f70fa4 100644
--- a/commit.c
+++ b/commit.c
@@ -384,7 +384,7 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,
 	return 0;
 }
 
-int parse_commit_gently(struct commit *item, int quiet_on_missing)
+int parse_commit_gently_the_repository(struct commit *item, int quiet_on_missing)
 {
 	enum object_type type;
 	void *buffer;
diff --git a/commit.h b/commit.h
index 870ad525fd..bb2b1e1e28 100644
--- a/commit.h
+++ b/commit.h
@@ -66,10 +66,11 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref
 
 #define parse_commit_buffer(r, i, b, s) parse_commit_buffer_##r(i, b, s)
 int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size);
-int parse_commit_gently(struct commit *item, int quiet_on_missing);
+#define parse_commit_gently(r, i, q) parse_commit_gently_##r(i, q)
+int parse_commit_gently_the_repository(struct commit *item, int quiet_on_missing);
 static inline int parse_commit(struct commit *item)
 {
-	return parse_commit_gently(item, 0);
+	return parse_commit_gently(the_repository, item, 0);
 }
 void parse_commit_or_die(struct commit *item);
 
diff --git a/contrib/coccinelle/object_store.cocci b/contrib/coccinelle/object_store.cocci
index 3d29868dbf..93b1d03971 100644
--- a/contrib/coccinelle/object_store.cocci
+++ b/contrib/coccinelle/object_store.cocci
@@ -44,3 +44,12 @@ expression H;
 open_istream(
 + the_repository,
  E, F, G, H)
+
+@@
+expression E;
+expression F;
+@@
+ parse_commit_gently(
++ the_repository,
+  E, F)
+
diff --git a/revision.c b/revision.c
index 5c5375ac54..7501ef3160 100644
--- a/revision.c
+++ b/revision.c
@@ -775,7 +775,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
 			parent = parent->next;
 			if (p)
 				p->object.flags |= UNINTERESTING;
-			if (parse_commit_gently(p, 1) < 0)
+			if (parse_commit_gently(the_repository, p, 1) < 0)
 				continue;
 			if (p->parents)
 				mark_parents_uninteresting(p);
@@ -802,7 +802,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
 	for (parent = commit->parents; parent; parent = parent->next) {
 		struct commit *p = parent->item;
 
-		if (parse_commit_gently(p, revs->ignore_missing_links) < 0)
+		if (parse_commit_gently(the_repository, p, revs->ignore_missing_links) < 0)
 			return -1;
 		if (revs->show_source && !p->util)
 			p->util = commit->util;
-- 
2.15.1.433.g936d1b9894.dirty