aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-17 21:37:09 -0700
committerJunio C Hamano <gitster@pobox.com>2011-10-17 21:37:09 -0700
commit66d2c22f416cda652f08e8db5820abf3e87592e5 (patch)
treead4e5e2e38eec22aa6cb769e5d2d1dd896b19629 /builtin
parenta9af6c451d68267a605b7b7385cdffa939b167b2 (diff)
parent0a1283bc3955a97557019d077b96669c5c93c551 (diff)
downloadgit-66d2c22f416cda652f08e8db5820abf3e87592e5.tar.gz
git-66d2c22f416cda652f08e8db5820abf3e87592e5.tar.xz
Merge branch 'jc/checkout-from-tree-keep-local-changes'
* jc/checkout-from-tree-keep-local-changes: checkout $tree $path: do not clobber local changes in $path not in $tree
Diffstat (limited to 'builtin')
-rw-r--r--builtin/checkout.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 49a547a0d..2a8077242 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -72,7 +72,7 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
hashcpy(ce->sha1, sha1);
memcpy(ce->name, base, baselen);
memcpy(ce->name + baselen, pathname, len - baselen);
- ce->ce_flags = create_ce_flags(len, 0);
+ ce->ce_flags = create_ce_flags(len, 0) | CE_UPDATE;
ce->ce_mode = create_ce_mode(mode);
add_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
return 0;
@@ -229,6 +229,8 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
+ if (source_tree && !(ce->ce_flags & CE_UPDATE))
+ continue;
match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, ps_matched);
}
@@ -267,6 +269,8 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
state.refresh_cache = 1;
for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
+ if (source_tree && !(ce->ce_flags & CE_UPDATE))
+ continue;
if (match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, NULL)) {
if (!ce_stage(ce)) {
errs |= checkout_entry(ce, &state, NULL);