commit 7ebc057006aaed02492a35a9215698a37b755911 from: Stefan Sperling date: Wed Mar 18 16:13:47 2020 UTC do not forget to create references under remotes/origin during 'got clone' commit - b46f3e7182c65f46c60e1b9db7c90dc213f52584 commit + 7ebc057006aaed02492a35a9215698a37b755911 blob - 7b17cf38ea32edfa0ba03d521ba4c6ae1edc89c0 blob + 36670ed391de1f001d40ef57ed7f20c230bbbeba --- got/got.c +++ got/got.c @@ -1173,19 +1173,28 @@ cmd_clone(int argc, char *argv[]) const char *refname = pe->path; struct got_object_id *id = pe->data; struct got_reference *ref; - + char *remote_refname; error = got_ref_alloc(&ref, refname, id); if (error) goto done; + error = got_ref_write(ref, repo); + got_ref_close(ref); + if (error) + goto done; - #if 0 - error = got_object_id_str(&id_str, id); + if (strncmp("refs/heads/", refname, 11) != 0) + continue; + + if (asprintf(&remote_refname, + "refs/remotes/%s/%s", GOT_FETCH_DEFAULT_REMOTE_NAME, + refname + 11) == -1) { + error = got_error_from_errno("asprintf"); + goto done; + } + error = got_ref_alloc(&ref, remote_refname, id); if (error) goto done; - printf("%s: %s\n", got_ref_get_name(ref), id_str); - free(id_str); - #endif error = got_ref_write(ref, repo); got_ref_close(ref); if (error) @@ -1236,10 +1245,11 @@ cmd_clone(int argc, char *argv[]) "[core]\n" "\trepositoryformatversion = 0\n" "\tbare = true\n" - "[remote \"origin\"]\n" + "[remote \"%s\"]\n" "\turl = %s\n" - "\tfetch = +refs/heads/*:refs/remotes/origin/*\n", - git_url) == -1) { + "\tfetch = +refs/heads/*:refs/remotes/%s/*\n", + GOT_FETCH_DEFAULT_REMOTE_NAME, git_url, + GOT_FETCH_DEFAULT_REMOTE_NAME) == -1) { error = got_error_from_errno("asprintf"); goto done; } blob - c7d34a72ffb35176dd30e436cdd4254a019ffce7 blob + f0f4c2b70f5e2d9ddf539d255377ca4dfe299dea --- include/got_fetch.h +++ include/got_fetch.h @@ -22,6 +22,8 @@ #define GOT_FETCH_PATH_SSH "/usr/bin/ssh" #endif +#define GOT_FETCH_DEFAULT_REMOTE_NAME "origin" + /* * Attempt to parse a URI into the following parts: * A protocol scheme, hostname, port number (as a string), path on server,