Skip to content

Commit 0295ce7

Browse files
peffgitster
authored andcommitted
archive: fix check for missing url
Running "git archive --remote" checks that we have at least one url for the remote. It does so by looking at remote.url[0], but that won't work; if we have no url at all, then remote.url will be NULL, and we'll segfault. Check url_nr instead, which is a more direct way of asking what we want. You can trigger the segfault like this: git -c remote.foo.vcs=bar archive --remote=foo but I didn't bother adding a test. This is the tip of the iceberg for no-url remotes, and a later patch will improve that situation. I just wanted to clean up this bug so it didn't make further refactoring of this code more confusing. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d63586c commit 0295ce7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static int run_remote_archiver(int argc, const char **argv,
3131
struct packet_reader reader;
3232

3333
_remote = remote_get(remote);
34-
if (!_remote->url[0])
34+
if (!_remote->url_nr)
3535
die(_("git archive: Remote with no URL"));
3636
transport = transport_get(_remote, _remote->url[0]);
3737
transport_connect(transport, "git-upload-archive", exec, fd);

0 commit comments

Comments
 (0)