On Fri, Dec 18, 2009 at 08:17:50AM +0100, Carmelo AMOROSO wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
[catching up on mail backlog..]
>Hi All,
>for all git-format-patch users, I would suggest to specify in the
>[PATCH] subject the branch name too {master,nptl,0_9_28,0_9_29,0_9_30}
>to help reviewer/committers
>
>The option to be used with format-patch is --subject-prefix="[PATCH <branch>]"
>
>Sorry for experienced git users that already know this.
I've tried that with both the version packaged by debian as well as
git's master branch and it doesn't seem to work for me? ¹)
I do:
$ git config --replace-all format.subjectprefix 'PATCH <branch>'
# edit something, commit it
$ git format-patch -o ~/foo/ HEAD^..HEAD
and that patch still has "<branch>" in the subject, even when
send-email'ed.
What am i doing wrong?
¹) With attached patchlet against git master it works as you advertise
above. You must be using a similar patch in your git-core?
>
>Cheers,
>Carmelo
>From 4cc3d2a6a67049951abd70c0662f48db65aab255 Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <[email protected]>
Date: Wed, 6 Jan 2010 11:25:47 +0100
Subject: [PATCH master] expand "<branch>" in format.subjectprefix
Replace "<branch>" with the current branch name for
[format]
subjectprefix = PATCH <branch>
A subject-prefix given on the command-line overrides the one given in
the config.
Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
---
builtin-log.c | 44 +++++++++++++++++++++++++++++++++++++++++---
log-tree.c | 6 +++---
revision.h | 2 +-
3 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 41b6df4..ef9c0ef 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -31,6 +31,43 @@ static const char * const builtin_log_usage =
"git log [<options>] [<since>..<until>] [[--] <path>...]\n"
" or: git show [options] <object>...";
+static const char* subst_subject_prefix(void)
+{
+ char *ch;
+
+ /* now expand <branch> */
+ if ((ch = strstr(fmt_patch_subject_prefix, "<branch>")) != NULL)
+ {
+ /* get_or_ask_branch_name(): */
+ struct branch *current_branch;
+ size_t len;
+ int a, b = ch - fmt_patch_subject_prefix;
+ char *branch_name, *new_subject;
+
+ current_branch = branch_get(NULL);
+ if (!current_branch || !current_branch->merge
+ || !current_branch->merge[0]
+ || !current_branch->merge[0]->dst) {
+ branch_name = "(no branch)";
+ } else {
+ branch_name = current_branch->merge[0]->dst;
+ ch = strrchr(branch_name, '/');
+ if (ch)
+ branch_name = ++ch;
+ }
+ len = strlen(branch_name);
+ a = strlen(fmt_patch_subject_prefix) - b - strlen("<branch>");
+ new_subject = xcalloc(1, 1 + b + len + a);
+ memcpy(new_subject, fmt_patch_subject_prefix, b);
+ memcpy(new_subject + b, branch_name, len);
+ memcpy(new_subject + b + len,
+ fmt_patch_subject_prefix + b + strlen("<branch>"),
+ a);
+ *&fmt_patch_subject_prefix = new_subject;
+ }
+ return fmt_patch_subject_prefix;
+}
+
static void cmd_log_init(int argc, const char **argv, const char *prefix,
struct rev_info *rev)
{
@@ -44,7 +81,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
rev->verbose_header = 1;
DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
rev->show_root_diff = default_show_root;
- rev->subject_prefix = fmt_patch_subject_prefix;
+ rev->subject_prefix = &subst_subject_prefix;
DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);
if (default_date_mode)
@@ -795,7 +832,8 @@ static int subject_prefix_callback(const struct option *opt, const char *arg,
int unset)
{
subject_prefix = 1;
- ((struct rev_info *)opt->value)->subject_prefix = arg;
+ //((struct rev_info *)opt->value)->subject_prefix = arg;
+ *&fmt_patch_subject_prefix = arg;
return 0;
}
@@ -962,7 +1000,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.ignore_merges = 1;
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
- rev.subject_prefix = fmt_patch_subject_prefix;
+ rev.subject_prefix = &subst_subject_prefix;
if (default_attach) {
rev.mime_boundary = default_attach;
diff --git a/log-tree.c b/log-tree.c
index 0fdf159..e29f009 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -203,15 +203,15 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
static char buffer[64];
snprintf(buffer, sizeof(buffer),
"Subject: [%s %0*d/%d] ",
- opt->subject_prefix,
+ opt->subject_prefix(),
digits_in_number(opt->total),
opt->nr, opt->total);
subject = buffer;
- } else if (opt->total == 0 && opt->subject_prefix && *opt->subject_prefix) {
+ } else if (opt->total == 0 && opt->subject_prefix()) {
static char buffer[256];
snprintf(buffer, sizeof(buffer),
"Subject: [%s] ",
- opt->subject_prefix);
+ opt->subject_prefix());
subject = buffer;
} else {
subject = "Subject: ";
diff --git a/revision.h b/revision.h
index d368003..ca45c57 100644
--- a/revision.h
+++ b/revision.h
@@ -100,7 +100,7 @@ struct rev_info {
const char *add_signoff;
const char *extra_headers;
const char *log_reencode;
- const char *subject_prefix;
+ const char *(*subject_prefix)(void);
int no_inline;
int show_log_size;
--
1.6.6.103.gbcea0.dirty
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc