From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 4/6] replace xstrdup(git_path(...)) with git_pathdup(...)
Date: Thu, 20 Apr 2017 17:09:09 -0400 [thread overview]
Message-ID: <20170420210909.ehy4kim6losllux7@sigill.intra.peff.net> (raw)
In-Reply-To: <20170420210754.bzrnc74dpjs7fgpf@sigill.intra.peff.net>
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>
---
builtin/config.c | 5 +++--
fast-import.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/builtin/config.c b/builtin/config.c
index 4f49a0edb..3407a8b87 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -597,8 +597,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) {
diff --git a/fast-import.c b/fast-import.c
index 1ea3a0860..cf58f875b 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -3202,7 +3202,7 @@ static char* make_fast_import_path(const char *path)
{
if (!relative_marks_paths || is_absolute_path(path))
return xstrdup(path);
- return xstrdup(git_path("info/fast-import/%s", path));
+ return git_pathdup("info/fast-import/%s", path);
}
static void option_import_marks(const char *marks,
--
2.13.0.rc0.363.g8726c260e
next prev parent reply other threads:[~2017-04-20 21:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-20 21:07 [PATCH 0/6] removing more calls to git_path() Jeff King
2017-04-20 21:08 ` [PATCH 1/6] bisect: add git_path_bisect_terms helper Jeff King
2017-04-20 21:08 ` [PATCH 2/6] branch: add edit_description() helper Jeff King
2017-04-20 21:08 ` [PATCH 3/6] use git_path_* helper functions Jeff King
2017-04-20 21:09 ` Jeff King [this message]
2017-04-20 21:09 ` [PATCH 5/6] replace strbuf_addstr(git_path()) with git_path_buf() Jeff King
2017-04-20 21:09 ` [PATCH 6/6] am: drop "dir" parameter from am_state_init Jeff King
2017-04-21 4:05 ` [PATCH 0/6] removing more calls to git_path() Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170420210909.ehy4kim6losllux7@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).