__attribute__((format (printf, 3, 4)));
extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
__attribute__((format (printf, 2, 3)));
+extern void strbuf_git_path_submodule(struct strbuf *sb, const char *path,
+ const char *fmt, ...)
+ __attribute__((format (printf, 3, 4)));
extern char *git_pathdup(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));
extern char *mkpathdup(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));
+extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)
+ __attribute__((format (printf, 2, 3)));
extern void report_linked_checkout_garbage(void);
return cleanup_path(pathname->buf);
}
-const char *git_path_submodule(const char *path, const char *fmt, ...)
+static void do_submodule_path(struct strbuf *buf, const char *path,
+ const char *fmt, va_list args)
{
- struct strbuf *buf = get_pathname();
const char *git_dir;
- va_list args;
strbuf_addstr(buf, path);
if (buf->len && buf->buf[buf->len - 1] != '/')
}
strbuf_addch(buf, '/');
- va_start(args, fmt);
strbuf_vaddf(buf, fmt, args);
- va_end(args);
strbuf_cleanup_path(buf);
+}
+
+const char *git_path_submodule(const char *path, const char *fmt, ...)
+{
+ va_list args;
+ struct strbuf *buf = get_pathname();
+ va_start(args, fmt);
+ do_submodule_path(buf, path, fmt, args);
+ va_end(args);
return buf->buf;
}
+char *git_pathdup_submodule(const char *path, const char *fmt, ...)
+{
+ va_list args;
+ struct strbuf buf = STRBUF_INIT;
+ va_start(args, fmt);
+ do_submodule_path(&buf, path, fmt, args);
+ va_end(args);
+ return strbuf_detach(&buf, NULL);
+}
+
+void strbuf_git_path_submodule(struct strbuf *buf, const char *path,
+ const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ do_submodule_path(buf, path, fmt, args);
+ va_end(args);
+}
+
int validate_headref(const char *path)
{
struct stat st;