|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +TEST_PASSES_SANITIZE_LEAK=true |
| 4 | + |
| 5 | +test_description='direct path-walk API tests' |
| 6 | + |
| 7 | +. ./test-lib.sh |
| 8 | + |
| 9 | +test_expect_success 'setup test repository' ' |
| 10 | + git checkout -b base && |
| 11 | +
|
| 12 | + mkdir left && |
| 13 | + mkdir right && |
| 14 | + echo a >a && |
| 15 | + echo b >left/b && |
| 16 | + echo c >right/c && |
| 17 | + git add . && |
| 18 | + git commit -m "first" && |
| 19 | +
|
| 20 | + echo d >right/d && |
| 21 | + git add right && |
| 22 | + git commit -m "second" && |
| 23 | +
|
| 24 | + echo bb >left/b && |
| 25 | + git commit -a -m "third" && |
| 26 | +
|
| 27 | + git checkout -b topic HEAD~1 && |
| 28 | + echo cc >right/c && |
| 29 | + git commit -a -m "topic" |
| 30 | +' |
| 31 | + |
| 32 | +test_expect_success 'all' ' |
| 33 | + test-tool path-walk -- --all >out && |
| 34 | +
|
| 35 | + cat >expect <<-EOF && |
| 36 | + 0:tree::$(git rev-parse topic^{tree}) |
| 37 | + 0:tree::$(git rev-parse base^{tree}) |
| 38 | + 0:tree::$(git rev-parse base~1^{tree}) |
| 39 | + 0:tree::$(git rev-parse base~2^{tree}) |
| 40 | + 1:tree:right/:$(git rev-parse topic:right) |
| 41 | + 1:tree:right/:$(git rev-parse base~1:right) |
| 42 | + 1:tree:right/:$(git rev-parse base~2:right) |
| 43 | + 2:blob:right/d:$(git rev-parse base~1:right/d) |
| 44 | + 3:blob:right/c:$(git rev-parse base~2:right/c) |
| 45 | + 3:blob:right/c:$(git rev-parse topic:right/c) |
| 46 | + 4:tree:left/:$(git rev-parse base:left) |
| 47 | + 4:tree:left/:$(git rev-parse base~2:left) |
| 48 | + 5:blob:left/b:$(git rev-parse base~2:left/b) |
| 49 | + 5:blob:left/b:$(git rev-parse base:left/b) |
| 50 | + 6:blob:a:$(git rev-parse base~2:a) |
| 51 | + blobs:6 |
| 52 | + trees:9 |
| 53 | + EOF |
| 54 | +
|
| 55 | + test_cmp_sorted expect out |
| 56 | +' |
| 57 | + |
| 58 | +test_expect_success 'topic only' ' |
| 59 | + test-tool path-walk -- topic >out && |
| 60 | +
|
| 61 | + cat >expect <<-EOF && |
| 62 | + 0:tree::$(git rev-parse topic^{tree}) |
| 63 | + 0:tree::$(git rev-parse base~1^{tree}) |
| 64 | + 0:tree::$(git rev-parse base~2^{tree}) |
| 65 | + 1:tree:right/:$(git rev-parse topic:right) |
| 66 | + 1:tree:right/:$(git rev-parse base~1:right) |
| 67 | + 1:tree:right/:$(git rev-parse base~2:right) |
| 68 | + 2:blob:right/d:$(git rev-parse base~1:right/d) |
| 69 | + 3:blob:right/c:$(git rev-parse base~2:right/c) |
| 70 | + 3:blob:right/c:$(git rev-parse topic:right/c) |
| 71 | + 4:tree:left/:$(git rev-parse base~2:left) |
| 72 | + 5:blob:left/b:$(git rev-parse base~2:left/b) |
| 73 | + 6:blob:a:$(git rev-parse base~2:a) |
| 74 | + blobs:5 |
| 75 | + trees:7 |
| 76 | + EOF |
| 77 | +
|
| 78 | + test_cmp_sorted expect out |
| 79 | +' |
| 80 | + |
| 81 | +test_expect_success 'topic, not base' ' |
| 82 | + test-tool path-walk -- topic --not base >out && |
| 83 | +
|
| 84 | + cat >expect <<-EOF && |
| 85 | + 0:tree::$(git rev-parse topic^{tree}) |
| 86 | + 1:tree:right/:$(git rev-parse topic:right) |
| 87 | + 2:blob:right/d:$(git rev-parse topic:right/d) |
| 88 | + 3:blob:right/c:$(git rev-parse topic:right/c) |
| 89 | + 4:tree:left/:$(git rev-parse topic:left) |
| 90 | + 5:blob:left/b:$(git rev-parse topic:left/b) |
| 91 | + 6:blob:a:$(git rev-parse topic:a) |
| 92 | + blobs:4 |
| 93 | + trees:3 |
| 94 | + EOF |
| 95 | +
|
| 96 | + test_cmp_sorted expect out |
| 97 | +' |
| 98 | + |
| 99 | +test_expect_success 'topic, not base, boundary' ' |
| 100 | + test-tool path-walk -- --boundary topic --not base >out && |
| 101 | +
|
| 102 | + cat >expect <<-EOF && |
| 103 | + 0:tree::$(git rev-parse topic^{tree}) |
| 104 | + 0:tree::$(git rev-parse base~1^{tree}) |
| 105 | + 1:tree:right/:$(git rev-parse topic:right) |
| 106 | + 1:tree:right/:$(git rev-parse base~1:right) |
| 107 | + 2:blob:right/d:$(git rev-parse base~1:right/d) |
| 108 | + 3:blob:right/c:$(git rev-parse base~1:right/c) |
| 109 | + 3:blob:right/c:$(git rev-parse topic:right/c) |
| 110 | + 4:tree:left/:$(git rev-parse base~1:left) |
| 111 | + 5:blob:left/b:$(git rev-parse base~1:left/b) |
| 112 | + 6:blob:a:$(git rev-parse base~1:a) |
| 113 | + blobs:5 |
| 114 | + trees:5 |
| 115 | + EOF |
| 116 | +
|
| 117 | + test_cmp_sorted expect out |
| 118 | +' |
| 119 | + |
| 120 | +test_done |
0 commit comments