Commit fd2ff8c97d26ac747a40766242d10c9f3c8a9564

Patrick Steinhardt 2017-05-05T09:21:58

remote: improve error message if no URL is set The current error message when connecting to a remote when no URL is set is missing information on whether it is missing a fetch or push URL. Furthermore, it results in undefined behavior when using a remote without name. Fix both issues.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/remote.c b/src/remote.c
index bd8b3cf..bbca7ae 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -674,7 +674,9 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
 	url = git_remote__urlfordirection(remote, direction);
 	if (url == NULL) {
 		giterr_set(GITERR_INVALID,
-			"Malformed remote '%s' - missing URL", remote->name);
+			"Malformed remote '%s' - missing %s URL",
+			remote->name ? remote->name : "(anonymous)",
+			direction == GIT_DIRECTION_FETCH ? "fetch" : "push");
 		return -1;
 	}