format-patch: move get_patch_filename() into log-tree
authorStephen Boyd <bebarino@gmail.com>
Mon, 23 Mar 2009 02:14:04 +0000 (19:14 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Mar 2009 04:42:05 +0000 (21:42 -0700)
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-log.c
log-tree.c
log-tree.h

index 6a27ce6..4f438db 100644 (file)
@@ -417,7 +417,6 @@ int cmd_log(int argc, const char **argv, const char *prefix)
 }
 
 /* format-patch */
-#define FORMAT_PATCH_NAME_MAX 64
 
 static const char *fmt_patch_suffix = ".patch";
 static int numbered = 0;
@@ -512,29 +511,6 @@ static int git_format_config(const char *var, const char *value, void *cb)
        return git_log_config(var, value, cb);
 }
 
-
-static void get_patch_filename(struct commit *commit, int nr,
-                              const char *suffix, struct strbuf *buf)
-{
-       int suffix_len = strlen(suffix) + 1;
-       int start_len = buf->len;
-
-       strbuf_addf(buf, commit ? "%04d-" : "%d", nr);
-       if (commit) {
-               format_commit_message(commit, "%f", buf, DATE_NORMAL);
-               /*
-                * Replace characters at the end with the suffix if the
-                * filename is too long
-                */
-               if (buf->len + suffix_len > FORMAT_PATCH_NAME_MAX + start_len)
-                       strbuf_splice(buf,
-                               start_len + FORMAT_PATCH_NAME_MAX - suffix_len,
-                               suffix_len, suffix, suffix_len);
-               else
-                       strbuf_addstr(buf, suffix);
-       }
-}
-
 static FILE *realstdout = NULL;
 static const char *output_directory = NULL;
 static int outdir_offset;
index 9565c18..aee9995 100644 (file)
@@ -179,6 +179,28 @@ static int has_non_ascii(const char *s)
        return 0;
 }
 
+void get_patch_filename(struct commit *commit, int nr, const char *suffix,
+                       struct strbuf *buf)
+{
+       int suffix_len = strlen(suffix) + 1;
+       int start_len = buf->len;
+
+       strbuf_addf(buf, commit ? "%04d-" : "%d", nr);
+       if (commit) {
+               format_commit_message(commit, "%f", buf, DATE_NORMAL);
+               /*
+                * Replace characters at the end with the suffix if the
+                * filename is too long
+                */
+               if (buf->len + suffix_len > FORMAT_PATCH_NAME_MAX + start_len)
+                       strbuf_splice(buf,
+                               start_len + FORMAT_PATCH_NAME_MAX - suffix_len,
+                               suffix_len, suffix, suffix_len);
+               else
+                       strbuf_addstr(buf, suffix);
+       }
+}
+
 void log_write_email_headers(struct rev_info *opt, const char *name,
                             const char **subject_p,
                             const char **extra_headers_p,
index f2a9008..78dc5be 100644 (file)
@@ -19,4 +19,8 @@ void log_write_email_headers(struct rev_info *opt, const char *name,
                             int *need_8bit_cte_p);
 void load_ref_decorations(void);
 
+#define FORMAT_PATCH_NAME_MAX 64
+void get_patch_filename(struct commit *commit, int nr, const char *suffix,
+                       struct strbuf *buf);
+
 #endif