Skip to content

Commit eedce78

Browse files
jonseymourgitster
authored andcommitted
sha1_name.c: use warning in preference to fprintf(stderr
This commit changes sha1_name.c to use warning instead of fprintf(stderr). Trailing newlines from message formats have been removed since warning adds one itself. Signed-off-by: Jon Seymour <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e6eedc3 commit eedce78

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

sha1_name.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1);
342342

343343
static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
344344
{
345-
static const char *warning = "warning: refname '%.*s' is ambiguous.\n";
345+
static const char *warn_msg = "refname '%.*s' is ambiguous.";
346346
char *real_ref = NULL;
347347
int refs_found = 0;
348348
int at, reflog_len;
@@ -390,7 +390,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
390390
return -1;
391391

392392
if (warn_ambiguous_refs && refs_found > 1)
393-
fprintf(stderr, warning, len, str);
393+
warning(warn_msg, len, str);
394394

395395
if (reflog_len) {
396396
int nth, i;
@@ -426,9 +426,8 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
426426
if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
427427
&co_time, &co_tz, &co_cnt)) {
428428
if (at_time)
429-
fprintf(stderr,
430-
"warning: Log for '%.*s' only goes "
431-
"back to %s.\n", len, str,
429+
warning("Log for '%.*s' only goes "
430+
"back to %s.", len, str,
432431
show_date(co_time, co_tz, DATE_RFC2822));
433432
else {
434433
free(real_ref);

0 commit comments

Comments
 (0)