summaryrefslogtreecommitdiff
path: root/t/annotate-tests.sh
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2019-04-07 23:43:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-04-08 08:02:26 (GMT)
commita544fb08f8bfa3a9a566d436e5e81dd30fb21c4c (patch)
tree45dc10e153304923ded034801bb892bc02f6c45f /t/annotate-tests.sh
parentaeb582a98374c094361cba1bd756dc6307432c42 (diff)
downloadgit-a544fb08f8bfa3a9a566d436e5e81dd30fb21c4c.zip
git-a544fb08f8bfa3a9a566d436e5e81dd30fb21c4c.tar.gz
git-a544fb08f8bfa3a9a566d436e5e81dd30fb21c4c.tar.bz2
blame: default to HEAD in a bare repo when no start commit is given
When 'git blame' is invoked without specifying the commit to start blaming from, it starts from the given file's state in the work tree. However, when invoked in a bare repository without a start commit, then there is no work tree state to start from, and it dies with the following error message: $ git rev-parse --is-bare-repository true $ git blame file.c fatal: this operation must be run in a work tree This is misleading, because it implies that 'git blame' doesn't work in bare repositories at all, but it does, in fact, work just fine when it is given a commit to start from. We could improve the error message, of course, but let's just default to HEAD in a bare repository instead, as most likely that is what the user wanted anyway (if they wanted to start from an other commit, then they would have specified that in the first place). 'git annotate' is just a thin wrapper around 'git blame', so in the same situation it printed the same misleading error message, and this patch fixes it, too. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/annotate-tests.sh')
-rw-r--r--t/annotate-tests.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 6da48a2..d933af5 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -68,6 +68,14 @@ test_expect_success 'blame 1 author' '
check_count A 2
'
+test_expect_success 'blame in a bare repo without starting commit' '
+ git clone --bare . bare.git &&
+ (
+ cd bare.git &&
+ check_count A 2
+ )
+'
+
test_expect_success 'blame by tag objects' '
git tag -m "test tag" testTag &&
git tag -m "test tag #2" testTag2 testTag &&