diff options
author | Jeff King <peff@peff.net> | 2016-07-08 05:06:50 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-07-08 09:47:28 -0700 |
commit | aabbd3f3c9dd17c414100d0e029f8a3d13673ab1 (patch) | |
tree | 2e803c866f90395deac63bf644d47ecb80c0adb0 /t/t4253-am-keep-cr-dos.sh | |
parent | Git 2.9 (diff) | |
download | tgif-aabbd3f3c9dd17c414100d0e029f8a3d13673ab1.tar.xz |
config: fix bogus fd check when setting up default config
Since 9830534 (config --global --edit: create a template
file if needed, 2014-07-25), an edit of the global config
file will try to open() it with O_EXCL, and wants to handle
three cases:
1. We succeeded; the user has no config file, and we
should fill in the default template.
2. We got EEXIST; they have a file already, proceed as usual.
3. We got another error; we should complain.
However, the check for case 1 does "if (fd)", which will
generally _always_ be true (except for the oddball case that
somehow our stdin got closed and opening really did give us
a new descriptor 0).
So in the EEXIST case, we tried to write the default config
anyway! Fortunately, this turns out to be a noop, since we
just end up writing to and closing "-1", which does nothing.
But in case 3, we would fail to notice any other errors, and
just silently continue (given that we don't actually notice
write errors for the template either, it's probably not that
big a deal; we're about to spawn the editor, so it would
notice any problems. But the code is clearly _trying_ to hit
cover this case and failing).
We can fix it easily by using "fd >= 0" for case 1.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4253-am-keep-cr-dos.sh')
0 files changed, 0 insertions, 0 deletions