]> git.ipfire.org Git - thirdparty/git.git/blobdiff - strbuf.h
config: do not leak excludes_file
[thirdparty/git.git] / strbuf.h
index 96512f85b316e7f3b56df94cd1e7912dbb6020f0..f6dbb9681ee768221e707a39c37dc0a00f63b95d 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -160,7 +160,7 @@ void strbuf_grow(struct strbuf *sb, size_t amount);
 static inline void strbuf_setlen(struct strbuf *sb, size_t len)
 {
        if (len > (sb->alloc ? sb->alloc - 1 : 0))
-               die("BUG: strbuf_setlen() beyond buffer");
+               BUG("strbuf_setlen() beyond buffer");
        sb->len = len;
        if (sb->buf != strbuf_slopbuf)
                sb->buf[len] = '\0';
@@ -664,6 +664,17 @@ int launch_sequence_editor(const char *path, struct strbuf *buffer,
 int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
                              const char *const *env);
 
+/*
+ * Remove the filename from the provided path string. If the path
+ * contains a trailing separator, then the path is considered a directory
+ * and nothing is modified.
+ *
+ * Examples:
+ * - "/path/to/file" -> "/path/to/"
+ * - "/path/to/dir/" -> "/path/to/dir/"
+ */
+void strbuf_strip_file_from_path(struct strbuf *sb);
+
 void strbuf_add_lines(struct strbuf *sb,
                      const char *prefix,
                      const char *buf,