Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Write the diff and patch checks as the suite does
git -C, test_cmp with expect and actual, and rev-list --max-parents=0 for the root commit, the forms the other files use.
Diffstat (limited to '')
-rwxr-xr-xtests/t0106-commit.sh2
-rwxr-xr-xtests/t0108-rawdiff.sh34
-rwxr-xr-xtests/t0109-patch.sh22
3 files changed, 29 insertions, 29 deletions
diff --git a/tests/t0106-commit.sh b/tests/t0106-commit.sh
index d420585..9a0a7e1 100755
--- a/tests/t0106-commit.sh
+++ b/tests/t0106-commit.sh
@@ -39,7 +39,7 @@ test_expect_success 'a commit that changes no files draws no diffstat table' '
# A root commit has no parent, so it diffs against the empty tree.
test_expect_success 'get root commit' '
- root=$(cd repos/foo && git rev-list --reverse HEAD | head -1) &&
+ root=$(git -C repos/foo rev-list --max-parents=0 HEAD) &&
cgit_url "foo/commit&id=$root" >tmp &&
grep "</html>" tmp
'
diff --git a/tests/t0108-rawdiff.sh b/tests/t0108-rawdiff.sh
index 500407f..9b4eb37 100755
--- a/tests/t0108-rawdiff.sh
+++ b/tests/t0108-rawdiff.sh
@@ -12,13 +12,13 @@ test_expect_success 'generate foo/rawdiff' '
'
test_expect_success 'compare with output of git-diff(1)' '
- git --git-dir="$PWD/repos/foo/.git" diff HEAD^.. >tmp2 &&
- strip_headers <tmp >tmp_ &&
- cmp tmp_ tmp2
+ git -C repos/foo diff HEAD^.. >expect &&
+ strip_headers <tmp >actual &&
+ test_cmp expect actual
'
test_expect_success 'find initial commit' '
- root=$(git --git-dir="$PWD/repos/foo/.git" rev-list --max-parents=0 HEAD)
+ root=$(git -C repos/foo rev-list --max-parents=0 HEAD)
'
test_expect_success 'generate diff for initial commit' '
@@ -26,30 +26,30 @@ test_expect_success 'generate diff for initial commit' '
'
test_expect_success 'compare with output of git-diff-tree(1)' '
- git --git-dir="$PWD/repos/foo/.git" diff-tree -p --no-commit-id --root "$root" >tmp2 &&
- strip_headers <tmp >tmp_ &&
- cmp tmp_ tmp2
+ git -C repos/foo diff-tree -p --no-commit-id --root "$root" >expect &&
+ strip_headers <tmp >actual &&
+ test_cmp expect actual
'
test_expect_success 'generate diff for multiple commits' '
- id=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD) &&
- id2=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD~3) &&
+ id=$(git -C repos/foo rev-parse HEAD) &&
+ id2=$(git -C repos/foo rev-parse HEAD~3) &&
cgit_url "foo/rawdiff&id=$id&id2=$id2" >tmp
'
test_expect_success 'compare with output of git-diff(1)' '
- git --git-dir="$PWD/repos/foo/.git" diff HEAD~3..HEAD >tmp2 &&
- strip_headers <tmp >tmp_ &&
- cmp tmp_ tmp2
+ git -C repos/foo diff HEAD~3..HEAD >expect &&
+ strip_headers <tmp >actual &&
+ test_cmp expect actual
'
test_expect_success 'a path limits the diff to that file' '
cgit_url "foo/rawdiff/file-4&id=$id&id2=$id2" >tmp &&
- git --git-dir="$PWD/repos/foo/.git" diff HEAD~3..HEAD -- file-4 >tmp2 &&
- strip_headers <tmp >tmp_ &&
- cmp tmp_ tmp2 &&
- grep "file-4" tmp_ &&
- ! grep "file-5" tmp_
+ git -C repos/foo diff HEAD~3..HEAD -- file-4 >expect &&
+ strip_headers <tmp >actual &&
+ test_cmp expect actual &&
+ grep "file-4" actual &&
+ ! grep "file-5" actual
'
test_done
diff --git a/tests/t0109-patch.sh b/tests/t0109-patch.sh
index f37a23e..18ed501 100755
--- a/tests/t0109-patch.sh
+++ b/tests/t0109-patch.sh
@@ -22,14 +22,14 @@ test_expect_success 'generate foo/patch' '
'
test_expect_success 'compare with output of git-format-patch(1)' '
- git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" \
- --signature="cgit" --stdout HEAD^ >tmp2 &&
- strip_headers <tmp >tmp_ &&
- test_cmp tmp_ tmp2
+ git -C repos/foo format-patch --subject-prefix="" \
+ --signature="cgit" --stdout HEAD^ >expect &&
+ strip_headers <tmp >actual &&
+ test_cmp expect actual
'
test_expect_success 'find initial commit' '
- root=$(git --git-dir="$PWD/repos/foo/.git" rev-list --max-parents=0 HEAD)
+ root=$(git -C repos/foo rev-list --max-parents=0 HEAD)
'
test_expect_success 'generate patch for initial commit' '
@@ -41,16 +41,16 @@ test_expect_success 'find `cgit` signature on the initial commit' '
'
test_expect_success 'generate patches for multiple commits' '
- id=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD) &&
- id2=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD~3) &&
+ id=$(git -C repos/foo rev-parse HEAD) &&
+ id2=$(git -C repos/foo rev-parse HEAD~3) &&
cgit_url "foo/patch&id=$id&id2=$id2" >tmp
'
test_expect_success 'compare the range with git-format-patch(1)' '
- git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" \
- -N --signature="cgit" --stdout HEAD~3..HEAD >tmp2 &&
- strip_headers <tmp >tmp_ &&
- test_cmp tmp_ tmp2
+ git -C repos/foo format-patch --subject-prefix="" \
+ -N --signature="cgit" --stdout HEAD~3..HEAD >expect &&
+ strip_headers <tmp >actual &&
+ test_cmp expect actual
'
test_expect_success 'max-patch-count bounds a patch range' '