Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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>
  • Loading branch information...
commit 3cf6134ad016712ecb78186d9079b9cff7b25416 1 parent f2ef607
Jay Soffian authored November 10, 2009 gitster committed November 10, 2009
2  builtin-remote.c
@@ -1166,7 +1166,7 @@ static int prune_remote(const char *remote, int dry_run)
1166 1166
 
1167 1167
 		printf(" * [%s] %s\n", dry_run ? "would prune" : "pruned",
1168 1168
 		       abbrev_ref(refname, "refs/remotes/"));
1169  
-		warn_dangling_symref(dangling_msg, refname);
  1169
+		warn_dangling_symref(stdout, dangling_msg, refname);
1170 1170
 	}
1171 1171
 
1172 1172
 	free_remote_ref_states(&states);
7  refs.c
@@ -286,6 +286,7 @@ static struct ref_list *get_ref_dir(const char *base, struct ref_list *list)
286 286
 }
287 287
 
288 288
 struct warn_if_dangling_data {
  289
+	FILE *fp;
289 290
 	const char *refname;
290 291
 	const char *msg_fmt;
291 292
 };
@@ -304,13 +305,13 @@ static int warn_if_dangling_symref(const char *refname, const unsigned char *sha
304 305
 	if (!resolves_to || strcmp(resolves_to, d->refname))
305 306
 		return 0;
306 307
 
307  
-	printf(d->msg_fmt, refname);
  308
+	fprintf(d->fp, d->msg_fmt, refname);
308 309
 	return 0;
309 310
 }
310 311
 
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)
312 313
 {
313  
-	struct warn_if_dangling_data data = { refname, msg_fmt };
  314
+	struct warn_if_dangling_data data = { fp, refname, msg_fmt };
314 315
 	for_each_rawref(warn_if_dangling_symref, &data);
315 316
 }
316 317
 
2  refs.h
@@ -29,7 +29,7 @@ extern int for_each_replace_ref(each_ref_fn, void *);
29 29
 /* can be used to learn about broken ref and symref */
30 30
 extern int for_each_rawref(each_ref_fn, void *);
31 31
 
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);
33 33
 
34 34
 /*
35 35
  * Extra refs will be listed by for_each_ref() before any actual refs

0 notes on commit 3cf6134

Please sign in to comment.
Something went wrong with that request. Please try again.