t9501-gitweb-standalone-http-status.sh: use the $( ... ) construct for command substitution
[gitweb.git] / environment.c
index 23a38e4b14f61f078bec3d7c2a5e5bcc5d505d9d..2da7fe2e06ff38b977209d44b7404c93358430af 100644 (file)
@@ -144,11 +144,8 @@ static char *git_path_from_env(const char *envvar, const char *git_dir,
                               const char *path, int *fromenv)
 {
        const char *value = getenv(envvar);
-       if (!value) {
-               char *buf = xmalloc(strlen(git_dir) + strlen(path) + 2);
-               sprintf(buf, "%s/%s", git_dir, path);
-               return buf;
-       }
+       if (!value)
+               return xstrfmt("%s/%s", git_dir, path);
        if (fromenv)
                *fromenv = 1;
        return xstrdup(value);