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