Code

Merge branch 'nd/maint-clone-gitdir' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 23 Sep 2011 21:21:39 +0000 (14:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 23 Sep 2011 21:21:39 +0000 (14:21 -0700)
* nd/maint-clone-gitdir:
  clone: allow to clone from .git file
  read_gitfile_gently(): rename misnamed function to read_gitfile()

1  2 
cache.h
refs.c
submodule.c

diff --combined cache.h
index be506187f89c4dcdc125545482e51c15c6edcbb0,1abf71505007a9ca8476e24cf1a097c0d9f8b302..e494bdcda77678c971ab810151e0d5ecfe89c447
+++ b/cache.h
  #endif
  
  #include <zlib.h>
 -#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
 -#define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
 -#endif
 -
 -void git_inflate_init(z_streamp strm);
 -void git_inflate_end(z_streamp strm);
 -int git_inflate(z_streamp strm, int flush);
 +typedef struct git_zstream {
 +      z_stream z;
 +      unsigned long avail_in;
 +      unsigned long avail_out;
 +      unsigned long total_in;
 +      unsigned long total_out;
 +      unsigned char *next_in;
 +      unsigned char *next_out;
 +} git_zstream;
 +
 +void git_inflate_init(git_zstream *);
 +void git_inflate_init_gzip_only(git_zstream *);
 +void git_inflate_end(git_zstream *);
 +int git_inflate(git_zstream *, int flush);
 +
 +void git_deflate_init(git_zstream *, int level);
 +void git_deflate_init_gzip(git_zstream *, int level);
 +void git_deflate_end(git_zstream *);
 +int git_deflate_end_gently(git_zstream *);
 +int git_deflate(git_zstream *, int flush);
 +unsigned long git_deflate_bound(git_zstream *, unsigned long);
  
  #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
  #define DTYPE(de)     ((de)->d_type)
@@@ -434,7 -420,7 +434,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);
+ extern const char *read_gitfile(const char *path);
  extern void set_git_work_tree(const char *tree);
  
  #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
@@@ -1023,7 -1009,7 +1023,7 @@@ extern struct packed_git *find_sha1_pac
  extern void pack_report(void);
  extern int open_pack_index(struct packed_git *);
  extern void close_pack_index(struct packed_git *);
 -extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned int *);
 +extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
  extern void close_pack_windows(struct packed_git *);
  extern void unuse_pack(struct pack_window **);
  extern void free_pack_by_name(const char *);
diff --combined refs.c
index 0fa8dcf3e10bfed4825db1c3d2cf140507cfa617,c98c006e7a0270db2ebeb628cacc6027645eb4b2..4c1fd470dd645cd28132efb6290e25cd5f734215
--- 1/refs.c
--- 2/refs.c
+++ b/refs.c
@@@ -451,7 -451,7 +451,7 @@@ int resolve_gitlink_ref(const char *pat
        memcpy(gitdir + len, "/.git", 6);
        len += 5;
  
-       tmp = read_gitfile_gently(gitdir);
+       tmp = read_gitfile(gitdir);
        if (tmp) {
                free(gitdir);
                len = strlen(tmp);
@@@ -837,7 -837,7 +837,7 @@@ int for_each_rawref(each_ref_fn fn, voi
  
  static inline int bad_ref_char(int ch)
  {
 -      if (((unsigned) ch) <= ' ' ||
 +      if (((unsigned) ch) <= ' ' || ch == 0x7f ||
            ch == '~' || ch == '^' || ch == ':' || ch == '\\')
                return 1;
        /* 2.13 Pattern Matching Notation */
@@@ -1826,12 -1826,6 +1826,12 @@@ int update_ref(const char *action, cons
        return 0;
  }
  
 +int ref_exists(char *refname)
 +{
 +      unsigned char sha1[20];
 +      return !!resolve_ref(refname, sha1, 1, NULL);
 +}
 +
  struct ref *find_ref_by_name(const struct ref *list, const char *name)
  {
        for ( ; list; list = list->next)
diff --combined submodule.c
index b648927509cc4a1a663b981557f1529564121645,b8b0326c5090f545ebaf5e26146588e7009eed01..11de09ae97e09fa1146e0f567b7c360ad6ed4cb8
@@@ -32,7 -32,7 +32,7 @@@ static int add_submodule_odb(const cha
        const char *git_dir;
  
        strbuf_addf(&objects_directory, "%s/.git", path);
-       git_dir = read_gitfile_gently(objects_directory.buf);
+       git_dir = read_gitfile(objects_directory.buf);
        if (git_dir) {
                strbuf_reset(&objects_directory);
                strbuf_addstr(&objects_directory, git_dir);
@@@ -373,10 -373,6 +373,10 @@@ void check_for_new_submodule_commits(un
        const char *argv[] = {NULL, NULL, "--not", "--all", NULL};
        int argc = ARRAY_SIZE(argv) - 1;
  
 +      /* No need to check if there are no submodules configured */
 +      if (!config_name_for_path.nr)
 +              return;
 +
        init_revisions(&rev, NULL);
        argv[1] = xstrdup(sha1_to_hex(new_sha1));
        setup_revisions(argc, argv, &rev, NULL);
                while (parent) {
                        struct diff_options diff_opts;
                        diff_setup(&diff_opts);
 +                      DIFF_OPT_SET(&diff_opts, RECURSIVE);
                        diff_opts.output_format |= DIFF_FORMAT_CALLBACK;
                        diff_opts.format_callback = submodule_collect_changed_cb;
                        if (diff_setup_done(&diff_opts) < 0)
@@@ -483,7 -478,7 +483,7 @@@ int fetch_populated_submodules(int num_
                strbuf_addf(&submodule_path, "%s/%s", work_tree, ce->name);
                strbuf_addf(&submodule_git_dir, "%s/.git", submodule_path.buf);
                strbuf_addf(&submodule_prefix, "%s%s/", prefix, ce->name);
-               git_dir = read_gitfile_gently(submodule_git_dir.buf);
+               git_dir = read_gitfile(submodule_git_dir.buf);
                if (!git_dir)
                        git_dir = submodule_git_dir.buf;
                if (is_directory(git_dir)) {
@@@ -521,7 -516,7 +521,7 @@@ unsigned is_submodule_modified(const ch
        const char *git_dir;
  
        strbuf_addf(&buf, "%s/.git", path);
-       git_dir = read_gitfile_gently(buf.buf);
+       git_dir = read_gitfile(buf.buf);
        if (!git_dir)
                git_dir = buf.buf;
        if (!is_directory(git_dir)) {