git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC][PATCH 06/10] Sparse: fix "'add_head' not declared" warning

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Jun 8, 2007, 22:16 UTC
Message-ID
<4669D53F.5020206@ramsay1.demon.co.uk>

This function was defined in builtin-diff.c and also used in builtin-log.c. Since it has demonstrated its utility, move the function definition to revision.c, which is a more logical place for it, and add a declaration to revision.h.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
 builtin-diff.c |   12 ------------
 builtin-log.c  |    3 ---
 revision.c     |   12 ++++++++++++
 revision.h     |    1 +
 4 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/builtin-diff.c b/builtin-diff.c
index 7f367b6..e00a212 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -176,18 +176,6 @@ static int builtin_diff_combined(struct rev_info *revs,
 	return 0;
 }
 
-void add_head(struct rev_info *revs)
-{
-	unsigned char sha1[20];
-	struct object *obj;
-	if (get_sha1("HEAD", sha1))
-		return;
-	obj = parse_object(sha1);
-	if (!obj)
-		return;
-	add_pending_object(revs, obj, "HEAD");
-}
-
 int cmd_diff(int argc, const char **argv, const char *prefix)
 {
 	int i;
diff --git a/builtin-log.c b/builtin-log.c
index 3744712..d40a0fc 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -17,9 +17,6 @@
 
 static int default_show_root = 1;
 
-/* this is in builtin-diff.c */
-void add_head(struct rev_info *revs);
-
 static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
 {
 	int plen = strlen(prefix);
diff --git a/revision.c b/revision.c
index 0125d41..1bfe80c 100644
--- a/revision.c
+++ b/revision.c
@@ -129,6 +129,18 @@ void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, con
 				(struct commit *)obj, name);
 }
 
+void add_head(struct rev_info *revs)
+{
+	unsigned char sha1[20];
+	struct object *obj;
+	if (get_sha1("HEAD", sha1))
+		return;
+	obj = parse_object(sha1);
+	if (!obj)
+		return;
+	add_pending_object(revs, obj, "HEAD");
+}
+
 static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags)
 {
 	struct object *object;
diff --git a/revision.h b/revision.h
index 2845167..2fa6286 100644
--- a/revision.h
+++ b/revision.h
@@ -132,5 +132,6 @@ extern void add_object(struct object *obj,
 
 extern void add_pending_object(struct rev_info *revs, struct object *obj, const char *name);
 extern void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, const char *name, unsigned mode);
+extern void add_head(struct rev_info *revs);
 
 #endif
-- 
1.5.2
Message 1 of 1 in “Sparse: fix "'add_head' not declared" warning”
  1. Ramsay JonesJun 8, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.