{"thread":{"id":"50892","subject":"[PATCH] blame: default to HEAD in a bare repo when no start commit is given","startedAt":"2019-04-07T23:43:35Z","lastAt":"2019-04-09T08:13:58Z","messageCount":6,"participants":["SZEDER Gábor","Eric Sunshine","Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"373378","messageId":"20190407234327.25617-1-szeder.dev@gmail.com","threadId":"50892","inReplyTo":null,"subject":"[PATCH] blame: default to HEAD in a bare repo when no start commit is given","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-04-07T23:43:27Z","receivedAt":"2019-04-07T23:43:35Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"When 'git blame' is invoked without specifying the commit to start\nblaming from, it starts from the given file's state in the work tree.\nHowever, when invoked in a bare repository without a start commit,\nthen there is no work tree state to start from, and it dies with the\nfollowing error message:\n\n  $ git rev-parse --is-bare-repository\n  true\n  $ git blame file.c\n  fatal: this operation must be run in a work tree\n\nThis is misleading, because it implies that 'git blame' doesn't work\nin bare repositories at all, but it does, in fact, work just fine when\nit is given a commit to start from.\n\nWe could improve the error message, of course, but let's just default\nto HEAD in a bare repository instead, as most likely that is what the\nuser wanted anyway (if they wanted to start from an other commit, then\nthey would have specified that in the first place).\n\n'git annotate' is just a thin wrapper around 'git blame', so in the\nsame situation it printed the same misleading error message, and this\npatch fixes it, too.\n\nSigned-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n---\n builtin/blame.c     | 13 +++++++++++++\n t/annotate-tests.sh |  8 ++++++++\n 2 files changed, 21 insertions(+)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 177c1022a0..21cde57e71 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -27,6 +27,7 @@\n #include \"object-store.h\"\n #include \"blame.h\"\n #include \"string-list.h\"\n+#include \"refs.h\"\n \n static char blame_usage[] = N_(\"git blame [<options>] [<rev-opts>] [<rev>] [--] <file>\");\n \n@@ -993,6 +994,18 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \n \trevs.disable_stdin = 1;\n \tsetup_revisions(argc, argv, &revs, NULL);\n+\tif (!revs.pending.nr && is_bare_repository()) {\n+\t\tstruct commit *head_commit;\n+\t\tstruct object_id head_oid;\n+\n+\t\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n+\t\t\t\t\t&head_oid, NULL) ||\n+\t\t    !(head_commit = lookup_commit_reference_gently(revs.repo,\n+\t\t\t\t\t\t\t     &head_oid, 1)))\n+\t\t\tdie(\"no such ref: HEAD\");\n+\n+\t\tadd_pending_object(&revs, &head_commit->object, \"HEAD\");\n+\t}\n \n \tinit_scoreboard(&sb);\n \tsb.revs = &revs;\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nindex 6da48a2e0a..d933af5714 100644\n--- a/t/annotate-tests.sh\n+++ b/t/annotate-tests.sh\n@@ -68,6 +68,14 @@ test_expect_success 'blame 1 author' '\n \tcheck_count A 2\n '\n \n+test_expect_success 'blame in a bare repo without starting commit' '\n+\tgit clone --bare . bare.git &&\n+\t(\n+\t\tcd bare.git &&\n+\t\tcheck_count A 2\n+\t)\n+'\n+\n test_expect_success 'blame by tag objects' '\n \tgit tag -m \"test tag\" testTag &&\n \tgit tag -m \"test tag #2\" testTag2 testTag &&\n-- \n2.21.0.539.g07239c3a71.dirty\n\n"},{"id":"373379","messageId":"CAPig+cQJUEEZ1=bG2WFLCXHpO6D2h36Bhz0c=zTsyjB5Oc4piQ@mail.gmail.com","threadId":"50892","inReplyTo":"20190407234327.25617-1-szeder.dev@gmail.com","subject":"Re: [PATCH] blame: default to HEAD in a bare repo when no start commit is given","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-04-08T00:42:24Z","receivedAt":"2019-04-08T00:42:43Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Apr 7, 2019 at 7:43 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:\n> [...]\n> We could improve the error message, of course, but let's just default\n> to HEAD in a bare repository instead, as most likely that is what the\n> user wanted anyway (if they wanted to start from an other commit, then\n> they would have specified that in the first place).\n> [...]\n> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n> ---\n> diff --git a/builtin/blame.c b/builtin/blame.c\n> @@ -993,6 +994,18 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n> +       if (!revs.pending.nr && is_bare_repository()) {\n> +               struct commit *head_commit;\n> +               struct object_id head_oid;\n> +\n> +               if (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n> +                                       &head_oid, NULL) ||\n> +                   !(head_commit = lookup_commit_reference_gently(revs.repo,\n> +                                                            &head_oid, 1)))\n> +                       die(\"no such ref: HEAD\");\n\nThis source file is already mostly internationalized, so perhaps:\n\n    die(_(\"no such ref: %s\"), \"HEAD\");\n\n> +               add_pending_object(&revs, &head_commit->object, \"HEAD\");\n> +       }\n"},{"id":"373417","messageId":"878swkacok.fsf@evledraar.gmail.com","threadId":"50892","inReplyTo":"20190407234327.25617-1-szeder.dev@gmail.com","subject":"Re: [PATCH] blame: default to HEAD in a bare repo when no start commit is given","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2019-04-08T12:44:59Z","receivedAt":"2019-04-08T12:45:04Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Apr 08 2019, SZEDER Gábor wrote:\n\n> When 'git blame' is invoked without specifying the commit to start\n> blaming from, it starts from the given file's state in the work tree.\n> However, when invoked in a bare repository without a start commit,\n> then there is no work tree state to start from, and it dies with the\n> following error message:\n>\n>   $ git rev-parse --is-bare-repository\n>   true\n>   $ git blame file.c\n>   fatal: this operation must be run in a work tree\n>\n> This is misleading, because it implies that 'git blame' doesn't work\n> in bare repositories at all, but it does, in fact, work just fine when\n> it is given a commit to start from.\n>\n> We could improve the error message, of course, but let's just default\n> to HEAD in a bare repository instead, as most likely that is what the\n> user wanted anyway (if they wanted to start from an other commit, then\n> they would have specified that in the first place).\n>\n> 'git annotate' is just a thin wrapper around 'git blame', so in the\n> same situation it printed the same misleading error message, and this\n> patch fixes it, too.\n>\n> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n\nThere was the explicit decision not to fall back to HEAD in 1cfe77333f\n(\"git-blame: no rev means start from the working tree file.\",\n2007-01-30). This change makes sense to me, but perhaps some discussion\nor reference to the previous commit is warranted?\n\nAlthough from skimming the thread from back then it seems to be \"not\nHEAD but working tree file\", not \"let's not use HEAD in bare repos\".\n\n>  builtin/blame.c     | 13 +++++++++++++\n>  t/annotate-tests.sh |  8 ++++++++\n>  2 files changed, 21 insertions(+)\n>\n> diff --git a/builtin/blame.c b/builtin/blame.c\n> index 177c1022a0..21cde57e71 100644\n> --- a/builtin/blame.c\n> +++ b/builtin/blame.c\n> @@ -27,6 +27,7 @@\n>  #include \"object-store.h\"\n>  #include \"blame.h\"\n>  #include \"string-list.h\"\n> +#include \"refs.h\"\n>\n>  static char blame_usage[] = N_(\"git blame [<options>] [<rev-opts>] [<rev>] [--] <file>\");\n>\n> @@ -993,6 +994,18 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n>\n>  \trevs.disable_stdin = 1;\n>  \tsetup_revisions(argc, argv, &revs, NULL);\n> +\tif (!revs.pending.nr && is_bare_repository()) {\n> +\t\tstruct commit *head_commit;\n> +\t\tstruct object_id head_oid;\n> +\n> +\t\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n> +\t\t\t\t\t&head_oid, NULL) ||\n> +\t\t    !(head_commit = lookup_commit_reference_gently(revs.repo,\n> +\t\t\t\t\t\t\t     &head_oid, 1)))\n> +\t\t\tdie(\"no such ref: HEAD\");\n> +\n> +\t\tadd_pending_object(&revs, &head_commit->object, \"HEAD\");\n> +\t}\n\nWith this patch, if I have a bare repo without a HEAD I now get:\n\n    fatal: no such ref: HEAD\n\nInstead of:\n\n    fatal: this operation must be run in a work tree\n\nBoth are bad & misleading, perhaps we can instead say something like:\n\n    die(_(\"in a bare repository you must specify a ref to blame from, we tried and failed to implicitly use HEAD\"));\n\nAlong with a test for what we do in bare repos without a HEAD....?\n\n>\n>  \tinit_scoreboard(&sb);\n>  \tsb.revs = &revs;\n> diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\n> index 6da48a2e0a..d933af5714 100644\n> --- a/t/annotate-tests.sh\n> +++ b/t/annotate-tests.sh\n> @@ -68,6 +68,14 @@ test_expect_success 'blame 1 author' '\n>  \tcheck_count A 2\n>  '\n>\n> +test_expect_success 'blame in a bare repo without starting commit' '\n> +\tgit clone --bare . bare.git &&\n> +\t(\n> +\t\tcd bare.git &&\n> +\t\tcheck_count A 2\n> +\t)\n\n....just 'git update-ref -d HEAD` after this and a test for 'git blame\n<file>' here would test bare without HEAD.\n\n>  test_expect_success 'blame by tag objects' '\n>  \tgit tag -m \"test tag\" testTag &&\n>  \tgit tag -m \"test tag #2\" testTag2 testTag &&\n"},{"id":"373424","messageId":"20190408143046.GF8796@szeder.dev","threadId":"50892","inReplyTo":"878swkacok.fsf@evledraar.gmail.com","subject":"Re: [PATCH] blame: default to HEAD in a bare repo when no start commit is given","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-04-08T14:30:46Z","receivedAt":"2019-04-08T14:30:52Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Apr 08, 2019 at 02:44:59PM +0200, Ævar Arnfjörð Bjarmason wrote:\n> \n> On Mon, Apr 08 2019, SZEDER Gábor wrote:\n> \n> > When 'git blame' is invoked without specifying the commit to start\n> > blaming from, it starts from the given file's state in the work tree.\n> > However, when invoked in a bare repository without a start commit,\n> > then there is no work tree state to start from, and it dies with the\n> > following error message:\n> >\n> >   $ git rev-parse --is-bare-repository\n> >   true\n> >   $ git blame file.c\n> >   fatal: this operation must be run in a work tree\n> >\n> > This is misleading, because it implies that 'git blame' doesn't work\n> > in bare repositories at all, but it does, in fact, work just fine when\n> > it is given a commit to start from.\n> >\n> > We could improve the error message, of course, but let's just default\n> > to HEAD in a bare repository instead, as most likely that is what the\n> > user wanted anyway (if they wanted to start from an other commit, then\n> > they would have specified that in the first place).\n> >\n> > 'git annotate' is just a thin wrapper around 'git blame', so in the\n> > same situation it printed the same misleading error message, and this\n> > patch fixes it, too.\n> >\n> > Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n> \n> There was the explicit decision not to fall back to HEAD in 1cfe77333f\n> (\"git-blame: no rev means start from the working tree file.\",\n> 2007-01-30). This change makes sense to me, but perhaps some discussion\n> or reference to the previous commit is warranted?\n\nI don't think so, because that doesn't apply here, since it doesn't\nreally make much sense to talk about a working tree file in a bare\nrepo.\n\n> Although from skimming the thread from back then it seems to be \"not\n> HEAD but working tree file\", not \"let's not use HEAD in bare repos\".\n> \n> >  builtin/blame.c     | 13 +++++++++++++\n> >  t/annotate-tests.sh |  8 ++++++++\n> >  2 files changed, 21 insertions(+)\n> >\n> > diff --git a/builtin/blame.c b/builtin/blame.c\n> > index 177c1022a0..21cde57e71 100644\n> > --- a/builtin/blame.c\n> > +++ b/builtin/blame.c\n> > @@ -27,6 +27,7 @@\n> >  #include \"object-store.h\"\n> >  #include \"blame.h\"\n> >  #include \"string-list.h\"\n> > +#include \"refs.h\"\n> >\n> >  static char blame_usage[] = N_(\"git blame [<options>] [<rev-opts>] [<rev>] [--] <file>\");\n> >\n> > @@ -993,6 +994,18 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n> >\n> >  \trevs.disable_stdin = 1;\n> >  \tsetup_revisions(argc, argv, &revs, NULL);\n> > +\tif (!revs.pending.nr && is_bare_repository()) {\n> > +\t\tstruct commit *head_commit;\n> > +\t\tstruct object_id head_oid;\n> > +\n> > +\t\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n> > +\t\t\t\t\t&head_oid, NULL) ||\n> > +\t\t    !(head_commit = lookup_commit_reference_gently(revs.repo,\n> > +\t\t\t\t\t\t\t     &head_oid, 1)))\n> > +\t\t\tdie(\"no such ref: HEAD\");\n> > +\n> > +\t\tadd_pending_object(&revs, &head_commit->object, \"HEAD\");\n> > +\t}\n> \n> With this patch, if I have a bare repo without a HEAD I now get:\n> \n>     fatal: no such ref: HEAD\n\nThis is the same error message as in a regular repo without HEAD.\nThat's good: it's consistent, and it tells what the actual problem is.\n\nThough perhaps too terse and the error message from 'git log' would\napply just as well and be more friendly:\n\n  fatal: your current branch 'master' does not have any commits yet\n\n> Instead of:\n> \n>     fatal: this operation must be run in a work tree\n> \n> Both are bad & misleading, perhaps we can instead say something like:\n> \n>     die(_(\"in a bare repository you must specify a ref to blame from, we tried and failed to implicitly use HEAD\"));\n\nThe point of this patch is that you don't necessarily have to specify\nthe starting ref in a bare repo anymore.\n\n> Along with a test for what we do in bare repos without a HEAD....?\n\nHow can a repo have no HEAD?  Maybe I'm missing something, but I only\nsee the following cases:\n\n  - An empty repo: there is nothing to blame there at all in the first\n    place.\n\n  - An orphan branch in a non-bare repo: there is nothing to blame\n    there.\n\n  - The user is looking for trouble, and ran 'git update-ref -d HEAD',\n    as you mentioned below, or something else with similar results.\n    \"If it hurts, don't it\" applies.\n\n  - Some sort of repo corruption that left the refs in a sorry state.\n    The user has more serious problems than the error message from\n    'git blame'.\n\nSo I doubt that any of these cases are worth dealing with and testing\nspecifically in a bare repo.\n\n> \n> >\n> >  \tinit_scoreboard(&sb);\n> >  \tsb.revs = &revs;\n> > diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\n> > index 6da48a2e0a..d933af5714 100644\n> > --- a/t/annotate-tests.sh\n> > +++ b/t/annotate-tests.sh\n> > @@ -68,6 +68,14 @@ test_expect_success 'blame 1 author' '\n> >  \tcheck_count A 2\n> >  '\n> >\n> > +test_expect_success 'blame in a bare repo without starting commit' '\n> > +\tgit clone --bare . bare.git &&\n> > +\t(\n> > +\t\tcd bare.git &&\n> > +\t\tcheck_count A 2\n> > +\t)\n> \n> ....just 'git update-ref -d HEAD` after this and a test for 'git blame\n> <file>' here would test bare without HEAD.\n> \n> >  test_expect_success 'blame by tag objects' '\n> >  \tgit tag -m \"test tag\" testTag &&\n> >  \tgit tag -m \"test tag #2\" testTag2 testTag &&\n"},{"id":"373427","messageId":"875zroa46y.fsf@evledraar.gmail.com","threadId":"50892","inReplyTo":"20190408143046.GF8796@szeder.dev","subject":"Re: [PATCH] blame: default to HEAD in a bare repo when no start commit is given","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2019-04-08T15:48:21Z","receivedAt":"2019-04-08T15:48:26Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Apr 08 2019, SZEDER Gábor wrote:\n\n> On Mon, Apr 08, 2019 at 02:44:59PM +0200, Ævar Arnfjörð Bjarmason wrote:\n>>\n>> On Mon, Apr 08 2019, SZEDER Gábor wrote:\n>>\n>> > When 'git blame' is invoked without specifying the commit to start\n>> > blaming from, it starts from the given file's state in the work tree.\n>> > However, when invoked in a bare repository without a start commit,\n>> > then there is no work tree state to start from, and it dies with the\n>> > following error message:\n>> >\n>> >   $ git rev-parse --is-bare-repository\n>> >   true\n>> >   $ git blame file.c\n>> >   fatal: this operation must be run in a work tree\n>> >\n>> > This is misleading, because it implies that 'git blame' doesn't work\n>> > in bare repositories at all, but it does, in fact, work just fine when\n>> > it is given a commit to start from.\n>> >\n>> > We could improve the error message, of course, but let's just default\n>> > to HEAD in a bare repository instead, as most likely that is what the\n>> > user wanted anyway (if they wanted to start from an other commit, then\n>> > they would have specified that in the first place).\n>> >\n>> > 'git annotate' is just a thin wrapper around 'git blame', so in the\n>> > same situation it printed the same misleading error message, and this\n>> > patch fixes it, too.\n>> >\n>> > Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n>>\n>> There was the explicit decision not to fall back to HEAD in 1cfe77333f\n>> (\"git-blame: no rev means start from the working tree file.\",\n>> 2007-01-30). This change makes sense to me, but perhaps some discussion\n>> or reference to the previous commit is warranted?\n>\n> I don't think so, because that doesn't apply here, since it doesn't\n> really make much sense to talk about a working tree file in a bare\n> repo.\n\nI mean for context in the sense that the current error we display we\nhaven't always shown, and explicitly started doing in that commit (but\nfor another purpose...).\n\n>> Although from skimming the thread from back then it seems to be \"not\n>> HEAD but working tree file\", not \"let's not use HEAD in bare repos\".\n>>\n>> >  builtin/blame.c     | 13 +++++++++++++\n>> >  t/annotate-tests.sh |  8 ++++++++\n>> >  2 files changed, 21 insertions(+)\n>> >\n>> > diff --git a/builtin/blame.c b/builtin/blame.c\n>> > index 177c1022a0..21cde57e71 100644\n>> > --- a/builtin/blame.c\n>> > +++ b/builtin/blame.c\n>> > @@ -27,6 +27,7 @@\n>> >  #include \"object-store.h\"\n>> >  #include \"blame.h\"\n>> >  #include \"string-list.h\"\n>> > +#include \"refs.h\"\n>> >\n>> >  static char blame_usage[] = N_(\"git blame [<options>] [<rev-opts>] [<rev>] [--] <file>\");\n>> >\n>> > @@ -993,6 +994,18 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n>> >\n>> >  \trevs.disable_stdin = 1;\n>> >  \tsetup_revisions(argc, argv, &revs, NULL);\n>> > +\tif (!revs.pending.nr && is_bare_repository()) {\n>> > +\t\tstruct commit *head_commit;\n>> > +\t\tstruct object_id head_oid;\n>> > +\n>> > +\t\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n>> > +\t\t\t\t\t&head_oid, NULL) ||\n>> > +\t\t    !(head_commit = lookup_commit_reference_gently(revs.repo,\n>> > +\t\t\t\t\t\t\t     &head_oid, 1)))\n>> > +\t\t\tdie(\"no such ref: HEAD\");\n>> > +\n>> > +\t\tadd_pending_object(&revs, &head_commit->object, \"HEAD\");\n>> > +\t}\n>>\n>> With this patch, if I have a bare repo without a HEAD I now get:\n>>\n>>     fatal: no such ref: HEAD\n>\n> This is the same error message as in a regular repo without HEAD.\n> That's good: it's consistent, and it tells what the actual problem is.\n>\n> Though perhaps too terse and the error message from 'git log' would\n> apply just as well and be more friendly:\n>\n>   fatal: your current branch 'master' does not have any commits yet\n>\n>> Instead of:\n>>\n>>     fatal: this operation must be run in a work tree\n>>\n>> Both are bad & misleading, perhaps we can instead say something like:\n>>\n>>     die(_(\"in a bare repository you must specify a ref to blame from, we tried and failed to implicitly use HEAD\"));\n\nYeah, I missed that it's the same message as with no HEAD in a non-bare\nrepo. Makes sense.\n\n> The point of this patch is that you don't necessarily have to specify\n> the starting ref in a bare repo anymore.\n>\n>> Along with a test for what we do in bare repos without a HEAD....?\n>\n> How can a repo have no HEAD?  Maybe I'm missing something, but I only\n> see the following cases:\n>\n>   - An empty repo: there is nothing to blame there at all in the first\n>     place.\n>\n>   - An orphan branch in a non-bare repo: there is nothing to blame\n>     there.\n>\n>   - The user is looking for trouble, and ran 'git update-ref -d HEAD',\n>     as you mentioned below, or something else with similar results.\n>     \"If it hurts, don't it\" applies.\n>\n>   - Some sort of repo corruption that left the refs in a sorry state.\n>     The user has more serious problems than the error message from\n>     'git blame'.\n>\n> So I doubt that any of these cases are worth dealing with and testing\n> specifically in a bare repo.\n\nIf you setup a repo to manually fetch refspecs you can end up without a\nHEAD but still be able to 'blame' stuff. I don't think that happens with\nnon-bare, but does with bare. E.g. I set up some server-side \"blame\"\nthat supports the \"master\" branch of several repos like that in the\npast, and just plain 'git blame' throws the old message.\n\nSo maybe since we're checking is_bare_repository() it's worth improving\nthe error while we're at it, or at least testing that bare & non-bare do\nthe same thing.\n\n>>\n>> >\n>> >  \tinit_scoreboard(&sb);\n>> >  \tsb.revs = &revs;\n>> > diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\n>> > index 6da48a2e0a..d933af5714 100644\n>> > --- a/t/annotate-tests.sh\n>> > +++ b/t/annotate-tests.sh\n>> > @@ -68,6 +68,14 @@ test_expect_success 'blame 1 author' '\n>> >  \tcheck_count A 2\n>> >  '\n>> >\n>> > +test_expect_success 'blame in a bare repo without starting commit' '\n>> > +\tgit clone --bare . bare.git &&\n>> > +\t(\n>> > +\t\tcd bare.git &&\n>> > +\t\tcheck_count A 2\n>> > +\t)\n>>\n>> ....just 'git update-ref -d HEAD` after this and a test for 'git blame\n>> <file>' here would test bare without HEAD.\n>>\n>> >  test_expect_success 'blame by tag objects' '\n>> >  \tgit tag -m \"test tag\" testTag &&\n>> >  \tgit tag -m \"test tag #2\" testTag2 testTag &&\n"},{"id":"373466","messageId":"xmqqmukz7fzy.fsf@gitster-ct.c.googlers.com","threadId":"50892","inReplyTo":"878swkacok.fsf@evledraar.gmail.com","subject":"Re: [PATCH] blame: default to HEAD in a bare repo when no start commit is given","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-04-09T08:13:53Z","receivedAt":"2019-04-09T08:13:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> There was the explicit decision not to fall back to HEAD in 1cfe77333f\n> (\"git-blame: no rev means start from the working tree file.\",\n> 2007-01-30). This change makes sense to me, but perhaps some discussion\n> or reference to the previous commit is warranted?\n\nYes.  That is a good suggestion.  I do not think the original meant\nto say that no rev should error out in a bare repository because no\nrev must mean 'start from te working tree' and there is no way to\nsatisify it in a bare repository.\n\n> Both are bad & misleading, perhaps we can instead say something like:\n>\n>     die(_(\"in a bare repository you must specify a ref to blame from, we tried and failed to implicitly use HEAD\"));\n\nSounds like an easy-to-understand message, albeit way too looong.\n\n> Along with a test for what we do in bare repos without a HEAD....?\n> ...\n> ....just 'git update-ref -d HEAD` after this and a test for 'git blame\n> <file>' here would test bare without HEAD.\n\nThat's a cute way to bring us on an unborn branch, but let's not\npromote it too much.  Doing so while on detached HEAD will render\nyour repository corrupt.\n"}]}