summaryrefslogtreecommitdiffstats
path: root/t/t5318-commit-graph.sh
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2018-07-12 00:42:42 +0200
committerJunio C Hamano <gitster@pobox.com>2018-07-18 00:47:48 +0200
commitdade47c06cf849b0ca180a8e6383b55ea6f75812 (patch)
tree9e7884a642dbf92f13b874457bf21464c383b9b2 /t/t5318-commit-graph.sh
parentcommit-graph: store graph in struct object_store (diff)
downloadgit-dade47c06cf849b0ca180a8e6383b55ea6f75812.tar.xz
git-dade47c06cf849b0ca180a8e6383b55ea6f75812.zip
commit-graph: add repo arg to graph readers
Add a struct repository argument to the functions in commit-graph.h that read the commit graph. (This commit does not affect functions that write commit graphs.) Because the commit graph functions can now read the commit graph of any repository, the global variable core_commit_graph has been removed. Instead, the config option core.commitGraph is now read on the first time in a repository that a commit is attempted to be parsed using its commit graph. This commit includes a test that exercises the functionality on an arbitrary repository that is not the_repository. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5318-commit-graph.sh')
-rwxr-xr-xt/t5318-commit-graph.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index 5947de3d24..4f17d7701e 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -431,4 +431,39 @@ test_expect_success 'git fsck (checks commit-graph)' '
test_must_fail git fsck
'
+test_expect_success 'setup non-the_repository tests' '
+ rm -rf repo &&
+ git init repo &&
+ test_commit -C repo one &&
+ test_commit -C repo two &&
+ git -C repo config core.commitGraph true &&
+ git -C repo rev-parse two | \
+ git -C repo commit-graph write --stdin-commits
+'
+
+test_expect_success 'parse_commit_in_graph works for non-the_repository' '
+ test-tool repository parse_commit_in_graph \
+ repo/.git repo "$(git -C repo rev-parse two)" >actual &&
+ echo $(git -C repo log --pretty="%ct" -1) \
+ $(git -C repo rev-parse one) >expect &&
+ test_cmp expect actual &&
+
+ test-tool repository parse_commit_in_graph \
+ repo/.git repo "$(git -C repo rev-parse one)" >actual &&
+ echo $(git -C repo log --pretty="%ct" -1 one) >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'get_commit_tree_in_graph works for non-the_repository' '
+ test-tool repository get_commit_tree_in_graph \
+ repo/.git repo "$(git -C repo rev-parse two)" >actual &&
+ echo $(git -C repo rev-parse two^{tree}) >expect &&
+ test_cmp expect actual &&
+
+ test-tool repository get_commit_tree_in_graph \
+ repo/.git repo "$(git -C repo rev-parse one)" >actual &&
+ echo $(git -C repo rev-parse one^{tree}) >expect &&
+ test_cmp expect actual
+'
+
test_done