@@ -18,6 +18,7 @@
#include "refs.h"
#include "fmt-merge-msg.h"
#include "commit.h"
+#include "strbuf.h"
#include "strvec.h"
#include "object-file.h"
#include "object-store-ll.h"
@@ -416,3 +417,34 @@ int print_sha1_ellipsis(void)
}
return cached_result;
}
+
+void strbuf_commented_addf(struct strbuf *sb,
+ const char *fmt, ...)
+{
+ va_list params;
+ struct strbuf buf = STRBUF_INIT;
+ int incomplete_line = sb->len && sb->buf[sb->len - 1] != '\n';
+
+ va_start(params, fmt);
+ strbuf_vaddf(&buf, fmt, params);
+ va_end(params);
+
+ strbuf_add_commented_lines(sb, buf.buf, buf.len);
+ if (incomplete_line)
+ sb->buf[--sb->len] = '\0';
+
+ strbuf_release(&buf);
+}
+
+void strbuf_add_commented_lines(struct strbuf *out,
+ const char *buf, size_t size)
+{
+ static char prefix1[3];
+ static char prefix2[2];
+
+ if (prefix1[0] != comment_line_char) {
+ xsnprintf(prefix1, sizeof(prefix1), "%c ", comment_line_char);
+ xsnprintf(prefix2, sizeof(prefix2), "%c", comment_line_char);
+ }
+ strbuf_add_lines_varied_prefix(out, prefix1, prefix2, buf, size);
+}
@@ -229,4 +229,18 @@ extern const char *excludes_file;
*/
int print_sha1_ellipsis(void);
+/**
+ * Add a formatted string prepended by a comment character and a
+ * blank to the buffer.
+ */
+__attribute__((format (printf, 2, 3)))
+void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...);
+
+/**
+ * Add a NUL-terminated string to the buffer. Each line will be prepended
+ * by a comment character and a blank.
+ */
+void strbuf_add_commented_lines(struct strbuf *out,
+ const char *buf, size_t size);
+
#endif
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "environment.h"
#include "gettext.h"
#include "hex-ll.h"
#include "strbuf.h"
@@ -360,37 +359,6 @@ void strbuf_add_lines_varied_prefix(struct strbuf *sb,
strbuf_complete_line(sb);
}
-void strbuf_add_commented_lines(struct strbuf *out,
- const char *buf, size_t size)
-{
- static char prefix1[3];
- static char prefix2[2];
-
- if (prefix1[0] != comment_line_char) {
- xsnprintf(prefix1, sizeof(prefix1), "%c ", comment_line_char);
- xsnprintf(prefix2, sizeof(prefix2), "%c", comment_line_char);
- }
- strbuf_add_lines_varied_prefix(out, prefix1, prefix2, buf, size);
-}
-
-void strbuf_commented_addf(struct strbuf *sb,
- const char *fmt, ...)
-{
- va_list params;
- struct strbuf buf = STRBUF_INIT;
- int incomplete_line = sb->len && sb->buf[sb->len - 1] != '\n';
-
- va_start(params, fmt);
- strbuf_vaddf(&buf, fmt, params);
- va_end(params);
-
- strbuf_add_commented_lines(sb, buf.buf, buf.len);
- if (incomplete_line)
- sb->buf[--sb->len] = '\0';
-
- strbuf_release(&buf);
-}
-
void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap)
{
int len;
@@ -282,14 +282,6 @@ void strbuf_remove(struct strbuf *sb, size_t pos, size_t len);
void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
const void *data, size_t data_len);
-/**
- * Add a NUL-terminated string to the buffer. Each line will be prepended
- * by a comment character and a blank.
- */
-void strbuf_add_commented_lines(struct strbuf *out,
- const char *buf, size_t size);
-
-
/**
* Add data of given length to the buffer.
*/
@@ -373,13 +365,6 @@ void strbuf_humanise_rate(struct strbuf *buf, off_t bytes);
__attribute__((format (printf,2,3)))
void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
-/**
- * Add a formatted string prepended by a comment character and a
- * blank to the buffer.
- */
-__attribute__((format (printf, 2, 3)))
-void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...);
-
__attribute__((format (printf,2,0)))
void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
This eliminates the dependency from strbuf to environment. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> --- environment.c | 32 ++++++++++++++++++++++++++++++++ environment.h | 14 ++++++++++++++ strbuf.c | 32 -------------------------------- strbuf.h | 15 --------------- 4 files changed, 46 insertions(+), 47 deletions(-)