From: Junio C Hamano Date: Mon, 22 Dec 2014 20:27:12 +0000 (-0800) Subject: Merge branch 'nd/ls-tree-pathspec' X-Git-Tag: v2.3.0-rc0~61 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/570077231f12e995bb9e8ebe3d6a295047bb993e?hp=-c Merge branch 'nd/ls-tree-pathspec' "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 --- 570077231f12e995bb9e8ebe3d6a295047bb993e diff --combined builtin/checkout.c index 5a78758036,8adf48de74..52d6cbb0a8 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@@ -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; }