Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
| -rw-r--r-- | source/scan-tree.c | 8 |
1 file changed, 6 insertions, 2 deletions
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. |
