summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2017-04-20 17:09:09 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-04-20 21:04:15 -0700
commitd9c69644b27eb59fe16c1931580e6fce4abbdc65 (patch)
tree71ecd47a9565debbbfe144c4f3edfe631f905f07 /builtin
parentuse git_path_* helper functions (diff)
downloadtgif-d9c69644b27eb59fe16c1931580e6fce4abbdc65.tar.xz
replace xstrdup(git_path(...)) with git_pathdup(...)
It's more efficient to use git_pathdup(), as it skips an extra copy of the path. And by removing some calls to git_path(), it makes it easier to audit for dangerous uses. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/config.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin/config.c b/builtin/config.c
index 05843a0f96..07fcc2388b 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -599,8 +599,9 @@ int cmd_config(int argc, const char **argv, const char *prefix)
if (given_config_source.blob)
die("editing blobs is not supported");
git_config(git_default_config, NULL);
- config_file = xstrdup(given_config_source.file ?
- given_config_source.file : git_path("config"));
+ config_file = given_config_source.file ?
+ xstrdup(given_config_source.file) :
+ git_pathdup("config");
if (use_global_config) {
int fd = open(config_file, O_CREAT | O_EXCL | O_WRONLY, 0666);
if (fd >= 0) {