Re: [PATCH v10 2/3] interpret-trailers: add own-identity option

3 messages, 2 authors, 2021-03-20 · open the first message on its own page

Re: [PATCH v10 2/3] interpret-trailers: add own-identity option

From: Junio C Hamano <hidden>
Date: 2021-03-20 11:29:53

Jeff King [off-list ref] writes:
If I understand Junio's suggestion correctly, it is very similar to how
"commit --author" works. See how it calls find_author_by_nickname(),
which finds the first commit matching the name, and then pulls out the
full name from format_commit_message().
Yup.

But I have to warn readers that it would not be a sane approach to
simply expose find_author_by_nickname() from builtin/commit.c as if
it is a generally reusable helper function.  In a very limited
context of "git commit", what the helper does is OK to run a single
revision traversal without cleaning the parsed commit objects and
object flag bits after finding a single commit.

But generally, it would not be an approach that would scale (e.g. I
do not know if we can expect to be able to call the helper function
twice and get sensible results out of it).

Re: [PATCH v10 2/3] interpret-trailers: add own-identity option

From: ZheNing Hu <hidden>
Date: 2021-03-20 11:30:20

In actually ,
@@ -1071,6 +1071,7 @@ static const char *find_author_by_nickname(const
char *name)
                strbuf_release(&buf);
                format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
                clear_mailmap(&mailmap);
+               reset_revision_walk();
                return strbuf_detach(&buf, NULL);
        }

then we can reuse this function.

But I think I can give find_author_by_nickname another arg for choice if we want
 `reset_revision_walk()`.

Thanks, Junio and Jeff.

Re: [PATCH v10 2/3] interpret-trailers: add own-identity option

From: ZheNing Hu <hidden>
Date: 2021-03-20 11:40:33

Junio C Hamano [off-list ref] 于2021年3月20日周六 下午1:50写道:
Jeff King [off-list ref] writes:
quoted
If I understand Junio's suggestion correctly, it is very similar to how
"commit --author" works. See how it calls find_author_by_nickname(),
which finds the first commit matching the name, and then pulls out the
full name from format_commit_message().
Yup.

But I have to warn readers that it would not be a sane approach to
simply expose find_author_by_nickname() from builtin/commit.c as if
it is a generally reusable helper function.  In a very limited
context of "git commit", what the helper does is OK to run a single
revision traversal without cleaning the parsed commit objects and
object flag bits after finding a single commit.

But generally, it would not be an approach that would scale (e.g. I
do not know if we can expect to be able to call the helper function
twice and get sensible results out of it).
Hi, Jeff and Junio,

`find_author_by_nickname` is indeed a good way to find
 the `author <email>` in the "last" commit that matches
the specified name, but after testing, `find_author_by_nickname` is
as Junio say, it is not reusable(use it twice, git will call die), but why?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help