# [PATCH v2] Use warning function instead of fprintf(stderr, "Warning: ...").

3 messages from 2010-01-03 to 2010-01-04. Participants: Thiago Farina, Nanako Shiraishi, Junio C Hamano.
Thread: https://gitlist.dev/t/22086

## Thiago Farina, 2010-01-03 16:20

Subject: [PATCH v2] Use warning function instead of fprintf(stderr, "Warning: ...").
Message-ID: <1262535630-3918-1-git-send-email-tfransosi@gmail.com>
URL: https://gitlist.dev/e/1262535630-3918-1-git-send-email-tfransosi%40gmail.com

```
Signed-off-by: Thiago Farina <tfransosi@gmail.com>
---
Removed the LF from the end of the strings.

 bisect.c     |    4 ++--
 builtin-mv.c |    4 +---
 http.c       |    2 +-
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/bisect.c b/bisect.c
index dc18db8..f1a1f84 100644
--- a/bisect.c
+++ b/bisect.c
@@ -813,11 +813,11 @@ static void handle_skipped_merge_base(const unsigned char *mb)
 	char *bad_hex = sha1_to_hex(current_bad_sha1);
 	char *good_hex = join_sha1_array_hex(&good_revs, ' ');
 
-	fprintf(stderr, "Warning: the merge base between %s and [%s] "
+	warning("the merge base between %s and [%s] "
 		"must be skipped.\n"
 		"So we cannot be sure the first bad commit is "
 		"between %s and %s.\n"
-		"We continue anyway.\n",
+		"We continue anyway.",
 		bad_hex, good_hex, mb_hex, bad_hex);
 	free(good_hex);
 }
diff --git a/builtin-mv.c b/builtin-mv.c
index f633d81..8247186 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -169,9 +169,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				 * check both source and destination
 				 */
 				if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
-					fprintf(stderr, "Warning: %s;"
-							" will overwrite!\n",
-							bad);
+					warning("%s; will overwrite!", bad);
 					bad = NULL;
 				} else
 					bad = "Cannot overwrite";
diff --git a/http.c b/http.c
index ed6414a..455732f 100644
--- a/http.c
+++ b/http.c
@@ -1244,7 +1244,7 @@ int finish_http_object_request(struct http_object_request *freq)
 	process_http_object_request(freq);
 
 	if (freq->http_code == 416) {
-		fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
+		warning("requested range invalid; we may already have all the data.");
 	} else if (freq->curl_result != CURLE_OK) {
 		if (stat(freq->tmpfile, &st) == 0)
 			if (st.st_size == 0)
-- 
1.6.6.75.g37bae

```

## Nanako Shiraishi, 2010-01-04 00:18

Subject: Re: [PATCH v2] Use warning function instead of fprintf(stderr, "Warning: ...").
Message-ID: <20100104091847.6117@nanako3.lavabit.com>
URL: https://gitlist.dev/e/20100104091847.6117%40nanako3.lavabit.com
In-Reply-To: <1262535630-3918-1-git-send-email-tfransosi@gmail.com>

```
Quoting Thiago Farina <tfransosi@gmail.com>

> Signed-off-by: Thiago Farina <tfransosi@gmail.com>
> ---
> Removed the LF from the end of the strings.

Trying this patch makes t6030-bisect-porcelain.sh fail for me. Was this tested at all?

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

```

## Junio C Hamano, 2010-01-04 00:41

Subject: Re: [PATCH v2] Use warning function instead of fprintf(stderr, "Warning: ...").
Message-ID: <7vljgevgzj.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vljgevgzj.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20100104091847.6117@nanako3.lavabit.com>

```
Nanako Shiraishi <nanako3@lavabit.com> writes:

> Quoting Thiago Farina <tfransosi@gmail.com>
>
>> Signed-off-by: Thiago Farina <tfransosi@gmail.com>
>> ---
>> Removed the LF from the end of the strings.
>
> Trying this patch makes t6030-bisect-porcelain.sh fail for me. Was this tested at all?

I noticed it as well; will squash this in.

diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index def397c..c51865f 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -423,7 +423,7 @@ test_expect_success 'skipped merge base when good and bad are siblings' '
 	grep "merge base must be tested" my_bisect_log.txt &&
 	grep $HASH4 my_bisect_log.txt &&
 	git bisect skip > my_bisect_log.txt 2>&1 &&
-	grep "Warning" my_bisect_log.txt &&
+	grep "warning" my_bisect_log.txt &&
 	grep $SIDE_HASH6 my_bisect_log.txt &&
 	git bisect reset
 '

```
