summaryrefslogtreecommitdiff
path: root/mailmap.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-03-22 21:00:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-03-22 21:00:22 (GMT)
commit204333b015a663a339c855c72b86034203b66a6a (patch)
tree04978dc454e8dbb85ab406e1149934ff9c99e158 /mailmap.c
parent98164e9585e02e31dcf1377a553efe076c15f8c6 (diff)
parentadcd9f54729e41aa63c3a1b80a19023ea8ede203 (diff)
downloadgit-204333b015a663a339c855c72b86034203b66a6a.zip
git-204333b015a663a339c855c72b86034203b66a6a.tar.gz
git-204333b015a663a339c855c72b86034203b66a6a.tar.bz2
Merge branch 'jk/open-dotgitx-with-nofollow'
It does not make sense to make ".gitattributes", ".gitignore" and ".mailmap" symlinks, as they are supposed to be usable from the object store (think: bare repositories where HEAD:.mailmap etc. are used). When these files are symbolic links, we used to read the contents of the files pointed by them by mistake, which has been corrected. * jk/open-dotgitx-with-nofollow: mailmap: do not respect symlinks for in-tree .mailmap exclude: do not respect symlinks for in-tree .gitignore attr: do not respect symlinks for in-tree .gitattributes exclude: add flags parameter to add_patterns() attr: convert "macro_ok" into a flags field add open_nofollow() helper
Diffstat (limited to 'mailmap.c')
-rw-r--r--mailmap.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/mailmap.c b/mailmap.c
index 183a2f6..d1f7c0d 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -157,20 +157,30 @@ static void read_mailmap_line(struct string_list *map, char *buffer)
add_mapping(map, name1, email1, name2, email2);
}
-static int read_mailmap_file(struct string_list *map, const char *filename)
+/* Flags for read_mailmap_file() */
+#define MAILMAP_NOFOLLOW (1<<0)
+
+static int read_mailmap_file(struct string_list *map, const char *filename,
+ unsigned flags)
{
char buffer[1024];
FILE *f;
+ int fd;
if (!filename)
return 0;
- f = fopen(filename, "r");
- if (!f) {
+ if (flags & MAILMAP_NOFOLLOW)
+ fd = open_nofollow(filename, O_RDONLY);
+ else
+ fd = open(filename, O_RDONLY);
+
+ if (fd < 0) {
if (errno == ENOENT)
return 0;
return error_errno("unable to open mailmap at %s", filename);
}
+ f = xfdopen(fd, "r");
while (fgets(buffer, sizeof(buffer), f) != NULL)
read_mailmap_line(map, buffer);
@@ -226,10 +236,12 @@ int read_mailmap(struct string_list *map)
git_mailmap_blob = "HEAD:.mailmap";
if (!startup_info->have_repository || !is_bare_repository())
- err |= read_mailmap_file(map, ".mailmap");
+ err |= read_mailmap_file(map, ".mailmap",
+ startup_info->have_repository ?
+ MAILMAP_NOFOLLOW : 0);
if (startup_info->have_repository)
err |= read_mailmap_blob(map, git_mailmap_blob);
- err |= read_mailmap_file(map, git_mailmap_file);
+ err |= read_mailmap_file(map, git_mailmap_file, 0);
return err;
}