From 0eaf543c6842cd9a202b3d755157fcfa1e2dbf2d Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 15:56:33 -0700 Subject: Log an owner lookup only when it fails getpwuid leaves errno alone for a uid with no passwd entry, so a scan logged "Unable to read the owner" with "Success" as the reason for each repository such a uid owns. --- source/scan-tree.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/scan-tree.c') diff --git a/source/scan-tree.c b/source/scan-tree.c index f29738c..ec991e0 100644 --- a/source/scan-tree.c +++ b/source/scan-tree.c @@ -219,9 +219,13 @@ static void add_repo(const char *base, struct strbuf *path) current_repo->url[urllen] = '\0'; } if (!current_repo->owner) { + // A uid with no passwd entry is no error, and getpwuid tells + // the two apart only by setting errno on a failure. + errno = 0; if (!(pwd = getpwuid(st.st_uid))) { - fprintf(stderr, "[cgit] Unable to read the owner of %s: %s (%d)\n", - path->buf, strerror(errno), errno); + if (errno) + fprintf(stderr, "[cgit] Unable to read the owner of %s: %s (%d)\n", + path->buf, strerror(errno), errno); } else { // A gecos field puts the owner's name in front of a // comma separated list of office and phone details. -- cgit