Merge branch 'db/learn-HEAD'
authorJunio C Hamano <gitster@pobox.com>
Fri, 9 May 2008 03:06:23 +0000 (20:06 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 May 2008 03:06:23 +0000 (20:06 -0700)
* db/learn-HEAD:
Make ls-remote http://... list HEAD, like for git://...
Make walker.fetch_ref() take a struct ref.

1  2 
cache.h
remote.c
remote.h
diff --combined cache.h
index d5d5dad1463e2251dc84cf0a85095a7e3e0eaeae,cfc123747c2a9e50a114a80b3c247f6f97899edb..7fb8f3359dddbb8f93aa827947c3e5d9de04f639
+++ 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 870d224a3931bf0468c0b74334c0fb49a06ad731,1504cd01e863d2fb1c54423d3d4a99ac35b616ee..6b480cbb9808d9e2b77f2a88f0324701e02a8a75
+++ 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 6878c52ce0e3fa57693e919a9cdb66748bb6e6e3,ab8230850cabce7e51c05bf391bcb93a774361c3..75d006b6deb2ded726df2c1749aa63dec69e34d2
+++ 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.
   */