summaryrefslogtreecommitdiff
path: root/t/t8002-blame.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t8002-blame.sh')
-rwxr-xr-xt/t8002-blame.sh35
1 files changed, 27 insertions, 8 deletions
diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh
index eea048e..0147de3 100755
--- a/t/t8002-blame.sh
+++ b/t/t8002-blame.sh
@@ -1,11 +1,19 @@
#!/bin/sh
test_description='git blame'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+TEST_CREATE_REPO_NO_TEMPLATE=1
. ./test-lib.sh
PROG='git blame -c'
. "$TEST_DIRECTORY"/annotate-tests.sh
+test_expect_success 'setup' '
+ hexsz=$(test_oid hexsz)
+'
+
test_expect_success 'blame untracked file in empty repo' '
>untracked &&
test_must_fail git blame untracked
@@ -90,7 +98,7 @@ test_expect_success 'set up abbrev tests' '
test_commit abbrev &&
sha1=$(git rev-parse --verify HEAD) &&
check_abbrev () {
- expect=$1; shift
+ expect=$1 && shift &&
echo $sha1 | cut -c 1-$expect >expect &&
git blame "$@" abbrev.t >actual &&
perl -lne "/[0-9a-f]+/ and print \$&" <actual >actual.sha &&
@@ -105,21 +113,32 @@ test_expect_success 'blame --abbrev=<n> works' '
'
test_expect_success 'blame -l aligns regular and boundary commits' '
- check_abbrev 40 -l HEAD &&
- check_abbrev 39 -l ^HEAD
+ check_abbrev $hexsz -l HEAD &&
+ check_abbrev $((hexsz - 1)) -l ^HEAD
'
-test_expect_success 'blame --abbrev=40 behaves like -l' '
- check_abbrev 40 --abbrev=40 HEAD &&
- check_abbrev 39 --abbrev=40 ^HEAD
+test_expect_success 'blame --abbrev with full length behaves like -l' '
+ check_abbrev $hexsz --abbrev=$hexsz HEAD &&
+ check_abbrev $((hexsz - 1)) --abbrev=$hexsz ^HEAD
'
-test_expect_success '--no-abbrev works like --abbrev=40' '
- check_abbrev 40 --no-abbrev
+test_expect_success '--no-abbrev works like --abbrev with full length' '
+ check_abbrev $hexsz --no-abbrev
'
test_expect_success '--exclude-promisor-objects does not BUG-crash' '
test_must_fail git blame --exclude-promisor-objects one
'
+test_expect_success 'blame with uncommitted edits in partial clone does not crash' '
+ git init server &&
+ echo foo >server/file.txt &&
+ git -C server add file.txt &&
+ git -C server commit -m file &&
+
+ git clone --filter=blob:none "file://$(pwd)/server" client &&
+ echo bar >>client/file.txt &&
+ git -C client blame file.txt
+'
+
test_done