teach warn_dangling_symref to take a FILE argument
Different callers of warn_dangling_symref() may want to control whether its output goes to stdout or stderr so let it take a FILE argument. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
f2ef6075c9
commit
3cf6134ad0
@ -1166,7 +1166,7 @@ static int prune_remote(const char *remote, int dry_run)
|
|||||||
|
|
||||||
printf(" * [%s] %s\n", dry_run ? "would prune" : "pruned",
|
printf(" * [%s] %s\n", dry_run ? "would prune" : "pruned",
|
||||||
abbrev_ref(refname, "refs/remotes/"));
|
abbrev_ref(refname, "refs/remotes/"));
|
||||||
warn_dangling_symref(dangling_msg, refname);
|
warn_dangling_symref(stdout, dangling_msg, refname);
|
||||||
}
|
}
|
||||||
|
|
||||||
free_remote_ref_states(&states);
|
free_remote_ref_states(&states);
|
||||||
|
7
refs.c
7
refs.c
@ -286,6 +286,7 @@ static struct ref_list *get_ref_dir(const char *base, struct ref_list *list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct warn_if_dangling_data {
|
struct warn_if_dangling_data {
|
||||||
|
FILE *fp;
|
||||||
const char *refname;
|
const char *refname;
|
||||||
const char *msg_fmt;
|
const char *msg_fmt;
|
||||||
};
|
};
|
||||||
@ -304,13 +305,13 @@ static int warn_if_dangling_symref(const char *refname, const unsigned char *sha
|
|||||||
if (!resolves_to || strcmp(resolves_to, d->refname))
|
if (!resolves_to || strcmp(resolves_to, d->refname))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf(d->msg_fmt, refname);
|
fprintf(d->fp, d->msg_fmt, refname);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void warn_dangling_symref(const char *msg_fmt, const char *refname)
|
void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)
|
||||||
{
|
{
|
||||||
struct warn_if_dangling_data data = { refname, msg_fmt };
|
struct warn_if_dangling_data data = { fp, refname, msg_fmt };
|
||||||
for_each_rawref(warn_if_dangling_symref, &data);
|
for_each_rawref(warn_if_dangling_symref, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
refs.h
2
refs.h
@ -29,7 +29,7 @@ extern int for_each_replace_ref(each_ref_fn, void *);
|
|||||||
/* can be used to learn about broken ref and symref */
|
/* can be used to learn about broken ref and symref */
|
||||||
extern int for_each_rawref(each_ref_fn, void *);
|
extern int for_each_rawref(each_ref_fn, void *);
|
||||||
|
|
||||||
extern void warn_dangling_symref(const char *msg_fmt, const char *refname);
|
extern void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extra refs will be listed by for_each_ref() before any actual refs
|
* Extra refs will be listed by for_each_ref() before any actual refs
|
||||||
|
Loading…
Reference in New Issue
Block a user