summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-04-25 04:28:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-25 04:28:52 (GMT)
commit5d8da91e707668227464c9ba0e74b5fea1ee3b7e (patch)
treeccb39649d719d90a50be186cc51322afbf0cca36 /config.c
parent850e9257525ef2fa13e1d34ccce4e6b73085bb4e (diff)
parent05e293c1ac63295fcfe1b8fd9533fcdb012d5f03 (diff)
downloadgit-5d8da91e707668227464c9ba0e74b5fea1ee3b7e.zip
git-5d8da91e707668227464c9ba0e74b5fea1ee3b7e.tar.gz
git-5d8da91e707668227464c9ba0e74b5fea1ee3b7e.tar.bz2
Merge branch 'jk/flockfile-stdio'
Code clean-up. * jk/flockfile-stdio: config: move flockfile() closer to unlocked functions
Diffstat (limited to 'config.c')
-rw-r--r--config.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/config.c b/config.c
index c698988..563853c 100644
--- a/config.c
+++ b/config.c
@@ -1426,6 +1426,7 @@ static int do_config_from_file(config_fn_t fn,
void *data)
{
struct config_source top;
+ int ret;
top.u.file = f;
top.origin_type = origin_type;
@@ -1436,7 +1437,10 @@ static int do_config_from_file(config_fn_t fn,
top.do_ungetc = config_file_ungetc;
top.do_ftell = config_file_ftell;
- return do_config_from(&top, fn, data);
+ flockfile(f);
+ ret = do_config_from(&top, fn, data);
+ funlockfile(f);
+ return ret;
}
static int git_config_from_stdin(config_fn_t fn, void *data)
@@ -1451,9 +1455,7 @@ int git_config_from_file(config_fn_t fn, const char *filename, void *data)
f = fopen_or_warn(filename, "r");
if (f) {
- flockfile(f);
ret = do_config_from_file(fn, CONFIG_ORIGIN_FILE, filename, filename, f, data);
- funlockfile(f);
fclose(f);
}
return ret;