update-index: add test for chmod flags

Currently there is no test checking the expected behaviour when multiple chmod flags with different arguments are passed. As argument handling is not in line with other git commands it's easy to miss and accidentally change the current behaviour. While there, fix the argument type of chmod_path, which takes an int, but had a char passed in. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Gummerer committed Sep 14, 2016 at 22:07 UTC 22433ce4617b6ff30c9e9bf03b85d4bb244c3dec
2 files changed +14 -1
builtin/update-index.c
+1 -1
@@ -419,7 +419,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
419 return 0;
420 }
421
422 -static void chmod_path(int flip, const char *path)
422 +static void chmod_path(char flip, const char *path)
423 {
424 int pos;
425 struct cache_entry *ce;
t/t2107-update-index-basic.sh
+13
@@ -80,4 +80,17 @@ test_expect_success '.lock files cleaned up' '
80 )
81 '
82
83 +test_expect_success '--chmod=+x and chmod=-x in the same argument list' '
84 + >A &&
85 + >B &&
86 + git add A B &&
87 + git update-index --chmod=+x A --chmod=-x B &&
88 + cat >expect <<-\EOF &&
89 + 100755 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 A
90 + 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 B
91 + EOF
92 + git ls-files --stage A B >actual &&
93 + test_cmp expect actual
94 +'
95 +
96 test_done