blob: b8cb4906aa7de022543b594399b6fa9a83ffc847 [file] [log] [blame]
Junio C Hamano29796c62009-08-04 16:25:40 -07001#!/bin/sh
2
3test_description='basic work tree status reporting'
4
5. ./test-lib.sh
6
7test_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
14test_expect_success 'A/A conflict' '
15 git checkout B^0 &&
16 test_must_fail git merge C
17'
18
19test_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
25test_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 Hamano4d4d5722009-08-05 00:04:51 -070031cat >expect <<EOF
32# On branch side
33# Unmerged paths:
Junio C Hamanodd20f8a2009-12-12 00:18:12 -080034# (use "git add/rm <file>..." as appropriate to mark resolution)
Junio C Hamano4d4d5722009-08-05 00:04:51 -070035#
36# deleted by us: foo
37#
38no changes added to commit (use "git add" and/or "git commit -a")
39EOF
40
Junio C Hamanob3e19002011-04-12 16:33:39 -070041test_expect_success 'M/D conflict does not segfault' '
Junio C Hamano4d4d5722009-08-05 00:04:51 -070042 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 Hamano9e4b7ab2009-08-15 02:27:39 -070052 test_must_fail git commit --dry-run >../actual &&
Junio C Hamanob3e19002011-04-12 16:33:39 -070053 test_i18ncmp ../expect ../actual &&
Junio C Hamano9e4b7ab2009-08-15 02:27:39 -070054 git status >../actual &&
Junio C Hamanob3e19002011-04-12 16:33:39 -070055 test_i18ncmp ../expect ../actual
Junio C Hamano9e4b7ab2009-08-15 02:27:39 -070056 )
Junio C Hamano4d4d5722009-08-05 00:04:51 -070057'
58
Martin von Zweigbergkd7c9bf22011-03-23 22:41:01 -040059test_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
80test_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
90test_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
100test_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
110test_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 Hamano29796c62009-08-04 16:25:40 -0700121test_done