Skip to content

Commit 3cf6134

Browse files
jaysoffiangitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f2ef607 commit 3cf6134

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

builtin-remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ static int prune_remote(const char *remote, int dry_run)
11661166

11671167
printf(" * [%s] %s\n", dry_run ? "would prune" : "pruned",
11681168
abbrev_ref(refname, "refs/remotes/"));
1169-
warn_dangling_symref(dangling_msg, refname);
1169+
warn_dangling_symref(stdout, dangling_msg, refname);
11701170
}
11711171

11721172
free_remote_ref_states(&states);

refs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ static struct ref_list *get_ref_dir(const char *base, struct ref_list *list)
286286
}
287287

288288
struct warn_if_dangling_data {
289+
FILE *fp;
289290
const char *refname;
290291
const char *msg_fmt;
291292
};
@@ -304,13 +305,13 @@ static int warn_if_dangling_symref(const char *refname, const unsigned char *sha
304305
if (!resolves_to || strcmp(resolves_to, d->refname))
305306
return 0;
306307

307-
printf(d->msg_fmt, refname);
308+
fprintf(d->fp, d->msg_fmt, refname);
308309
return 0;
309310
}
310311

311-
void warn_dangling_symref(const char *msg_fmt, const char *refname)
312+
void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)
312313
{
313-
struct warn_if_dangling_data data = { refname, msg_fmt };
314+
struct warn_if_dangling_data data = { fp, refname, msg_fmt };
314315
for_each_rawref(warn_if_dangling_symref, &data);
315316
}
316317

refs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern int for_each_replace_ref(each_ref_fn, void *);
2929
/* can be used to learn about broken ref and symref */
3030
extern int for_each_rawref(each_ref_fn, void *);
3131

32-
extern void warn_dangling_symref(const char *msg_fmt, const char *refname);
32+
extern void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname);
3333

3434
/*
3535
* Extra refs will be listed by for_each_ref() before any actual refs

0 commit comments

Comments
 (0)