Skip to content

Commit 0a8c60e

Browse files
committed
Merge branch 'kj/refspec-parsing-outside-repository' into next
"git ls-remote '+refs/tags/*:refs/tags/*' https://..." run outside a repository would dereference a NULL while trying to see if the given refspec is a single-object refspec, which has been corrected. * kj/refspec-parsing-outside-repository: refspec: fix typo in comment remote-curl: fall back to default hash outside repo
2 parents ffae180 + 4e5dc60 commit 0a8c60e

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

refspec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet
8585
if (!*item->src)
8686
return 0; /* negative refspecs must not be empty */
8787
else if (llen == the_hash_algo->hexsz && !get_oid_hex(item->src, &unused))
88-
return 0; /* negative refpsecs cannot be exact sha1 */
88+
return 0; /* negative refspecs cannot be exact sha1 */
8989
else if (!check_refname_format(item->src, flags))
9090
; /* valid looking ref is ok */
9191
else

remote-curl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,13 @@ int cmd_main(int argc, const char **argv)
15631563
goto cleanup;
15641564
}
15651565

1566+
/*
1567+
* yuck, see 9e89dcb66a (builtin/ls-remote: fall back to SHA1 outside
1568+
* of a repo, 2024-08-02)
1569+
*/
1570+
if (nongit)
1571+
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
1572+
15661573
options.verbosity = 1;
15671574
options.progress = !!isatty(2);
15681575
options.thin = 1;

t/t5551-http-fetch-smart.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,4 +782,11 @@ test_expect_success 'tag following always works over v0 http' '
782782
test_cmp expect actual
783783
'
784784

785+
test_expect_success 'ls-remote outside repo does not segfault with fetch refspec' '
786+
nongit git \
787+
-c remote.origin.url="$HTTPD_URL/smart/repo.git" \
788+
-c remote.origin.fetch=anything \
789+
ls-remote origin
790+
'
791+
785792
test_done

0 commit comments

Comments
 (0)