Junio C Hamano | 29796c6 | 2009-08-04 16:25:40 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='basic work tree status reporting' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success setup ' |
| 8 | test_commit A && |
| 9 | test_commit B oneside added && |
| 10 | git checkout A^0 && |
| 11 | test_commit C oneside created |
| 12 | ' |
| 13 | |
| 14 | test_expect_success 'A/A conflict' ' |
| 15 | git checkout B^0 && |
| 16 | test_must_fail git merge C |
| 17 | ' |
| 18 | |
| 19 | test_expect_success 'Report path with conflict' ' |
| 20 | git diff --cached --name-status >actual && |
| 21 | echo "U oneside" >expect && |
| 22 | test_cmp expect actual |
| 23 | ' |
| 24 | |
| 25 | test_expect_success 'Report new path with conflict' ' |
| 26 | git diff --cached --name-status HEAD^ >actual && |
| 27 | echo "U oneside" >expect && |
| 28 | test_cmp expect actual |
| 29 | ' |
| 30 | |
Junio C Hamano | 4d4d572 | 2009-08-05 00:04:51 -0700 | [diff] [blame] | 31 | cat >expect <<EOF |
| 32 | # On branch side |
| 33 | # Unmerged paths: |
Junio C Hamano | dd20f8a | 2009-12-12 00:18:12 -0800 | [diff] [blame] | 34 | # (use "git add/rm <file>..." as appropriate to mark resolution) |
Junio C Hamano | 4d4d572 | 2009-08-05 00:04:51 -0700 | [diff] [blame] | 35 | # |
| 36 | # deleted by us: foo |
| 37 | # |
| 38 | no changes added to commit (use "git add" and/or "git commit -a") |
| 39 | EOF |
| 40 | |
Junio C Hamano | b3e1900 | 2011-04-12 16:33:39 -0700 | [diff] [blame] | 41 | test_expect_success 'M/D conflict does not segfault' ' |
Junio C Hamano | 4d4d572 | 2009-08-05 00:04:51 -0700 | [diff] [blame] | 42 | mkdir mdconflict && |
| 43 | ( |
| 44 | cd mdconflict && |
| 45 | git init && |
| 46 | test_commit initial foo "" && |
| 47 | test_commit modify foo foo && |
| 48 | git checkout -b side HEAD^ && |
| 49 | git rm foo && |
| 50 | git commit -m delete && |
| 51 | test_must_fail git merge master && |
Junio C Hamano | 9e4b7ab | 2009-08-15 02:27:39 -0700 | [diff] [blame] | 52 | test_must_fail git commit --dry-run >../actual && |
Junio C Hamano | b3e1900 | 2011-04-12 16:33:39 -0700 | [diff] [blame] | 53 | test_i18ncmp ../expect ../actual && |
Junio C Hamano | 9e4b7ab | 2009-08-15 02:27:39 -0700 | [diff] [blame] | 54 | git status >../actual && |
Junio C Hamano | b3e1900 | 2011-04-12 16:33:39 -0700 | [diff] [blame] | 55 | test_i18ncmp ../expect ../actual |
Junio C Hamano | 9e4b7ab | 2009-08-15 02:27:39 -0700 | [diff] [blame] | 56 | ) |
Junio C Hamano | 4d4d572 | 2009-08-05 00:04:51 -0700 | [diff] [blame] | 57 | ' |
| 58 | |
Martin von Zweigbergk | d7c9bf2 | 2011-03-23 22:41:01 -0400 | [diff] [blame] | 59 | test_expect_success 'rename & unmerged setup' ' |
| 60 | git rm -f -r . && |
| 61 | cat "$TEST_DIRECTORY/README" >ONE && |
| 62 | git add ONE && |
| 63 | test_tick && |
| 64 | git commit -m "One commit with ONE" && |
| 65 | |
| 66 | echo Modified >TWO && |
| 67 | cat ONE >>TWO && |
| 68 | cat ONE >>THREE && |
| 69 | git add TWO THREE && |
| 70 | sha1=$(git rev-parse :ONE) && |
| 71 | git rm --cached ONE && |
| 72 | ( |
| 73 | echo "100644 $sha1 1 ONE" && |
| 74 | echo "100644 $sha1 2 ONE" && |
| 75 | echo "100644 $sha1 3 ONE" |
| 76 | ) | git update-index --index-info && |
| 77 | echo Further >>THREE |
| 78 | ' |
| 79 | |
| 80 | test_expect_success 'rename & unmerged status' ' |
| 81 | git status -suno >actual && |
| 82 | cat >expect <<-EOF && |
| 83 | UU ONE |
| 84 | AM THREE |
| 85 | A TWO |
| 86 | EOF |
| 87 | test_cmp expect actual |
| 88 | ' |
| 89 | |
| 90 | test_expect_success 'git diff-index --cached shows 2 added + 1 unmerged' ' |
| 91 | cat >expected <<-EOF && |
| 92 | U ONE |
| 93 | A THREE |
| 94 | A TWO |
| 95 | EOF |
| 96 | git diff-index --cached --name-status HEAD >actual && |
| 97 | test_cmp expected actual |
| 98 | ' |
| 99 | |
| 100 | test_expect_success 'git diff-index --cached -M shows 2 added + 1 unmerged' ' |
| 101 | cat >expected <<-EOF && |
| 102 | U ONE |
| 103 | A THREE |
| 104 | A TWO |
| 105 | EOF |
| 106 | git diff-index --cached --name-status HEAD >actual && |
| 107 | test_cmp expected actual |
| 108 | ' |
| 109 | |
| 110 | test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' ' |
| 111 | cat >expected <<-EOF && |
| 112 | U ONE |
| 113 | C ONE THREE |
| 114 | C ONE TWO |
| 115 | EOF |
| 116 | git diff-index --cached -C --name-status HEAD | |
| 117 | sed "s/^C[0-9]*/C/g" >actual && |
| 118 | test_cmp expected actual |
| 119 | ' |
| 120 | |
Junio C Hamano | 29796c6 | 2009-08-04 16:25:40 -0700 | [diff] [blame] | 121 | test_done |