summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 958a478)
raw | patch | inline | side by side (parent: 958a478)
author | Alex Riesen <raa.lkml@gmail.com> | |
Mon, 27 Oct 2008 10:17:51 +0000 (11:17 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 31 Oct 2008 00:30:55 +0000 (17:30 -0700) |
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h | patch | blob | history | |
path.c | patch | blob | history |
index 3d5a08ea81e927d59d0c50d26ad416d9baa9e7f7..eaacd6dd9fae9aac5f55614d099b0838c13f90cf 100644 (file)
--- a/cache.h
+++ b/cache.h
__attribute__((format (printf, 3, 4)));
extern char *git_snpath(char *buf, size_t n, const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
+extern char *git_pathdup(const char *fmt, ...)
+ __attribute__((format (printf, 1, 2)));
/* Return a statically allocated filename matching the sha1 signature */
extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
index 85ab28a0f1f0ff6276c587ec6d5be7716d8e0c83..092ce57190cc75882a3766c9aee1df719da8a3d6 100644 (file)
--- a/path.c
+++ b/path.c
return cleanup_path(buf);
}
-char *git_snpath(char *buf, size_t n, const char *fmt, ...)
+static char *git_vsnpath(char *buf, size_t n, const char *fmt, va_list args)
{
const char *git_dir = get_git_dir();
- va_list args;
size_t len;
len = strlen(git_dir);
memcpy(buf, git_dir, len);
if (len && !is_dir_sep(git_dir[len-1]))
buf[len++] = '/';
- va_start(args, fmt);
len += vsnprintf(buf + len, n - len, fmt, args);
- va_end(args);
if (len >= n)
goto bad;
return cleanup_path(buf);
return buf;
}
+char *git_snpath(char *buf, size_t n, const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ (void)git_vsnpath(buf, n, fmt, args);
+ va_end(args);
+ return buf;
+}
+
+char *git_pathdup(const char *fmt, ...)
+{
+ char path[PATH_MAX];
+ va_list args;
+ va_start(args, fmt);
+ (void)git_vsnpath(path, sizeof(path), fmt, args);
+ va_end(args);
+ return xstrdup(path);
+}
+
char *mkpath(const char *fmt, ...)
{
va_list args;