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

[PATCH 4/6] mailmap: do not resolve blobs in a non-repository

From
Jeff King <peff@peff.net>
Date
Mar 5, 2016, 22:13 UTC
Message-ID
<20160305221329.GD31508@sigill.intra.peff.net>
In-Reply-To
<20160305220829.GA31316@sigill.intra.peff.net>

The mailmap code may be triggered outside of a repository by git-shortlog. There is no point in looking up a name like "HEAD:.mailmap" there; without a repository, we have no refs.

This is unlikely to matter much in practice for the current code, as we would simply fail to find the ref. But as the refs code learns about new backends, this is more important; without a repository, we do not even know which backend to look at.

Signed-off-by: Jeff King <peff@peff.net>
---
I debated whether ".mailmap" in the $PWD should be respected in a
non-repository. If it were 2005, I think I could go either way. But it's
not, and changing it now seems like a pointless and unnecessary
regression, even if there is some grounds to argue for it.
 mailmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mailmap.c b/mailmap.c
index f4a0f1c..9726237 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -250,7 +250,8 @@ int read_mailmap(struct string_list *map, char **repo_abbrev)
 		git_mailmap_blob = "HEAD:.mailmap";
 
 	err |= read_mailmap_file(map, ".mailmap", repo_abbrev);
-	err |= read_mailmap_blob(map, git_mailmap_blob, repo_abbrev);
+	if (startup_info->have_repository)
+		err |= read_mailmap_blob(map, git_mailmap_blob, repo_abbrev);
 	err |= read_mailmap_file(map, git_mailmap_file, repo_abbrev);
 	return err;
 }
-- 
2.8.0.rc1.318.g2193183
Previous: Jeff KingNext: Jeff King
Message 5 of 10 in “avoid touching ref code in non-repositories”
  1. 0/6 avoid touching ref code in non-repositoriesJeff King, Mar 5, 2016
  2. 1/6 setup: make startup_info available everywhereJeff King, Mar 5, 2016
  3. 2/6 setup: set startup_info->have_repository more reliablyJeff King, Mar 5, 2016
  4. 3/6 remote: don't resolve HEAD in non-repositoryJeff King, Mar 5, 2016
  5. 4/6 mailmap: do not resolve blobs in a non-repositoryJeff King, Mar 5, 2016
  6. 5/6 grep: turn off gitlink detection for --no-indexJeff King, Mar 5, 2016
  7. Junio C HamanoMar 7, 2016
  8. 5/6 grep: turn off gitlink detection for --no-indexJeff King, Mar 7, 2016
  9. 6/6 use setup_git_directory() in test-* programsJeff King, Mar 5, 2016
  10. Junio C HamanoMar 7, 2016

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.