From: Ronnie Sahlberg <sahlberg@xxxxxxxxxx> These functions do not use any backend specific code so we move them to the common code. Signed-off-by: Ronnie Sahlberg <sahlberg@xxxxxxxxxx> Signed-off-by: David Turner <dturner@xxxxxxxxxxxxxxxx> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- refs-be-files.c | 52 ---------------------------------------------------- refs.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/refs-be-files.c b/refs-be-files.c index b74b6cc..ab72adf 100644 --- a/refs-be-files.c +++ b/refs-be-files.c @@ -1944,58 +1944,6 @@ int peel_ref(const char *refname, unsigned char *sha1) return peel_object(base, sha1); } -struct warn_if_dangling_data { - FILE *fp; - const char *refname; - const struct string_list *refnames; - const char *msg_fmt; -}; - -static int warn_if_dangling_symref(const char *refname, const struct object_id *oid, - int flags, void *cb_data) -{ - struct warn_if_dangling_data *d = cb_data; - const char *resolves_to; - struct object_id junk; - - if (!(flags & REF_ISSYMREF)) - return 0; - - resolves_to = resolve_ref_unsafe(refname, 0, junk.hash, NULL); - if (!resolves_to - || (d->refname - ? strcmp(resolves_to, d->refname) - : !string_list_has_string(d->refnames, resolves_to))) { - return 0; - } - - fprintf(d->fp, d->msg_fmt, refname); - fputc('\n', d->fp); - return 0; -} - -void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname) -{ - struct warn_if_dangling_data data; - - data.fp = fp; - data.refname = refname; - data.refnames = NULL; - data.msg_fmt = msg_fmt; - for_each_rawref(warn_if_dangling_symref, &data); -} - -void warn_dangling_symrefs(FILE *fp, const char *msg_fmt, const struct string_list *refnames) -{ - struct warn_if_dangling_data data; - - data.fp = fp; - data.refname = NULL; - data.refnames = refnames; - data.msg_fmt = msg_fmt; - for_each_rawref(warn_if_dangling_symref, &data); -} - /* * Call fn for each reference in the specified ref_cache, omitting * references not in the containing_dir of base. fn is called for all diff --git a/refs.c b/refs.c index e0bc031..1f77978 100644 --- a/refs.c +++ b/refs.c @@ -545,3 +545,55 @@ char *shorten_unambiguous_ref(const char *refname, int strict) free(short_name); return xstrdup(refname); } + +struct warn_if_dangling_data { + FILE *fp; + const char *refname; + const struct string_list *refnames; + const char *msg_fmt; +}; + +static int warn_if_dangling_symref(const char *refname, const struct object_id *oid, + int flags, void *cb_data) +{ + struct warn_if_dangling_data *d = cb_data; + const char *resolves_to; + struct object_id junk; + + if (!(flags & REF_ISSYMREF)) + return 0; + + resolves_to = resolve_ref_unsafe(refname, 0, junk.hash, NULL); + if (!resolves_to + || (d->refname + ? strcmp(resolves_to, d->refname) + : !string_list_has_string(d->refnames, resolves_to))) { + return 0; + } + + fprintf(d->fp, d->msg_fmt, refname); + fputc('\n', d->fp); + return 0; +} + +void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname) +{ + struct warn_if_dangling_data data; + + data.fp = fp; + data.refname = refname; + data.refnames = NULL; + data.msg_fmt = msg_fmt; + for_each_rawref(warn_if_dangling_symref, &data); +} + +void warn_dangling_symrefs(FILE *fp, const char *msg_fmt, const struct string_list *refnames) +{ + struct warn_if_dangling_data data; + + data.fp = fp; + data.refname = NULL; + data.refnames = refnames; + data.msg_fmt = msg_fmt; + for_each_rawref(warn_if_dangling_symref, &data); +} -- 2.4.2.658.g6d8523e-twtrsrc -- 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