summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorNipunn Koorapati <nipunn@dropbox.com>2020-12-22 03:58:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-12-22 06:49:36 (GMT)
commit18f9c9884582c743d8ba04ef5cbbe647947d2578 (patch)
treef8e7c22b60ad01a84af1deba690c385865291509 /remote.c
parentc0192df6306d4d9ad77f6015a053925b13155834 (diff)
downloadgit-18f9c9884582c743d8ba04ef5cbbe647947d2578.zip
git-18f9c9884582c743d8ba04ef5cbbe647947d2578.tar.gz
git-18f9c9884582c743d8ba04ef5cbbe647947d2578.tar.bz2
negative-refspec: fix segfault on : refspec
The logic added to check for negative pathspec match by c0192df630 (refspec: add support for negative refspecs, 2020-09-30) looks at refspec->src assuming it is never NULL, however when remote.origin.push is set to ":", then refspec->src is NULL, causing a segfault within strcmp. Tell git to handle matching refspec by adding the needle to the set of positively matched refspecs, since matching ":" refspecs match anything as src. Add test for matching refspec pushes fetch-negative-refspec both individually and in combination with a negative refspec. Signed-off-by: Nipunn Koorapati <nipunn@dropbox.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/remote.c b/remote.c
index dad3b79..b8ac913 100644
--- a/remote.c
+++ b/remote.c
@@ -755,9 +755,13 @@ static int query_matches_negative_refspec(struct refspec *rs, struct refspec_ite
if (match_name_with_pattern(key, needle, value, &expn_name))
string_list_append_nodup(&reversed, expn_name);
- } else {
- if (!strcmp(needle, refspec->src))
- string_list_append(&reversed, refspec->src);
+ } else if (refspec->matching) {
+ /* For the special matching refspec, any query should match */
+ string_list_append(&reversed, needle);
+ } else if (!refspec->src) {
+ BUG("refspec->src should not be null here");
+ } else if (!strcmp(needle, refspec->src)) {
+ string_list_append(&reversed, refspec->src);
}
}