Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Sat, 18 Jul 2009 23:57:47 +0000 (16:57 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 18 Jul 2009 23:57:47 +0000 (16:57 -0700)
* maint:
checkout -f: deal with a D/F conflict entry correctly
sha1_name.c: avoid unnecessary strbuf_release
refs.c: release file descriptor on error return

1  2 
refs.c
unpack-trees.c
diff --combined refs.c
index dffe395a97a12f2489dc5bbec1f822e3b8f08de5,bb0762ee2bcb736e72db1c0bbda0604246f14c15..e15880fbc836c8111799da3a4b6f32afe2604db9
--- 1/refs.c
--- 2/refs.c
+++ b/refs.c
@@@ -682,13 -682,12 +682,13 @@@ int for_each_rawref(each_ref_fn fn, voi
   * - it has ASCII control character, "~", "^", ":" or SP, anywhere, or
   * - it ends with a "/".
   * - it ends with ".lock"
 + * - it contains a "\" (backslash)
   */
  
  static inline int bad_ref_char(int ch)
  {
        if (((unsigned) ch) <= ' ' ||
 -          ch == '~' || ch == '^' || ch == ':')
 +          ch == '~' || ch == '^' || ch == ':' || ch == '\\')
                return 1;
        /* 2.13 Pattern Matching Notation */
        if (ch == '?' || ch == '[') /* Unsupported */
@@@ -751,8 -750,9 +751,8 @@@ int check_ref_format(const char *ref
        }
  }
  
 -const char *prettify_ref(const struct ref *ref)
 +const char *prettify_refname(const char *name)
  {
 -      const char *name = ref->name;
        return name + (
                !prefixcmp(name, "refs/heads/") ? 11 :
                !prefixcmp(name, "refs/tags/") ? 10 :
@@@ -1418,7 -1418,7 +1418,7 @@@ int read_ref_at(const char *ref, unsign
        logfile = git_path("logs/%s", ref);
        logfd = open(logfile, O_RDONLY, 0);
        if (logfd < 0)
 -              die("Unable to read log %s: %s", logfile, strerror(errno));
 +              die_errno("Unable to read log '%s'", logfile);
        fstat(logfd, &st);
        if (!st.st_size)
                die("Log %s is empty.", logfile);
@@@ -1525,8 -1525,10 +1525,10 @@@ int for_each_recent_reflog_ent(const ch
                if (fstat(fileno(logfp), &statbuf) ||
                    statbuf.st_size < ofs ||
                    fseek(logfp, -ofs, SEEK_END) ||
-                   fgets(buf, sizeof(buf), logfp))
+                   fgets(buf, sizeof(buf), logfp)) {
+                       fclose(logfp);
                        return -1;
+               }
        }
  
        while (fgets(buf, sizeof(buf), logfp)) {
diff --combined unpack-trees.c
index 48d862d3b478875c3747bdb39a8cba0068300e97,a0697d24126b8cc894649da9a25e652bbea9dab7..720f7a161651126872b7357173c10d69d1db7636
@@@ -128,7 -128,7 +128,7 @@@ static inline int call_unpack_fn(struc
  
  static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_options *o)
  {
 -      struct cache_entry *src[5] = { ce, };
 +      struct cache_entry *src[5] = { ce, NULL, };
  
        o->pos++;
        if (ce_stage(ce)) {
        return call_unpack_fn(src, o);
  }
  
 -int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conflicts, struct name_entry *names, struct traverse_info *info)
 +static int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conflicts, struct name_entry *names, struct traverse_info *info)
  {
        int i;
        struct tree_desc t[MAX_UNPACK_TREES];
@@@ -326,23 -326,6 +326,23 @@@ static int unpack_callback(int n, unsig
                        if (src[0])
                                conflicts |= 1;
                }
 +
 +              /* special case: "diff-index --cached" looking at a tree */
 +              if (o->diff_index_cached &&
 +                  n == 1 && dirmask == 1 && S_ISDIR(names->mode)) {
 +                      int matches;
 +                      matches = cache_tree_matches_traversal(o->src_index->cache_tree,
 +                                                             names, info);
 +                      /*
 +                       * Everything under the name matches.  Adjust o->pos to
 +                       * skip the entire hierarchy.
 +                       */
 +                      if (matches) {
 +                              o->pos += matches;
 +                              return mask;
 +                      }
 +              }
 +
                if (traverse_trees_recursive(n, dirmask, conflicts,
                                             names, info) < 0)
                        return -1;
@@@ -551,7 -534,7 +551,7 @@@ static int verify_clean_subdirectory(st
        memset(&d, 0, sizeof(d));
        if (o->dir)
                d.exclude_per_dir = o->dir->exclude_per_dir;
 -      i = read_directory(&d, ce->name, pathbuf, namelen+1, NULL);
 +      i = read_directory(&d, pathbuf, namelen+1, NULL);
        if (i)
                return o->gently ? -1 :
                        error(ERRORMSG(o, not_uptodate_dir), ce->name);
@@@ -999,12 -982,12 +999,12 @@@ int oneway_merge(struct cache_entry **s
                return error("Cannot do a oneway merge of %d trees",
                             o->merge_size);
  
-       if (!a)
+       if (!a || a == o->df_conflict_entry)
                return deleted_entry(old, old, o);
  
        if (old && same(old, a)) {
                int update = 0;
 -              if (o->reset) {
 +              if (o->reset && !ce_uptodate(old)) {
                        struct stat st;
                        if (lstat(old->name, &st) ||
                            ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID))