summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/remote.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/remote.c b/src/remote.c
index 96f501f77..3cead716b 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 */