Skip to content

Commit d9c6964

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ca03e06 commit d9c6964

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

builtin/config.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,9 @@ int cmd_config(int argc, const char **argv, const char *prefix)
599599
if (given_config_source.blob)
600600
die("editing blobs is not supported");
601601
git_config(git_default_config, NULL);
602-
config_file = xstrdup(given_config_source.file ?
603-
given_config_source.file : git_path("config"));
602+
config_file = given_config_source.file ?
603+
xstrdup(given_config_source.file) :
604+
git_pathdup("config");
604605
if (use_global_config) {
605606
int fd = open(config_file, O_CREAT | O_EXCL | O_WRONLY, 0666);
606607
if (fd >= 0) {

fast-import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3203,7 +3203,7 @@ static char* make_fast_import_path(const char *path)
32033203
{
32043204
if (!relative_marks_paths || is_absolute_path(path))
32053205
return xstrdup(path);
3206-
return xstrdup(git_path("info/fast-import/%s", path));
3206+
return git_pathdup("info/fast-import/%s", path);
32073207
}
32083208

32093209
static void option_import_marks(const char *marks,

0 commit comments

Comments
 (0)