Commit 8a00de0899dcb71dca147acf7d47d19d27f63ba4

Patrick Steinhardt 2018-07-06T10:47:06

Merge pull request #4699 from nelhage/fetch-null-dst git_refspec_transform: Handle NULL dst

diff --git a/src/refspec.c b/src/refspec.c
index bc1d84a..aa6682b 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -277,7 +277,7 @@ int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *nam
 	}
 
 	if (!spec->pattern)
-		return git_buf_puts(out, spec->dst);
+		return git_buf_puts(out, spec->dst ? spec->dst : "");
 
 	return refspec_transform(out, spec->src, spec->dst, name);
 }
diff --git a/tests/network/refspecs.c b/tests/network/refspecs.c
index fd85ca0..15d3624 100644
--- a/tests/network/refspecs.c
+++ b/tests/network/refspecs.c
@@ -111,6 +111,11 @@ void test_network_refspecs__transform_mid_star(void)
 	assert_valid_transform("refs/*:refs/*", "refs/heads/master", "refs/heads/master");
 }
 
+void test_network_refspecs__no_dst(void)
+{
+	assert_valid_transform("refs/heads/master:", "refs/heads/master", "");
+}
+
 static void assert_invalid_transform(const char *refspec, const char *name)
 {
 	git_refspec spec;