Sparse: fix "'add_head' not declared" warning
RFC PATCH 6/10 Sparse: fix "'add_head' not declared" warning
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 <[email protected]>
--- builtin-diff.c | 12 ------------ builtin-log.c | 3 --- revision.c | 12 ++++++++++++ revision.h | 1 + 4 files changed, 13 insertions(+), 15 deletions(-)
builtin-diff.c +0 -12
@@ -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;
builtin-log.c +0 -3
@@ -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);
revision.c +12 -0
@@ -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;
revision.h +1 -0
@@ -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
Signature · 1 line
1.5.2