From: Junio C Hamano Date: Fri, 9 May 2008 03:06:23 +0000 (-0700) Subject: Merge branch 'db/learn-HEAD' X-Git-Tag: v1.5.6-rc0~80 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/31a3c6bb45aa61e45f1663871620eaf742f0abbb?ds=inline;hp=-c Merge branch 'db/learn-HEAD' * db/learn-HEAD: Make ls-remote http://... list HEAD, like for git://... Make walker.fetch_ref() take a struct ref. --- 31a3c6bb45aa61e45f1663871620eaf742f0abbb diff --combined cache.h index d5d5dad146,cfc123747c..7fb8f3359d --- a/cache.h +++ b/cache.h @@@ -311,7 -311,6 +311,7 @@@ extern char *get_index_file(void) extern char *get_graft_file(void); extern int set_git_dir(const char *path); extern const char *get_git_work_tree(void); +extern const char *read_gitfile_gently(const char *path); #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES" @@@ -635,6 -634,7 +635,7 @@@ struct ref struct ref *next; unsigned char old_sha1[20]; unsigned char new_sha1[20]; + char *symref; unsigned int force:1, merge:1, nonfastforward:1, @@@ -727,8 -727,8 +728,8 @@@ extern const char *git_log_output_encod extern void maybe_flush_or_die(FILE *, const char *); extern int copy_fd(int ifd, int ofd); extern int copy_file(const char *dst, const char *src, int mode); -extern int read_in_full(int fd, void *buf, size_t count); -extern int write_in_full(int fd, const void *buf, size_t count); +extern ssize_t read_in_full(int fd, void *buf, size_t count); +extern ssize_t write_in_full(int fd, const void *buf, size_t count); extern void write_or_die(int fd, const void *buf, size_t count); extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg); extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg); diff --combined remote.c index 870d224a39,1504cd01e8..6b480cbb98 --- a/remote.c +++ b/remote.c @@@ -337,49 -337,44 +337,49 @@@ static int handle_config(const char *ke return 0; } remote = make_remote(name, subkey - name); - if (!value) { - /* if we ever have a boolean variable, e.g. "remote.*.disabled" - * [remote "frotz"] - * disabled - * is a valid way to set it to true; we get NULL in value so - * we need to handle it here. - * - * if (!strcmp(subkey, ".disabled")) { - * val = git_config_bool(key, value); - * return 0; - * } else - * - */ - return 0; /* ignore unknown booleans */ - } - if (!strcmp(subkey, ".url")) { - add_url(remote, xstrdup(value)); + if (!strcmp(subkey, ".mirror")) + remote->mirror = git_config_bool(key, value); + else if (!strcmp(subkey, ".skipdefaultupdate")) + remote->skip_default_update = git_config_bool(key, value); + + else if (!strcmp(subkey, ".url")) { + const char *v; + if (git_config_string(&v, key, value)) + return -1; + add_url(remote, v); } else if (!strcmp(subkey, ".push")) { - add_push_refspec(remote, xstrdup(value)); + const char *v; + if (git_config_string(&v, key, value)) + return -1; + add_push_refspec(remote, v); } else if (!strcmp(subkey, ".fetch")) { - add_fetch_refspec(remote, xstrdup(value)); + const char *v; + if (git_config_string(&v, key, value)) + return -1; + add_fetch_refspec(remote, v); } else if (!strcmp(subkey, ".receivepack")) { + const char *v; + if (git_config_string(&v, key, value)) + return -1; if (!remote->receivepack) - remote->receivepack = xstrdup(value); + remote->receivepack = v; else error("more than one receivepack given, using the first"); } else if (!strcmp(subkey, ".uploadpack")) { + const char *v; + if (git_config_string(&v, key, value)) + return -1; if (!remote->uploadpack) - remote->uploadpack = xstrdup(value); + remote->uploadpack = v; else error("more than one uploadpack given, using the first"); } else if (!strcmp(subkey, ".tagopt")) { if (!strcmp(value, "--no-tags")) remote->fetch_tags = -1; } else if (!strcmp(subkey, ".proxy")) { - remote->http_proxy = xstrdup(value); - } else if (!strcmp(subkey, ".skipdefaultupdate")) - remote->skip_default_update = 1; + return git_config_string((const char **)&remote->http_proxy, + key, value); + } return 0; } @@@ -711,13 -706,22 +711,22 @@@ struct ref *copy_ref_list(const struct return ret; } + void free_ref(struct ref *ref) + { + if (!ref) + return; + free(ref->remote_status); + free(ref->symref); + free(ref); + } + void free_refs(struct ref *ref) { struct ref *next; while (ref) { next = ref->next; free(ref->peer_ref); - free(ref); + free_ref(ref); ref = next; } } @@@ -1177,3 -1181,15 +1186,15 @@@ int get_fetch_map(const struct ref *rem return 0; } + + int resolve_remote_symref(struct ref *ref, struct ref *list) + { + if (!ref->symref) + return 0; + for (; list; list = list->next) + if (!strcmp(ref->symref, list->name)) { + hashcpy(ref->old_sha1, list->old_sha1); + return 0; + } + return 1; + } diff --combined remote.h index 6878c52ce0,ab8230850c..75d006b6de --- a/remote.h +++ b/remote.h @@@ -26,7 -26,6 +26,7 @@@ struct remote */ int fetch_tags; int skip_default_update; + int mirror; const char *receivepack; const char *uploadpack; @@@ -63,6 -62,8 +63,8 @@@ int check_ref_type(const struct ref *re */ void free_refs(struct ref *ref); + int resolve_remote_symref(struct ref *ref, struct ref *list); + /* * Removes and frees any duplicate refs in the map. */