refresh-index: fix bitmask assignment
5fdeacb (Teach update-index about --ignore-submodules, 2008-05-14) added a new refresh option flag but did not assign a unique bit for it correctly, and broke "update-index --ignore-missing". This fixes it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jul 19, 2008 at 23:25 UTC
3f1b7b607a81cf56254fcc4ed417cc4344cde2a5
2 files changed
+90
-1
cache.h
+1
-1
@@ -396,7 +396,7 @@ extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
396
#define REFRESH_UNMERGED 0x0002 /* allow unmerged */
397
#define REFRESH_QUIET 0x0004 /* be quiet about it */
398
#define REFRESH_IGNORE_MISSING 0x0008 /* ignore non-existent */
399
-#define REFRESH_IGNORE_SUBMODULES 0x0008 /* ignore submodules */
399
+#define REFRESH_IGNORE_SUBMODULES 0x0010 /* ignore submodules */
400
extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen);
401
402
struct lock_file {
t/t2103-update-index-ignore-missing.sh
new
+89
@@ -0,0 +1,89 @@
1
+#!/bin/sh
2
+
3
+test_description='update-index with options'
4
+
5
+. ./test-lib.sh
6
+
7
+test_expect_success basics '
8
+ >one &&
9
+ >two &&
10
+ >three &&
11
+
12
+ # need --add when adding
13
+ test_must_fail git update-index one &&
14
+ test -z "$(git ls-files)" &&
15
+ git update-index --add one &&
16
+ test zone = "z$(git ls-files)" &&
17
+
18
+ # update-index is atomic
19
+ echo 1 >one &&
20
+ test_must_fail git update-index one two &&
21
+ echo "M one" >expect &&
22
+ git diff-files --name-status >actual &&
23
+ test_cmp expect actual &&
24
+
25
+ git update-index --add one two three &&
26
+ for i in one three two; do echo $i; done >expect &&
27
+ git ls-files >actual &&
28
+ test_cmp expect actual &&
29
+
30
+ test_tick &&
31
+ (
32
+ test_create_repo xyzzy &&
33
+ cd xyzzy &&
34
+ >file &&
35
+ git add file
36
+ git commit -m "sub initial"
37
+ ) &&
38
+ git add xyzzy &&
39
+
40
+ test_tick &&
41
+ git commit -m initial &&
42
+ git tag initial
43
+'
44
+
45
+test_expect_success '--ignore-missing --refresh' '
46
+ git reset --hard initial &&
47
+ echo 2 >one &&
48
+ test_must_fail git update-index --refresh &&
49
+ echo 1 >one &&
50
+ git update-index --refresh &&
51
+ rm -f two &&
52
+ test_must_fail git update-index --refresh &&
53
+ git update-index --ignore-missing --refresh
54
+
55
+'
56
+
57
+test_expect_success '--unmerged --refresh' '
58
+ git reset --hard initial &&
59
+ info=$(git ls-files -s one | sed -e "s/ 0 / 1 /") &&
60
+ git rm --cached one &&
61
+ echo "$info" | git update-index --index-info &&
62
+ test_must_fail git update-index --refresh &&
63
+ git update-index --unmerged --refresh &&
64
+ echo 2 >two &&
65
+ test_must_fail git update-index --unmerged --refresh >actual &&
66
+ grep two actual &&
67
+ ! grep one actual &&
68
+ ! grep three actual
69
+'
70
+
71
+test_expect_success '--ignore-submodules --refresh (1)' '
72
+ git reset --hard initial &&
73
+ rm -f two &&
74
+ test_must_fail git update-index --ignore-submodules --refresh
75
+'
76
+
77
+test_expect_success '--ignore-submodules --refresh (2)' '
78
+ git reset --hard initial &&
79
+ test_tick &&
80
+ (
81
+ cd xyzzy &&
82
+ git commit -m "sub second" --allow-empty
83
+ ) &&
84
+ test_must_fail git update-index --refresh &&
85
+ test_must_fail git update-index --ignore-missing --refresh &&
86
+ git update-index --ignore-submodules --refresh
87
+'
88
+
89
+test_done