Thread (12 messages) flat view 12 messages, 4 authors, 2016-06-15
STALE3734d

[PATCH 1/4] Reduce url_len variable scope

From: Vasyl' Vavrychuk <hidden>
Date: 2016-06-15 22:50:33
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Vasyl' Vavrychuk <redacted>
---
 builtin/fetch.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 357f3cd..2b0b11e 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -385,6 +385,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 		url_len = i + 1;
 		if (4 < i && !strncmp(".git", url + i - 3, 4))
 			url_len = i - 3;
+		url[url_len] = '\0';
 
 		note_len = 0;
 		if (*what) {
@@ -399,7 +400,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 				    rm->old_sha1),
 			rm->merge ? "" : "not-for-merge",
 			note);
-		for (i = 0; i < url_len; ++i)
+		for (i = 0; url[i]; ++i)
 			if ('\n' == url[i])
 				fputs("\\n", fp);
 			else
@@ -415,8 +416,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 				 REFCOL_WIDTH, *what ? what : "HEAD");
 		if (*note) {
 			if (verbosity >= 0 && !shown_url) {
-				fprintf(stderr, "From %.*s\n",
-						url_len, url);
+				fprintf(stderr, "From %s\n", url);
 				shown_url = 1;
 			}
 			if (verbosity >= 0)
-- 
1.7.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help