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

Re: [PATCH] mailmap: only look for .mailmap in work tree

From
Jeff King <peff@peff.net>
Date
Feb 10, 2021, 20:31 UTC
Message-ID
<YCRCu60a2MuGooiL@coredump.intra.peff.net>
In-Reply-To
<xmqqblcr3crp.fsf@gitster.c.googlers.com>
On Wed, Feb 10, 2021 at 12:10:02PM -0800, Junio C Hamano wrote:
Show 11 quoted lines
> >> OK.  Do we know at this point that cwd is always/already at the root
> >> level of the working tree?
> >
> > I think so. If we're in a non-bare repository, we'd have chdir'd during
> > the setup/discovery steps. At any rate, this patch could not possibly be
> > making such a situation _worse_, as we were previously reading it
> > unconditionally.
> 
> But the point of the patch is to ensure that we only read from the
> top of the working tree---I wanted to make sure that we previously
> weren't reading it from any subdirectory the command started.

Ah, I see. I assume that part already worked, or people would be complaining that "git shortlog" does not work from a subdirectory. :)

It doesn't look like we actually cover that in the test suite, though. We can do that pretty easily:

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index bf7a8add53..93caf9a46d 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -923,4 +923,13 @@ test_expect_success 'shortlog on stdin respects mailmap from repo' '
 	test_cmp expect actual
 '
 
+test_expect_success 'find top-level mailmap from subdir' '
+	git clone loc-bare loc-wt &&
+	cp loc-bare/.mailmap loc-wt &&
+	mkdir loc-wt/subdir &&
+	git -C loc-wt/subdir log -1 --format=%aE >actual &&
+	echo new@example.com >expect &&
+	test_cmp expect actual
+'
+
 test_done

I'll resend the whole thing with that squashed in, plus Eric's
documentation suggestion.

-Peff
Previous: Junio C HamanoNext: Jeff King
Message 11 of 12 in “I've noticed the command `git --git-dir=<path> shortlog`”
  1. SURAFeb 1, 2021
  2. Jeff KingFeb 5, 2021
  3. Bryan TurnerFeb 5, 2021
  4. mailmap: only look for .mailmap in work treeJeff King, Feb 9, 2021
  5. Eric SunshineFeb 9, 2021
  6. Junio C HamanoFeb 9, 2021
  7. Jeff KingFeb 10, 2021
  8. Junio C HamanoFeb 9, 2021
  9. Jeff KingFeb 10, 2021
  10. Junio C HamanoFeb 10, 2021
  11. Jeff KingFeb 10, 2021
  12. Jeff KingFeb 10, 2021

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.