THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

560 lines
17KB

  1. #!/bin/sh
  2. test_description='commit graph'
  3. . ./test-lib.sh
  4. test_expect_success 'setup full repo' '
  5. mkdir full &&
  6. cd "$TRASH_DIRECTORY/full" &&
  7. git init &&
  8. git config core.commitGraph true &&
  9. objdir=".git/objects" &&
  10. test_oid_init
  11. '
  12. test_expect_success 'verify graph with no graph file' '
  13. cd "$TRASH_DIRECTORY/full" &&
  14. git commit-graph verify
  15. '
  16. test_expect_success 'write graph with no packs' '
  17. cd "$TRASH_DIRECTORY/full" &&
  18. git commit-graph write --object-dir . &&
  19. test_path_is_file info/commit-graph
  20. '
  21. test_expect_success 'create commits and repack' '
  22. cd "$TRASH_DIRECTORY/full" &&
  23. for i in $(test_seq 3)
  24. do
  25. test_commit $i &&
  26. git branch commits/$i
  27. done &&
  28. git repack
  29. '
  30. graph_git_two_modes() {
  31. git -c core.commitGraph=true $1 >output
  32. git -c core.commitGraph=false $1 >expect
  33. test_cmp expect output
  34. }
  35. graph_git_behavior() {
  36. MSG=$1
  37. DIR=$2
  38. BRANCH=$3
  39. COMPARE=$4
  40. test_expect_success "check normal git operations: $MSG" '
  41. cd "$TRASH_DIRECTORY/$DIR" &&
  42. graph_git_two_modes "log --oneline $BRANCH" &&
  43. graph_git_two_modes "log --topo-order $BRANCH" &&
  44. graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
  45. graph_git_two_modes "branch -vv" &&
  46. graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
  47. '
  48. }
  49. graph_git_behavior 'no graph' full commits/3 commits/1
  50. graph_read_expect() {
  51. OPTIONAL=""
  52. NUM_CHUNKS=3
  53. if test ! -z $2
  54. then
  55. OPTIONAL=" $2"
  56. NUM_CHUNKS=$((3 + $(echo "$2" | wc -w)))
  57. fi
  58. cat >expect <<- EOF
  59. header: 43475048 1 1 $NUM_CHUNKS 0
  60. num_commits: $1
  61. chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL
  62. EOF
  63. git commit-graph read >output &&
  64. test_cmp expect output
  65. }
  66. test_expect_success 'write graph' '
  67. cd "$TRASH_DIRECTORY/full" &&
  68. graph1=$(git commit-graph write) &&
  69. test_path_is_file $objdir/info/commit-graph &&
  70. graph_read_expect "3"
  71. '
  72. graph_git_behavior 'graph exists' full commits/3 commits/1
  73. test_expect_success 'Add more commits' '
  74. cd "$TRASH_DIRECTORY/full" &&
  75. git reset --hard commits/1 &&
  76. for i in $(test_seq 4 5)
  77. do
  78. test_commit $i &&
  79. git branch commits/$i
  80. done &&
  81. git reset --hard commits/2 &&
  82. for i in $(test_seq 6 7)
  83. do
  84. test_commit $i &&
  85. git branch commits/$i
  86. done &&
  87. git reset --hard commits/2 &&
  88. git merge commits/4 &&
  89. git branch merge/1 &&
  90. git reset --hard commits/4 &&
  91. git merge commits/6 &&
  92. git branch merge/2 &&
  93. git reset --hard commits/3 &&
  94. git merge commits/5 commits/7 &&
  95. git branch merge/3 &&
  96. git repack
  97. '
  98. # Current graph structure:
  99. #
  100. # __M3___
  101. # / | \
  102. # 3 M1 5 M2 7
  103. # |/ \|/ \|
  104. # 2 4 6
  105. # |___/____/
  106. # 1
  107. test_expect_success 'write graph with merges' '
  108. cd "$TRASH_DIRECTORY/full" &&
  109. git commit-graph write &&
  110. test_path_is_file $objdir/info/commit-graph &&
  111. graph_read_expect "10" "extra_edges"
  112. '
  113. graph_git_behavior 'merge 1 vs 2' full merge/1 merge/2
  114. graph_git_behavior 'merge 1 vs 3' full merge/1 merge/3
  115. graph_git_behavior 'merge 2 vs 3' full merge/2 merge/3
  116. test_expect_success 'Add one more commit' '
  117. cd "$TRASH_DIRECTORY/full" &&
  118. test_commit 8 &&
  119. git branch commits/8 &&
  120. ls $objdir/pack | grep idx >existing-idx &&
  121. git repack &&
  122. ls $objdir/pack| grep idx | grep -v -f existing-idx >new-idx
  123. '
  124. # Current graph structure:
  125. #
  126. # 8
  127. # |
  128. # __M3___
  129. # / | \
  130. # 3 M1 5 M2 7
  131. # |/ \|/ \|
  132. # 2 4 6
  133. # |___/____/
  134. # 1
  135. graph_git_behavior 'mixed mode, commit 8 vs merge 1' full commits/8 merge/1
  136. graph_git_behavior 'mixed mode, commit 8 vs merge 2' full commits/8 merge/2
  137. test_expect_success 'write graph with new commit' '
  138. cd "$TRASH_DIRECTORY/full" &&
  139. git commit-graph write &&
  140. test_path_is_file $objdir/info/commit-graph &&
  141. graph_read_expect "11" "extra_edges"
  142. '
  143. graph_git_behavior 'full graph, commit 8 vs merge 1' full commits/8 merge/1
  144. graph_git_behavior 'full graph, commit 8 vs merge 2' full commits/8 merge/2
  145. test_expect_success 'write graph with nothing new' '
  146. cd "$TRASH_DIRECTORY/full" &&
  147. git commit-graph write &&
  148. test_path_is_file $objdir/info/commit-graph &&
  149. graph_read_expect "11" "extra_edges"
  150. '
  151. graph_git_behavior 'cleared graph, commit 8 vs merge 1' full commits/8 merge/1
  152. graph_git_behavior 'cleared graph, commit 8 vs merge 2' full commits/8 merge/2
  153. test_expect_success 'build graph from latest pack with closure' '
  154. cd "$TRASH_DIRECTORY/full" &&
  155. cat new-idx | git commit-graph write --stdin-packs &&
  156. test_path_is_file $objdir/info/commit-graph &&
  157. graph_read_expect "9" "extra_edges"
  158. '
  159. graph_git_behavior 'graph from pack, commit 8 vs merge 1' full commits/8 merge/1
  160. graph_git_behavior 'graph from pack, commit 8 vs merge 2' full commits/8 merge/2
  161. test_expect_success 'build graph from commits with closure' '
  162. cd "$TRASH_DIRECTORY/full" &&
  163. git tag -a -m "merge" tag/merge merge/2 &&
  164. git rev-parse tag/merge >commits-in &&
  165. git rev-parse merge/1 >>commits-in &&
  166. cat commits-in | git commit-graph write --stdin-commits &&
  167. test_path_is_file $objdir/info/commit-graph &&
  168. graph_read_expect "6"
  169. '
  170. graph_git_behavior 'graph from commits, commit 8 vs merge 1' full commits/8 merge/1
  171. graph_git_behavior 'graph from commits, commit 8 vs merge 2' full commits/8 merge/2
  172. test_expect_success 'build graph from commits with append' '
  173. cd "$TRASH_DIRECTORY/full" &&
  174. git rev-parse merge/3 | git commit-graph write --stdin-commits --append &&
  175. test_path_is_file $objdir/info/commit-graph &&
  176. graph_read_expect "10" "extra_edges"
  177. '
  178. graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1
  179. graph_git_behavior 'append graph, commit 8 vs merge 2' full commits/8 merge/2
  180. test_expect_success 'build graph using --reachable' '
  181. cd "$TRASH_DIRECTORY/full" &&
  182. git commit-graph write --reachable &&
  183. test_path_is_file $objdir/info/commit-graph &&
  184. graph_read_expect "11" "extra_edges"
  185. '
  186. graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1
  187. graph_git_behavior 'append graph, commit 8 vs merge 2' full commits/8 merge/2
  188. test_expect_success 'setup bare repo' '
  189. cd "$TRASH_DIRECTORY" &&
  190. git clone --bare --no-local full bare &&
  191. cd bare &&
  192. git config core.commitGraph true &&
  193. baredir="./objects"
  194. '
  195. graph_git_behavior 'bare repo, commit 8 vs merge 1' bare commits/8 merge/1
  196. graph_git_behavior 'bare repo, commit 8 vs merge 2' bare commits/8 merge/2
  197. test_expect_success 'write graph in bare repo' '
  198. cd "$TRASH_DIRECTORY/bare" &&
  199. git commit-graph write &&
  200. test_path_is_file $baredir/info/commit-graph &&
  201. graph_read_expect "11" "extra_edges"
  202. '
  203. graph_git_behavior 'bare repo with graph, commit 8 vs merge 1' bare commits/8 merge/1
  204. graph_git_behavior 'bare repo with graph, commit 8 vs merge 2' bare commits/8 merge/2
  205. test_expect_success 'perform fast-forward merge in full repo' '
  206. cd "$TRASH_DIRECTORY/full" &&
  207. git checkout -b merge-5-to-8 commits/5 &&
  208. git merge commits/8 &&
  209. git show-ref -s merge-5-to-8 >output &&
  210. git show-ref -s commits/8 >expect &&
  211. test_cmp expect output
  212. '
  213. test_expect_success 'check that gc computes commit-graph' '
  214. cd "$TRASH_DIRECTORY/full" &&
  215. git commit --allow-empty -m "blank" &&
  216. git commit-graph write --reachable &&
  217. cp $objdir/info/commit-graph commit-graph-before-gc &&
  218. git reset --hard HEAD~1 &&
  219. git config gc.writeCommitGraph true &&
  220. git gc &&
  221. cp $objdir/info/commit-graph commit-graph-after-gc &&
  222. ! test_cmp_bin commit-graph-before-gc commit-graph-after-gc &&
  223. git commit-graph write --reachable &&
  224. test_cmp_bin commit-graph-after-gc $objdir/info/commit-graph
  225. '
  226. test_expect_success 'replace-objects invalidates commit-graph' '
  227. cd "$TRASH_DIRECTORY" &&
  228. test_when_finished rm -rf replace &&
  229. git clone full replace &&
  230. (
  231. cd replace &&
  232. git commit-graph write --reachable &&
  233. test_path_is_file .git/objects/info/commit-graph &&
  234. git replace HEAD~1 HEAD~2 &&
  235. git -c core.commitGraph=false log >expect &&
  236. git -c core.commitGraph=true log >actual &&
  237. test_cmp expect actual &&
  238. git commit-graph write --reachable &&
  239. git -c core.commitGraph=false --no-replace-objects log >expect &&
  240. git -c core.commitGraph=true --no-replace-objects log >actual &&
  241. test_cmp expect actual &&
  242. rm -rf .git/objects/info/commit-graph &&
  243. git commit-graph write --reachable &&
  244. test_path_is_file .git/objects/info/commit-graph
  245. )
  246. '
  247. test_expect_success 'commit grafts invalidate commit-graph' '
  248. cd "$TRASH_DIRECTORY" &&
  249. test_when_finished rm -rf graft &&
  250. git clone full graft &&
  251. (
  252. cd graft &&
  253. git commit-graph write --reachable &&
  254. test_path_is_file .git/objects/info/commit-graph &&
  255. H1=$(git rev-parse --verify HEAD~1) &&
  256. H3=$(git rev-parse --verify HEAD~3) &&
  257. echo "$H1 $H3" >.git/info/grafts &&
  258. git -c core.commitGraph=false log >expect &&
  259. git -c core.commitGraph=true log >actual &&
  260. test_cmp expect actual &&
  261. git commit-graph write --reachable &&
  262. git -c core.commitGraph=false --no-replace-objects log >expect &&
  263. git -c core.commitGraph=true --no-replace-objects log >actual &&
  264. test_cmp expect actual &&
  265. rm -rf .git/objects/info/commit-graph &&
  266. git commit-graph write --reachable &&
  267. test_path_is_missing .git/objects/info/commit-graph
  268. )
  269. '
  270. test_expect_success 'replace-objects invalidates commit-graph' '
  271. cd "$TRASH_DIRECTORY" &&
  272. test_when_finished rm -rf shallow &&
  273. git clone --depth 2 "file://$TRASH_DIRECTORY/full" shallow &&
  274. (
  275. cd shallow &&
  276. git commit-graph write --reachable &&
  277. test_path_is_missing .git/objects/info/commit-graph &&
  278. git fetch origin --unshallow &&
  279. git commit-graph write --reachable &&
  280. test_path_is_file .git/objects/info/commit-graph
  281. )
  282. '
  283. # the verify tests below expect the commit-graph to contain
  284. # exactly the commits reachable from the commits/8 branch.
  285. # If the file changes the set of commits in the list, then the
  286. # offsets into the binary file will result in different edits
  287. # and the tests will likely break.
  288. test_expect_success 'git commit-graph verify' '
  289. cd "$TRASH_DIRECTORY/full" &&
  290. git rev-parse commits/8 | git commit-graph write --stdin-commits &&
  291. git commit-graph verify >output
  292. '
  293. NUM_COMMITS=9
  294. NUM_OCTOPUS_EDGES=2
  295. HASH_LEN="$(test_oid rawsz)"
  296. GRAPH_BYTE_VERSION=4
  297. GRAPH_BYTE_HASH=5
  298. GRAPH_BYTE_CHUNK_COUNT=6
  299. GRAPH_CHUNK_LOOKUP_OFFSET=8
  300. GRAPH_CHUNK_LOOKUP_WIDTH=12
  301. GRAPH_CHUNK_LOOKUP_ROWS=5
  302. GRAPH_BYTE_OID_FANOUT_ID=$GRAPH_CHUNK_LOOKUP_OFFSET
  303. GRAPH_BYTE_OID_LOOKUP_ID=$(($GRAPH_CHUNK_LOOKUP_OFFSET + \
  304. 1 * $GRAPH_CHUNK_LOOKUP_WIDTH))
  305. GRAPH_BYTE_COMMIT_DATA_ID=$(($GRAPH_CHUNK_LOOKUP_OFFSET + \
  306. 2 * $GRAPH_CHUNK_LOOKUP_WIDTH))
  307. GRAPH_FANOUT_OFFSET=$(($GRAPH_CHUNK_LOOKUP_OFFSET + \
  308. $GRAPH_CHUNK_LOOKUP_WIDTH * $GRAPH_CHUNK_LOOKUP_ROWS))
  309. GRAPH_BYTE_FANOUT1=$(($GRAPH_FANOUT_OFFSET + 4 * 4))
  310. GRAPH_BYTE_FANOUT2=$(($GRAPH_FANOUT_OFFSET + 4 * 255))
  311. GRAPH_OID_LOOKUP_OFFSET=$(($GRAPH_FANOUT_OFFSET + 4 * 256))
  312. GRAPH_BYTE_OID_LOOKUP_ORDER=$(($GRAPH_OID_LOOKUP_OFFSET + $HASH_LEN * 8))
  313. GRAPH_BYTE_OID_LOOKUP_MISSING=$(($GRAPH_OID_LOOKUP_OFFSET + $HASH_LEN * 4 + 10))
  314. GRAPH_COMMIT_DATA_OFFSET=$(($GRAPH_OID_LOOKUP_OFFSET + $HASH_LEN * $NUM_COMMITS))
  315. GRAPH_BYTE_COMMIT_TREE=$GRAPH_COMMIT_DATA_OFFSET
  316. GRAPH_BYTE_COMMIT_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN))
  317. GRAPH_BYTE_COMMIT_EXTRA_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 4))
  318. GRAPH_BYTE_COMMIT_WRONG_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 3))
  319. GRAPH_BYTE_COMMIT_GENERATION=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 11))
  320. GRAPH_BYTE_COMMIT_DATE=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 12))
  321. GRAPH_COMMIT_DATA_WIDTH=$(($HASH_LEN + 16))
  322. GRAPH_OCTOPUS_DATA_OFFSET=$(($GRAPH_COMMIT_DATA_OFFSET + \
  323. $GRAPH_COMMIT_DATA_WIDTH * $NUM_COMMITS))
  324. GRAPH_BYTE_OCTOPUS=$(($GRAPH_OCTOPUS_DATA_OFFSET + 4))
  325. GRAPH_BYTE_FOOTER=$(($GRAPH_OCTOPUS_DATA_OFFSET + 4 * $NUM_OCTOPUS_EDGES))
  326. corrupt_graph_setup() {
  327. cd "$TRASH_DIRECTORY/full" &&
  328. test_when_finished mv commit-graph-backup $objdir/info/commit-graph &&
  329. cp $objdir/info/commit-graph commit-graph-backup
  330. }
  331. corrupt_graph_verify() {
  332. grepstr=$1
  333. test_must_fail git commit-graph verify 2>test_err &&
  334. grep -v "^+" test_err >err &&
  335. test_i18ngrep "$grepstr" err &&
  336. git status --short
  337. }
  338. # usage: corrupt_graph_and_verify <position> <data> <string> [<zero_pos>]
  339. # Manipulates the commit-graph file at the position
  340. # by inserting the data, optionally zeroing the file
  341. # starting at <zero_pos>, then runs 'git commit-graph verify'
  342. # and places the output in the file 'err'. Test 'err' for
  343. # the given string.
  344. corrupt_graph_and_verify() {
  345. pos=$1
  346. data="${2:-\0}"
  347. grepstr=$3
  348. corrupt_graph_setup &&
  349. orig_size=$(wc -c < $objdir/info/commit-graph) &&
  350. zero_pos=${4:-${orig_size}} &&
  351. printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
  352. dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 &&
  353. generate_zero_bytes $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" &&
  354. corrupt_graph_verify "$grepstr"
  355. }
  356. test_expect_success 'detect too small' '
  357. corrupt_graph_setup &&
  358. echo "a small graph" >$objdir/info/commit-graph &&
  359. corrupt_graph_verify "too small"
  360. '
  361. test_expect_success 'detect bad signature' '
  362. corrupt_graph_and_verify 0 "\0" \
  363. "graph signature"
  364. '
  365. test_expect_success 'detect bad version' '
  366. corrupt_graph_and_verify $GRAPH_BYTE_VERSION "\02" \
  367. "graph version"
  368. '
  369. test_expect_success 'detect bad hash version' '
  370. corrupt_graph_and_verify $GRAPH_BYTE_HASH "\02" \
  371. "hash version"
  372. '
  373. test_expect_success 'detect low chunk count' '
  374. corrupt_graph_and_verify $GRAPH_BYTE_CHUNK_COUNT "\02" \
  375. "missing the .* chunk"
  376. '
  377. test_expect_success 'detect missing OID fanout chunk' '
  378. corrupt_graph_and_verify $GRAPH_BYTE_OID_FANOUT_ID "\0" \
  379. "missing the OID Fanout chunk"
  380. '
  381. test_expect_success 'detect missing OID lookup chunk' '
  382. corrupt_graph_and_verify $GRAPH_BYTE_OID_LOOKUP_ID "\0" \
  383. "missing the OID Lookup chunk"
  384. '
  385. test_expect_success 'detect missing commit data chunk' '
  386. corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_DATA_ID "\0" \
  387. "missing the Commit Data chunk"
  388. '
  389. test_expect_success 'detect incorrect fanout' '
  390. corrupt_graph_and_verify $GRAPH_BYTE_FANOUT1 "\01" \
  391. "fanout value"
  392. '
  393. test_expect_success 'detect incorrect fanout final value' '
  394. corrupt_graph_and_verify $GRAPH_BYTE_FANOUT2 "\01" \
  395. "fanout value"
  396. '
  397. test_expect_success 'detect incorrect OID order' '
  398. corrupt_graph_and_verify $GRAPH_BYTE_OID_LOOKUP_ORDER "\01" \
  399. "incorrect OID order"
  400. '
  401. test_expect_success 'detect OID not in object database' '
  402. corrupt_graph_and_verify $GRAPH_BYTE_OID_LOOKUP_MISSING "\01" \
  403. "from object database"
  404. '
  405. test_expect_success 'detect incorrect tree OID' '
  406. corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_TREE "\01" \
  407. "root tree OID for commit"
  408. '
  409. test_expect_success 'detect incorrect parent int-id' '
  410. corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_PARENT "\01" \
  411. "invalid parent"
  412. '
  413. test_expect_success 'detect extra parent int-id' '
  414. corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_EXTRA_PARENT "\00" \
  415. "is too long"
  416. '
  417. test_expect_success 'detect wrong parent' '
  418. corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_WRONG_PARENT "\01" \
  419. "commit-graph parent for"
  420. '
  421. test_expect_success 'detect incorrect generation number' '
  422. corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_GENERATION "\070" \
  423. "generation for commit"
  424. '
  425. test_expect_success 'detect incorrect generation number' '
  426. corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_GENERATION "\01" \
  427. "non-zero generation number"
  428. '
  429. test_expect_success 'detect incorrect commit date' '
  430. corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_DATE "\01" \
  431. "commit date"
  432. '
  433. test_expect_success 'detect incorrect parent for octopus merge' '
  434. corrupt_graph_and_verify $GRAPH_BYTE_OCTOPUS "\01" \
  435. "invalid parent"
  436. '
  437. test_expect_success 'detect invalid checksum hash' '
  438. corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
  439. "incorrect checksum"
  440. '
  441. test_expect_success 'detect incorrect chunk count' '
  442. corrupt_graph_and_verify $GRAPH_BYTE_CHUNK_COUNT "\377" \
  443. "chunk lookup table entry missing" $GRAPH_CHUNK_LOOKUP_OFFSET
  444. '
  445. test_expect_success 'git fsck (checks commit-graph)' '
  446. cd "$TRASH_DIRECTORY/full" &&
  447. git fsck &&
  448. corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
  449. "incorrect checksum" &&
  450. test_must_fail git fsck
  451. '
  452. test_expect_success 'setup non-the_repository tests' '
  453. rm -rf repo &&
  454. git init repo &&
  455. test_commit -C repo one &&
  456. test_commit -C repo two &&
  457. git -C repo config core.commitGraph true &&
  458. git -C repo rev-parse two | \
  459. git -C repo commit-graph write --stdin-commits
  460. '
  461. test_expect_success 'parse_commit_in_graph works for non-the_repository' '
  462. test-tool repository parse_commit_in_graph \
  463. repo/.git repo "$(git -C repo rev-parse two)" >actual &&
  464. {
  465. git -C repo log --pretty=format:"%ct " -1 &&
  466. git -C repo rev-parse one
  467. } >expect &&
  468. test_cmp expect actual &&
  469. test-tool repository parse_commit_in_graph \
  470. repo/.git repo "$(git -C repo rev-parse one)" >actual &&
  471. git -C repo log --pretty="%ct" -1 one >expect &&
  472. test_cmp expect actual
  473. '
  474. test_expect_success 'get_commit_tree_in_graph works for non-the_repository' '
  475. test-tool repository get_commit_tree_in_graph \
  476. repo/.git repo "$(git -C repo rev-parse two)" >actual &&
  477. git -C repo rev-parse two^{tree} >expect &&
  478. test_cmp expect actual &&
  479. test-tool repository get_commit_tree_in_graph \
  480. repo/.git repo "$(git -C repo rev-parse one)" >actual &&
  481. git -C repo rev-parse one^{tree} >expect &&
  482. test_cmp expect actual
  483. '
  484. test_done