From: Junio C Hamano <gitster@pobox.com>
To: Han Young <hanyang.tony@bytedance.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] blame: allow --contents to work with bare repo
Date: Fri, 21 Jul 2023 07:32:46 -0700 [thread overview]
Message-ID: <xmqq8rb9z65t.fsf@gitster.g> (raw)
In-Reply-To: <20230721035758.61956-1-hanyang.tony@bytedance.com> (Han Young's message of "Fri, 21 Jul 2023 11:57:58 +0800")
Han Young <hanyang.tony@bytedance.com> writes:
> The --contents option can be used with git blame to blame the file as if
> it had the contents from the specified file. Since 1a3119ed06c8fbb1c00a6aa3615299252575abab ("blame: allow --contents to work with non-HEAD commit"), the --contents option can work with non-HEAD commit. However, if you try to use --contents in a bare repository, you get the following error:
When using the "show -s --pretty=reference --oneline", abbreviate
the commit object name to a reasonable length (like 8 to 12
hexadecimal digits). Please wrap overlong lines.
I'll fix them up at the receiving end, if there is no other issues
in the patch. Let's read on.
> blame.c | 4 +++-
> t/annotate-tests.sh | 9 +++++++++
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/blame.c b/blame.c
> index d12bd9f97..141756975 100644
> --- a/blame.c
> +++ b/blame.c
> @@ -2806,7 +2806,9 @@ void setup_scoreboard(struct blame_scoreboard *sb,
> parent_oid = &head_oid;
> }
>
> - setup_work_tree();
> + if (!sb->contents_from)
> + setup_work_tree();
> +
> sb->final = fake_working_tree_commit(sb->repo,
> &sb->revs->diffopt,
> sb->path, sb->contents_from,
Thanks.
> diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
> index 2ef70235b..5e21e84f3 100644
> --- a/t/annotate-tests.sh
> +++ b/t/annotate-tests.sh
> @@ -83,6 +83,15 @@ test_expect_success 'blame with --contents' '
> check_count --contents=file A 2
> '
>
> +test_expect_success 'blame with --contents in a bare repo' '
> + git clone --bare . bare-contents.git &&
> + (
> + cd bare-contents.git &&
> + echo "1A quick brown fox jumps over the" >contents &&
> + check_count --contents=contents A 1
> + )
> +'
> +
> test_expect_success 'blame with --contents changed' '
> echo "1A quick brown fox jumps over the" >contents &&
> echo "another lazy dog" >>contents &&
prev parent reply other threads:[~2023-07-21 14:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-19 10:48 [PATCH] blame: allow --contents to work with bare repo 韩仰
2023-07-19 21:21 ` Junio C Hamano
2023-07-21 3:57 ` [PATCH v2] " Han Young
2023-07-21 14:32 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq8rb9z65t.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=hanyang.tony@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).