]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'nd/ls-tree-pathspec'
authorJunio C Hamano <gitster@pobox.com>
Mon, 22 Dec 2014 20:27:12 +0000 (12:27 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Dec 2014 20:27:12 +0000 (12:27 -0800)
"git ls-tree" does not support path selection based on negative
pathspecs, but did not error out when negative pathspecs are given.

* nd/ls-tree-pathspec:
  t3102: style modernization
  t3102: document that ls-tree does not yet support negated pathspec
  ls-tree: disable negative pathspec because it's not supported
  ls-tree: remove path filtering logic in show_tree
  tree.c: update read_tree_recursive callback to pass strbuf as base

1  2 
builtin/checkout.c

diff --combined builtin/checkout.c
index 5a787580368bd3e6410128ff300853a10e4a50ee,8adf48de74517f6c4c41db6894d9707e93cc29a8..52d6cbb0a84e2693fc53c88ca1fb4cd899b26a91
@@@ -62,41 -62,23 +62,41 @@@ static int post_checkout_hook(struct co
  
  }
  
- static int update_some(const unsigned char *sha1, const char *base, int baselen,
+ static int update_some(const unsigned char *sha1, struct strbuf *base,
                const char *pathname, unsigned mode, int stage, void *context)
  {
        int len;
        struct cache_entry *ce;
 +      int pos;
  
        if (S_ISDIR(mode))
                return READ_TREE_RECURSIVE;
  
-       len = baselen + strlen(pathname);
+       len = base->len + strlen(pathname);
        ce = xcalloc(1, cache_entry_size(len));
        hashcpy(ce->sha1, sha1);
-       memcpy(ce->name, base, baselen);
-       memcpy(ce->name + baselen, pathname, len - baselen);
+       memcpy(ce->name, base->buf, base->len);
+       memcpy(ce->name + base->len, pathname, len - base->len);
        ce->ce_flags = create_ce_flags(0) | CE_UPDATE;
        ce->ce_namelen = len;
        ce->ce_mode = create_ce_mode(mode);
 +
 +      /*
 +       * If the entry is the same as the current index, we can leave the old
 +       * entry in place. Whether it is UPTODATE or not, checkout_entry will
 +       * do the right thing.
 +       */
 +      pos = cache_name_pos(ce->name, ce->ce_namelen);
 +      if (pos >= 0) {
 +              struct cache_entry *old = active_cache[pos];
 +              if (ce->ce_mode == old->ce_mode &&
 +                  !hashcmp(ce->sha1, old->sha1)) {
 +                      old->ce_flags |= CE_UPDATE;
 +                      free(ce);
 +                      return 0;
 +              }
 +      }
 +
        add_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
        return 0;
  }