From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: Tanay Abhra <tanayabh@gmail.com>
Cc: git@vger.kernel.org, Ramkumar Ramachandra <artagnon@gmail.com>
Subject: Re: [PATCH v8 1/2] add `config_set` API for caching config-like files
Date: Tue, 15 Jul 2014 13:32:54 +0200 [thread overview]
Message-ID: <vpqiomy3li1.fsf@anie.imag.fr> (raw)
In-Reply-To: <53C50859.5070209@gmail.com> (Tanay Abhra's message of "Tue, 15 Jul 2014 16:24:17 +0530")
Tanay Abhra <tanayabh@gmail.com> writes:
> I checked the whole codebase and in all of the cases if they cannot read a file
> they return -1 and continue running.
More precisely: in git_config_from_file, any fopen failure results in
"return -1". But in git_config_early (one caller of
git_config_from_file()), the file is checked before access, e.g.:
if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0)) {
ret += git_config_from_file(fn, git_etc_gitconfig(),
data);
found += 1;
}
Essentially, if a config file does not exist, it's skipped (obviously
desirable), but if some really weird error occur (if "err == ENOENT ||
err == ENOTDIR || ((flag & ACCESS_EACCES_OK) && err == EACCES" is false,
from access_eacces_ok() in wrapper.c), then the process dies.
"Permission denied" errors are allowed for user-wide config, but not for
others. Read the log for commit 4698c8feb for more details.
Anyway, this is the part of the code you're not touching.
(I actually consider it as a bug that "git config --file no-such-file
foo.bar" and "git config --file unreadable-file foo.bar" fail without
error message, but your commit does not change this).
> I think if the file is unreadable. we must continue running as no harm has been
> done yet, worse is parsing a file with wrong syntax which can cause reading
> wrong config values. So the decision to die on syntax error sounds alright
> to me.
In the case of git_config_check_init(), I think it makes sense to die,
because file accesses are protected with access_or_die(), so the return
value can be negative only if something really went wrong.
If you chose not to die, then you should check the return value in the
callers of git_config_check_init().
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
next prev parent reply other threads:[~2014-07-15 11:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-11 3:34 [PATCH v8 0/3] git config cache & special querying api utilizing the cache Tanay Abhra
2014-07-11 3:34 ` [PATCH v8 1/2] add `config_set` API for caching config-like files Tanay Abhra
2014-07-11 14:21 ` Matthieu Moy
2014-07-11 16:31 ` Tanay Abhra
2014-07-11 16:59 ` Matthieu Moy
2014-07-15 10:54 ` Tanay Abhra
2014-07-15 11:32 ` Matthieu Moy [this message]
2014-07-11 17:25 ` Junio C Hamano
2014-07-11 3:34 ` [PATCH v8 2/2] test-config: add tests for the config_set API Tanay Abhra
2014-07-11 14:24 ` Matthieu Moy
2014-07-11 14:27 ` [fixup PATCH 1/2] Call configset_clear Matthieu Moy
2014-07-11 14:27 ` [PATCH 2/2] Better tests for error cases Matthieu Moy
2014-07-11 18:18 ` [PATCH v8 2/2] test-config: add tests for the config_set API Junio C Hamano
2014-07-15 11:10 ` Tanay Abhra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpqiomy3li1.fsf@anie.imag.fr \
--to=matthieu.moy@grenoble-inp.fr \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=tanayabh@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.