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@xxxxxxxxxxxxxxxxxxx> --- 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 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html