git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] blame: default to HEAD in a bare repo when no start commit is given

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Apr 8, 2019, 00:42 UTC
Message-ID
<CAPig+cQJUEEZ1=bG2WFLCXHpO6D2h36Bhz0c=zTsyjB5Oc4piQ@mail.gmail.com>
In-Reply-To
<20190407234327.25617-1-szeder.dev@gmail.com>
On Sun, Apr 7, 2019 at 7:43 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:
Show 19 quoted lines
> [...]
> 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).
> [...]
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
> diff --git a/builtin/blame.c b/builtin/blame.c
> @@ -993,6 +994,18 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
> +       if (!revs.pending.nr && is_bare_repository()) {
> +               struct commit *head_commit;
> +               struct object_id head_oid;
> +
> +               if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
> +                                       &head_oid, NULL) ||
> +                   !(head_commit = lookup_commit_reference_gently(revs.repo,
> +                                                            &head_oid, 1)))
> +                       die("no such ref: HEAD");
This source file is already mostly internationalized, so perhaps:
    die(_("no such ref: %s"), "HEAD");
> +               add_pending_object(&revs, &head_commit->object, "HEAD");
> +       }
Previous: SZEDER GáborNext: Ævar Arnfjörð Bjarmason
Message 2 of 6 in “blame: default to HEAD in a bare repo when no start commit is given”
  1. blame: default to HEAD in a bare repo when no start commit is givenSZEDER Gábor, Apr 7, 2019
  2. Eric SunshineApr 8, 2019
  3. Ævar Arnfjörð BjarmasonApr 8, 2019
  4. SZEDER GáborApr 8, 2019
  5. Ævar Arnfjörð BjarmasonApr 8, 2019
  6. Junio C HamanoApr 9, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.