Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
setup_git_env: use git_pathdup instead of xmalloc + sprintf
author
Jeff King
<peff@peff.net>
Thu, 19 Jun 2014 21:28:00 +0000
(17:28 -0400)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 19 Jun 2014 22:20:55 +0000
(15:20 -0700)
This is shorter, harder to get wrong, and more clearly
captures the intent.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
environment.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
b2724c8
)
diff --git
a/environment.c
b/environment.c
index 4dac5e9edd75499ccf52debc847807d2fc180730..4de7b812ad2220fc43ad41dedb0c9b594f61e286 100644
(file)
--- a/
environment.c
+++ b/
environment.c
@@
-135,15
+135,11
@@
static void setup_git_env(void)
gitfile = read_gitfile(git_dir);
git_dir = xstrdup(gitfile ? gitfile : git_dir);
git_object_dir = getenv(DB_ENVIRONMENT);
gitfile = read_gitfile(git_dir);
git_dir = xstrdup(gitfile ? gitfile : git_dir);
git_object_dir = getenv(DB_ENVIRONMENT);
- if (!git_object_dir) {
- git_object_dir = xmalloc(strlen(git_dir) + 9);
- sprintf(git_object_dir, "%s/objects", git_dir);
- }
+ if (!git_object_dir)
+ git_object_dir = git_pathdup("objects");
git_index_file = getenv(INDEX_ENVIRONMENT);
git_index_file = getenv(INDEX_ENVIRONMENT);
- if (!git_index_file) {
- git_index_file = xmalloc(strlen(git_dir) + 7);
- sprintf(git_index_file, "%s/index", git_dir);
- }
+ if (!git_index_file)
+ git_index_file = git_pathdup("index");
git_graft_file = getenv(GRAFT_ENVIRONMENT);
if (!git_graft_file)
git_graft_file = git_pathdup("info/grafts");
git_graft_file = getenv(GRAFT_ENVIRONMENT);
if (!git_graft_file)
git_graft_file = git_pathdup("info/grafts");