Skip to content

Commit 22433ce

Browse files
tgummerergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 840529d commit 22433ce

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

builtin/update-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
419419
return 0;
420420
}
421421

422-
static void chmod_path(int flip, const char *path)
422+
static void chmod_path(char flip, const char *path)
423423
{
424424
int pos;
425425
struct cache_entry *ce;

t/t2107-update-index-basic.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,17 @@ test_expect_success '.lock files cleaned up' '
8080
)
8181
'
8282

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+
8396
test_done

0 commit comments

Comments
 (0)