MCPcopy Create free account
hub / github.com/git/git / cmd_main

Function cmd_main

remote-curl.c:1554–1670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1552}
1553
1554int cmd_main(int argc, const char **argv)
1555{
1556 struct strbuf buf = STRBUF_INIT;
1557 int nongit;
1558 int ret = 1;
1559
1560 setup_git_directory_gently(the_repository, &nongit);
1561 if (argc < 2) {
1562 error(_("remote-curl: usage: git remote-curl <remote> [<url>]"));
1563 goto cleanup;
1564 }
1565
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
1573 options.verbosity = 1;
1574 options.progress = !!isatty(2);
1575 options.thin = 1;
1576 string_list_init_dup(&options.deepen_not);
1577 string_list_init_dup(&options.push_options);
1578
1579 /*
1580 * Just report "remote-curl" here (folding all the various aliases
1581 * ("git-remote-http", "git-remote-https", and etc.) here since they
1582 * are all just copies of the same actual executable.
1583 */
1584 trace2_cmd_name("remote-curl");
1585
1586 remote = remote_get(argv[1]);
1587
1588 if (argc > 2) {
1589 end_url_with_slash(&url, argv[2]);
1590 } else {
1591 end_url_with_slash(&url, remote->url.v[0]);
1592 }
1593
1594 http_init(remote, url.buf, 0);
1595
1596 do {
1597 const char *arg;
1598
1599 if (strbuf_getline_lf(&buf, stdin) == EOF) {
1600 if (ferror(stdin))
1601 error(_("remote-curl: error reading command stream from git"));
1602 goto cleanup;
1603 }
1604 if (buf.len == 0)
1605 break;
1606 if (starts_with(buf.buf, "fetch ")) {
1607 if (nongit) {
1608 setup_git_directory_gently(the_repository, &nongit);
1609 if (nongit)
1610 die(_("remote-curl: fetch attempted without a local repo"));
1611 }

Callers

nothing calls this directly

Calls 15

errorFunction · 0.85
repo_set_hash_algoFunction · 0.85
string_list_init_dupFunction · 0.85
remote_getFunction · 0.85
end_url_with_slashFunction · 0.85
http_initFunction · 0.85
strbuf_getline_lfFunction · 0.85
starts_withFunction · 0.85
parse_fetchFunction · 0.85
output_refsFunction · 0.85
get_refsFunction · 0.85

Tested by

no test coverage detected