diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-06-21 16:39:23 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-06-21 16:39:23 +0400 |
commit | 443f26cbcac66368eb0ec8a8a250bf5815ad0a10 (patch) | |
tree | 0363e0e85d5009e9e042b4d22410c6d95373d805 | |
parent | 1b9fa0e81134df5c067efc1e3413f05c9e5043f8 (diff) | |
parent | ac472ba65f75fbdbc52328f2bdc8645e5289e683 (diff) |
Merge branch 'cb/assume-unchanged-fix' into maint
* cb/assume-unchanged-fix:
Documentation: git-add does not update files marked "assume unchanged"
do not overwrite files marked "assume unchanged"
-rw-r--r-- | Documentation/git-update-index.txt | 2 | ||||
-rwxr-xr-x | t/t2106-update-index-assume-unchanged.sh | 24 | ||||
-rw-r--r-- | unpack-trees.c | 2 |
3 files changed, 25 insertions, 3 deletions
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt index 68dc1879fe..765d4b312e 100644 --- a/Documentation/git-update-index.txt +++ b/Documentation/git-update-index.txt @@ -93,8 +93,6 @@ OPTIONS This option can be also used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what `.gitignore` does for untracked files). -You should remember that an explicit 'git add' operation will -still cause the file to be refreshed from the working tree. Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, diff --git a/t/t2106-update-index-assume-unchanged.sh b/t/t2106-update-index-assume-unchanged.sh new file mode 100755 index 0000000000..99d858c6b7 --- /dev/null +++ b/t/t2106-update-index-assume-unchanged.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +test_description='git update-index --assume-unchanged test. +' + +. ./test-lib.sh + +test_expect_success 'setup' \ + ': >file && + git add file && + git commit -m initial && + git branch other && + echo upstream >file && + git add file && + git commit -m upstream' + +test_expect_success 'do not switch branches with dirty file' \ + 'git reset --hard && + git checkout other && + echo dirt >file && + git update-index --assume-unchanged file && + test_must_fail git checkout master' + +test_done diff --git a/unpack-trees.c b/unpack-trees.c index 75f54cac97..1a8030ced0 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -862,7 +862,7 @@ static int verify_uptodate_1(struct cache_entry *ce, { struct stat st; - if (o->index_only || (!ce_skip_worktree(ce) && (o->reset || ce_uptodate(ce)))) + if (o->index_only || (!((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) && (o->reset || ce_uptodate(ce)))) return 0; if (!lstat(ce->name, &st)) { |