1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
test_description='Check content on rawdiff page'
. ./setup.sh
test_expect_success 'a commit is served as text matching git diff' '
cgit_ok_url "foo/rawdiff" >tmp &&
sed "/^$/q" tmp | grep "^Content-Type: text/plain" &&
git -C repos/foo diff HEAD^.. >expect &&
strip_headers <tmp >actual &&
test_cmp expect actual
'
test_expect_success 'the initial commit matches git diff-tree' '
root=$(git -C repos/foo rev-list --max-parents=0 HEAD) &&
cgit_ok_url "foo/rawdiff&id=$root" >tmp &&
git -C repos/foo diff-tree -p --no-commit-id --root "$root" >expect &&
strip_headers <tmp >actual &&
test_cmp expect actual
'
test_expect_success 'a range matches git diff over the same range' '
id=$(git -C repos/foo rev-parse HEAD) &&
id2=$(git -C repos/foo rev-parse HEAD~3) &&
cgit_ok_url "foo/rawdiff&id=$id&id2=$id2" >tmp &&
git -C repos/foo diff HEAD~3..HEAD >expect &&
strip_headers <tmp >actual &&
test_cmp expect actual
'
test_expect_success 'a path limits the diff to that file' '
id=$(git -C repos/foo rev-parse HEAD) &&
id2=$(git -C repos/foo rev-parse HEAD~3) &&
cgit_ok_url "foo/rawdiff/file-4&id=$id&id2=$id2" >tmp &&
git -C repos/foo diff HEAD~3..HEAD -- file-4 >expect &&
strip_headers <tmp >actual &&
test_cmp expect actual &&
grep "file-4" actual
'
test_expect_success 'a renamed file is diffed as the rename' '
mkrepo_renamed repos/moved "echo eleven >>new.txt" &&
cgitrc_repo movedrc moved &&
cgit_ok movedrc "url=moved/rawdiff/new.txt" >tmp &&
git -C repos/moved diff HEAD^ HEAD -- old.txt new.txt >expect &&
strip_headers <tmp >actual &&
test_cmp expect actual &&
grep "^rename from old.txt$" actual &&
grep "^+eleven$" actual
'
test_done
|