do not forget to create references under remotes/origin during 'got clone'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
diff --git a/got/got.c b/got/got.c
index 7b17cf3..36670ed 100644
--- a/got/got.c
+++ b/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;
}
diff --git a/include/got_fetch.h b/include/got_fetch.h
index c7d34a7..f0f4c2b 100644
--- a/include/got_fetch.h
+++ b/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,