Commit 43b4b2faadbd46c3ef56516785f64b2b9cd2b5a0

Etienne Samson 2018-06-20T02:27:09

remote: merge if-statements We need a repo/config and a name to be able to do anything to the configuration. As such, those two tests can be merged so their conditions are shared.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/remote.c b/src/remote.c
index 96f501f..3cead71 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -264,11 +264,10 @@ static int create_internal(git_remote **out, git_repository *repo, const char *n
 		if ((error = add_refspec(remote, fetch, true)) < 0)
 			goto on_error;
 
-		/* only write for non-anonymous remotes */
-		if (repo && name && (error = write_add_refspec(repo, name, fetch, true)) < 0)
-			goto on_error;
-
-		if (repo && (error = lookup_remote_prune_config(remote, config_ro, name)) < 0)
+		/* only write for named remotes with a repository */
+		if (repo && name &&
+		    ((error = write_add_refspec(repo, name, fetch, true)) < 0 ||
+		    (error = lookup_remote_prune_config(remote, config_ro, name)) < 0))
 			goto on_error;
 
 		/* Move the data over to where the matching functions can find them */