Git fork
1#!/bin/sh
2
3test_description='basic diff-pairs tests'
4. ./test-lib.sh
5
6# This creates a diff with added, modified, deleted, renamed, copied, and
7# typechange entries. This includes a submodule to test submodule diff support.
8test_expect_success 'setup' '
9 test_config_global protocol.file.allow always &&
10 git init sub &&
11 test_commit -C sub initial &&
12
13 git init main &&
14 cd main &&
15 echo to-be-gone >deleted &&
16 echo original >modified &&
17 echo now-a-file >symlink &&
18 test_seq 200 >two-hundred &&
19 test_seq 201 500 >five-hundred &&
20 git add . &&
21 test_tick &&
22 git commit -m base &&
23 git tag base &&
24
25 git submodule add ../sub &&
26 echo now-here >added &&
27 echo new >modified &&
28 rm deleted &&
29 mkdir subdir &&
30 echo content >subdir/file &&
31 mv two-hundred renamed &&
32 test_seq 201 500 | sed s/300/modified/ >copied &&
33 rm symlink &&
34 git add -A . &&
35 test_ln_s_add dest symlink &&
36 test_tick &&
37 git commit -m new &&
38 git tag new
39'
40
41test_expect_success 'diff-pairs recreates --raw' '
42 git diff-tree -r -M -C -C -z base new >expect &&
43 git diff-pairs --raw -z >actual <expect &&
44 test_cmp expect actual
45'
46
47test_expect_success 'diff-pairs can create -p output' '
48 git diff-tree -p -M -C -C base new >expect &&
49 git diff-tree -r -M -C -C -z base new |
50 git diff-pairs -p -z >actual &&
51 test_cmp expect actual
52'
53
54test_expect_success 'diff-pairs does not support normal raw diff input' '
55 git diff-tree -r base new |
56 test_must_fail git diff-pairs >out 2>err &&
57
58 echo "usage: working without -z is not supported" >expect &&
59 test_must_be_empty out &&
60 test_cmp expect err
61'
62
63test_expect_success 'diff-pairs does not support tree objects as input' '
64 git diff-tree -z base new |
65 test_must_fail git diff-pairs -z >out 2>err &&
66
67 echo "fatal: tree objects not supported" >expect &&
68 test_must_be_empty out &&
69 test_cmp expect err
70'
71
72test_expect_success 'diff-pairs does not support pathspec arguments' '
73 git diff-tree -r -z base new |
74 test_must_fail git diff-pairs -z -- new >out 2>err &&
75
76 echo "usage: pathspec arguments not supported" >expect &&
77 test_must_be_empty out &&
78 test_cmp expect err
79'
80
81test_expect_success 'diff-pairs explicit queue flush' '
82 git diff-tree -r -M -C -C -z base new >expect &&
83 printf "\0" >>expect &&
84 git diff-tree -r -M -C -C -z base new >>expect &&
85
86 git diff-pairs --raw -z <expect >actual &&
87 test_cmp expect actual
88'
89
90test_done