@matheusbsbs / matheus-bagliano / commits / aecda37c66
Fork 0

do not overwrite files marked "assume unchanged"

A merge will fail gracefully if it needs to update files marked "assume unchanged", but other similar commands will not. In particular, checkout and rebase will silently overwrite changes to such files. This is a regression introduced in commit 1dcafcc0 (verify_uptodate(): add ce_uptodate(ce) test), which avoids lstat's during a merge, if the index entry is up-to-date. If the CE_VALID flag is set, however, we cannot trust CE_UPTODATE. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Clemens Buchacher committed May 1, 2010 at 11:25 UTC aecda37c66ecf215fc67b0b48998a8c69c10d5a5
2 files changed +25 -1
t/t2106-update-index-assume-unchanged.sh new
+24
@@ -0,0 +1,24 @@
1 +#!/bin/sh
2 +
3 +test_description='git update-index --assume-unchanged test.
4 +'
5 +
6 +. ./test-lib.sh
7 +
8 +test_expect_success 'setup' \
9 + ': >file &&
10 + git add file &&
11 + git commit -m initial &&
12 + git branch other &&
13 + echo upstream >file &&
14 + git add file &&
15 + git commit -m upstream'
16 +
17 +test_expect_success 'do not switch branches with dirty file' \
18 + 'git reset --hard &&
19 + git checkout other &&
20 + echo dirt >file &&
21 + git update-index --assume-unchanged file &&
22 + test_must_fail git checkout master'
23 +
24 +test_done
unpack-trees.c
+1 -1
@@ -862,7 +862,7 @@ static int verify_uptodate_1(struct cache_entry *ce,
862 {
863 struct stat st;
864
865 - if (o->index_only || (!ce_skip_worktree(ce) && (o->reset || ce_uptodate(ce))))
865 + if (o->index_only || (!((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) && (o->reset || ce_uptodate(ce))))
866 return 0;
867
868 if (!lstat(ce->name, &st)) {