Jeff King | 93c44d4 | 2007-05-12 02:42:00 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Junio C Hamano | 25487bd | 2007-11-11 18:44:16 -0800 | [diff] [blame] | 3 | test_description='git add -u |
Jeff King | 93c44d4 | 2007-05-12 02:42:00 -0400 | [diff] [blame] | 4 | |
| 5 | This test creates a working tree state with three files: |
| 6 | |
| 7 | top (previously committed, modified) |
| 8 | dir/sub (previously committed, modified) |
| 9 | dir/other (untracked) |
| 10 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 11 | and issues a git add -u with path limiting on "dir" to add |
Junio C Hamano | 25487bd | 2007-11-11 18:44:16 -0800 | [diff] [blame] | 12 | only the updates to dir/sub. |
| 13 | |
| 14 | Also tested are "git add -u" without limiting, and "git add -u" |
| 15 | without contents changes.' |
Jeff King | 93c44d4 | 2007-05-12 02:42:00 -0400 | [diff] [blame] | 16 | |
| 17 | . ./test-lib.sh |
| 18 | |
Junio C Hamano | a4882c2 | 2007-08-15 14:12:14 -0700 | [diff] [blame] | 19 | test_expect_success setup ' |
| 20 | echo initial >check && |
| 21 | echo initial >top && |
Benoit Sigoure | 43b98ac | 2007-09-14 10:29:04 +0200 | [diff] [blame] | 22 | echo initial >foo && |
Junio C Hamano | a4882c2 | 2007-08-15 14:12:14 -0700 | [diff] [blame] | 23 | mkdir dir1 dir2 && |
| 24 | echo initial >dir1/sub1 && |
| 25 | echo initial >dir1/sub2 && |
| 26 | echo initial >dir2/sub3 && |
Benoit Sigoure | 43b98ac | 2007-09-14 10:29:04 +0200 | [diff] [blame] | 27 | git add check dir1 dir2 top foo && |
Junio C Hamano | a4882c2 | 2007-08-15 14:12:14 -0700 | [diff] [blame] | 28 | test_tick |
| 29 | git-commit -m initial && |
| 30 | |
| 31 | echo changed >check && |
| 32 | echo changed >top && |
| 33 | echo changed >dir2/sub3 && |
| 34 | rm -f dir1/sub1 && |
| 35 | echo other >dir2/other |
Jeff King | 93c44d4 | 2007-05-12 02:42:00 -0400 | [diff] [blame] | 36 | ' |
| 37 | |
Junio C Hamano | a4882c2 | 2007-08-15 14:12:14 -0700 | [diff] [blame] | 38 | test_expect_success update ' |
| 39 | git add -u dir1 dir2 |
| 40 | ' |
Jeff King | 93c44d4 | 2007-05-12 02:42:00 -0400 | [diff] [blame] | 41 | |
Junio C Hamano | a4882c2 | 2007-08-15 14:12:14 -0700 | [diff] [blame] | 42 | test_expect_success 'update noticed a removal' ' |
| 43 | test "$(git-ls-files dir1/sub1)" = "" |
| 44 | ' |
Jeff King | 93c44d4 | 2007-05-12 02:42:00 -0400 | [diff] [blame] | 45 | |
Junio C Hamano | a4882c2 | 2007-08-15 14:12:14 -0700 | [diff] [blame] | 46 | test_expect_success 'update touched correct path' ' |
| 47 | test "$(git-diff-files --name-status dir2/sub3)" = "" |
| 48 | ' |
Jeff King | 93c44d4 | 2007-05-12 02:42:00 -0400 | [diff] [blame] | 49 | |
Junio C Hamano | a4882c2 | 2007-08-15 14:12:14 -0700 | [diff] [blame] | 50 | test_expect_success 'update did not touch other tracked files' ' |
| 51 | test "$(git-diff-files --name-status check)" = "M check" && |
| 52 | test "$(git-diff-files --name-status top)" = "M top" |
| 53 | ' |
| 54 | |
| 55 | test_expect_success 'update did not touch untracked files' ' |
| 56 | test "$(git-ls-files dir2/other)" = "" |
| 57 | ' |
| 58 | |
| 59 | test_expect_success 'cache tree has not been corrupted' ' |
| 60 | |
| 61 | git ls-files -s | |
| 62 | sed -e "s/ 0 / /" >expect && |
| 63 | git ls-tree -r $(git write-tree) | |
| 64 | sed -e "s/ blob / /" >current && |
| 65 | diff -u expect current |
| 66 | |
| 67 | ' |
Jeff King | 93c44d4 | 2007-05-12 02:42:00 -0400 | [diff] [blame] | 68 | |
Salikh Zakirov | 2ed2c22 | 2007-08-16 02:01:43 +0900 | [diff] [blame] | 69 | test_expect_success 'update from a subdirectory' ' |
| 70 | ( |
| 71 | cd dir1 && |
| 72 | echo more >sub2 && |
| 73 | git add -u sub2 |
| 74 | ) |
| 75 | ' |
| 76 | |
| 77 | test_expect_success 'change gets noticed' ' |
| 78 | |
| 79 | test "$(git diff-files --name-status dir1)" = "" |
| 80 | |
| 81 | ' |
Jeff King | 93c44d4 | 2007-05-12 02:42:00 -0400 | [diff] [blame] | 82 | |
Benoit Sigoure | 43b98ac | 2007-09-14 10:29:04 +0200 | [diff] [blame] | 83 | test_expect_success 'replace a file with a symlink' ' |
| 84 | |
| 85 | rm foo && |
| 86 | ln -s top foo && |
| 87 | git add -u -- foo |
| 88 | |
| 89 | ' |
| 90 | |
Junio C Hamano | 25487bd | 2007-11-11 18:44:16 -0800 | [diff] [blame] | 91 | test_expect_success 'add everything changed' ' |
| 92 | |
| 93 | git add -u && |
| 94 | test -z "$(git diff-files)" |
| 95 | |
| 96 | ' |
| 97 | |
| 98 | test_expect_success 'touch and then add -u' ' |
| 99 | |
| 100 | touch check && |
| 101 | git add -u && |
| 102 | test -z "$(git diff-files)" |
| 103 | |
| 104 | ' |
| 105 | |
| 106 | test_expect_success 'touch and then add explicitly' ' |
| 107 | |
| 108 | touch check && |
| 109 | git add check && |
| 110 | test -z "$(git diff-files)" |
| 111 | |
| 112 | ' |
| 113 | |
Jeff King | 93c44d4 | 2007-05-12 02:42:00 -0400 | [diff] [blame] | 114 | test_done |