@@ -386,6 +386,36 @@ test_expect_success POSIXPERM 'git add --chmod=[+-]x does not change the working
386
386
! test -x foo4
387
387
'
388
388
389
+ test_expect_success ' git add --chmod fails with non regular files (but updates the other paths)' '
390
+ git reset --hard &&
391
+ test_ln_s_add foo foo3 &&
392
+ touch foo4 &&
393
+ test_must_fail git add --chmod=+x foo3 foo4 2>stderr &&
394
+ test_i18ngrep "cannot chmod +x .foo3." stderr &&
395
+ test_mode_in_index 120000 foo3 &&
396
+ test_mode_in_index 100755 foo4
397
+ '
398
+
399
+ test_expect_success ' git add --chmod honors --dry-run' '
400
+ git reset --hard &&
401
+ echo foo >foo4 &&
402
+ git add foo4 &&
403
+ git add --chmod=+x --dry-run foo4 &&
404
+ test_mode_in_index 100644 foo4
405
+ '
406
+
407
+ test_expect_success ' git add --chmod --dry-run reports error for non regular files' '
408
+ git reset --hard &&
409
+ test_ln_s_add foo foo4 &&
410
+ test_must_fail git add --chmod=+x --dry-run foo4 2>stderr &&
411
+ test_i18ngrep "cannot chmod +x .foo4." stderr
412
+ '
413
+
414
+ test_expect_success ' git add --chmod --dry-run reports error for unmatched pathspec' '
415
+ test_must_fail git add --chmod=+x --dry-run nonexistent 2>stderr &&
416
+ test_i18ngrep "pathspec .nonexistent. did not match any files" stderr
417
+ '
418
+
389
419
test_expect_success ' no file status change if no pathspec is given' '
390
420
>foo5 &&
391
421
>foo6 &&
@@ -409,11 +439,17 @@ test_expect_success 'no file status change if no pathspec is given in subdir' '
409
439
'
410
440
411
441
test_expect_success ' all statuses changed in folder if . is given' '
412
- rm -fr empty &&
413
- git add --chmod=+x . &&
414
- test $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 &&
415
- git add --chmod=-x . &&
416
- test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
442
+ git init repo &&
443
+ (
444
+ cd repo &&
445
+ mkdir -p sub/dir &&
446
+ touch x y z sub/a sub/dir/b &&
447
+ git add -A &&
448
+ git add --chmod=+x . &&
449
+ test $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 &&
450
+ git add --chmod=-x . &&
451
+ test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
452
+ )
417
453
'
418
454
419
455
test_expect_success CASE_INSENSITIVE_FS ' path is case-insensitive' '
0 commit comments