Re: I've noticed the command `git --git-dir=<path> shortlog`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 01, 2021 at 11:05:13AM +0800, SURA wrote:

> $ git clone --bare https://github.com/gitlabhq/gitlabhq.git
> $ git clone https://gitlab.com/gitlab-org/gitaly.git
> 
> $ git --git-dir=./gitlabhq.git shortlog --summary --email --numbered
> --committer HEAD --end-of-options | wc -l
> > 2592
> [...]
> $ cd gitaly
> $ git --git-dir=../gitlabhq.git shortlog --summary --email --numbered
> --committer HEAD --end-of-options | wc -l
> > 2587

I think what's happening is that the second command is using the
.mailmap file found in the working tree of the gitaly repository.

If the first checkout were non-bare, I would say that is the right
behavior (because --git-dir without otherwise specifying the working
tree means that the current directory becomes the working tree, and we
read ".mailmap" out of the top of the working tree). But because it was
cloned with "--bare", it should have the core.bare config set, and will
think there is no working tree at all.

So I do think there is a bug, which is: Git should avoid looking for
".mailmap" in the current directory if we do not have a working tree.
I.e., something like:

diff --git a/mailmap.c b/mailmap.c
index eb77c6e77c..3ea35a2289 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -225,7 +225,8 @@ int read_mailmap(struct string_list *map)
 	if (!git_mailmap_blob && is_bare_repository())
 		git_mailmap_blob = "HEAD:.mailmap";
 
-	err |= read_mailmap_file(map, ".mailmap");
+	if (!is_bare_repository())
+		err |= read_mailmap_file(map, ".mailmap");
 	if (startup_info->have_repository)
 		err |= read_mailmap_blob(map, git_mailmap_blob);
 	err |= read_mailmap_file(map, git_mailmap_file);

It's possible somebody is relying on this in order to read ".mailmap" in
a bare repository, but it seems rather unlikely. And the documentation
says "If the file .mailmap exists at the toplevel of the repository",
which I think pretty clearly means the top of the working tree.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux