Teach fmt-patch about --keep-subject
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>maint
parent
596524b33d
commit
8ac80a5701
|
@ -78,7 +78,7 @@ static int istitlechar(char c)
|
||||||
static FILE *realstdout = NULL;
|
static FILE *realstdout = NULL;
|
||||||
static char *output_directory = NULL;
|
static char *output_directory = NULL;
|
||||||
|
|
||||||
static void reopen_stdout(struct commit *commit, int nr)
|
static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
|
||||||
{
|
{
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
char *sol;
|
char *sol;
|
||||||
|
@ -100,7 +100,7 @@ static void reopen_stdout(struct commit *commit, int nr)
|
||||||
|
|
||||||
sol += 2;
|
sol += 2;
|
||||||
/* strip [PATCH] or [PATCH blabla] */
|
/* strip [PATCH] or [PATCH blabla] */
|
||||||
if (!strncmp(sol, "[PATCH", 6)) {
|
if (!keep_subject && !strncmp(sol, "[PATCH", 6)) {
|
||||||
char *eos = strchr(sol + 6, ']');
|
char *eos = strchr(sol + 6, ']');
|
||||||
if (eos) {
|
if (eos) {
|
||||||
while (isspace(*eos))
|
while (isspace(*eos))
|
||||||
|
@ -138,6 +138,7 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
|
||||||
int nr = 0, total, i, j;
|
int nr = 0, total, i, j;
|
||||||
int use_stdout = 0;
|
int use_stdout = 0;
|
||||||
int numbered = 0;
|
int numbered = 0;
|
||||||
|
int keep_subject = 0;
|
||||||
|
|
||||||
init_revisions(&rev);
|
init_revisions(&rev);
|
||||||
rev.commit_format = CMIT_FMT_EMAIL;
|
rev.commit_format = CMIT_FMT_EMAIL;
|
||||||
|
@ -160,7 +161,11 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
|
||||||
else if (!strcmp(argv[i], "-n") ||
|
else if (!strcmp(argv[i], "-n") ||
|
||||||
!strcmp(argv[i], "--numbered"))
|
!strcmp(argv[i], "--numbered"))
|
||||||
numbered = 1;
|
numbered = 1;
|
||||||
else if (!strcmp(argv[i], "-o")) {
|
else if (!strcmp(argv[i], "-k") ||
|
||||||
|
!strcmp(argv[i], "--keep-subject")) {
|
||||||
|
keep_subject = 1;
|
||||||
|
rev.total = -1;
|
||||||
|
} else if (!strcmp(argv[i], "-o")) {
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
die ("Which directory?");
|
die ("Which directory?");
|
||||||
if (mkdir(argv[i + 1], 0777) < 0 && errno != EEXIST)
|
if (mkdir(argv[i + 1], 0777) < 0 && errno != EEXIST)
|
||||||
|
@ -173,6 +178,9 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
|
||||||
}
|
}
|
||||||
argc = j;
|
argc = j;
|
||||||
|
|
||||||
|
if (numbered && keep_subject < 0)
|
||||||
|
die ("-n and -k are mutually exclusive.");
|
||||||
|
|
||||||
argc = setup_revisions(argc, argv, &rev, "HEAD");
|
argc = setup_revisions(argc, argv, &rev, "HEAD");
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
die ("unrecognized argument: %s", argv[1]);
|
die ("unrecognized argument: %s", argv[1]);
|
||||||
|
@ -197,7 +205,7 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
|
||||||
commit = list[nr];
|
commit = list[nr];
|
||||||
rev.nr = total - nr;
|
rev.nr = total - nr;
|
||||||
if (!use_stdout)
|
if (!use_stdout)
|
||||||
reopen_stdout(commit, rev.nr);
|
reopen_stdout(commit, rev.nr, keep_subject);
|
||||||
shown = log_tree_commit(&rev, commit);
|
shown = log_tree_commit(&rev, commit);
|
||||||
free(commit->buffer);
|
free(commit->buffer);
|
||||||
commit->buffer = NULL;
|
commit->buffer = NULL;
|
||||||
|
|
|
@ -46,8 +46,11 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
|
||||||
"Subject: [PATCH %d/%d] ",
|
"Subject: [PATCH %d/%d] ",
|
||||||
opt->nr, opt->total);
|
opt->nr, opt->total);
|
||||||
subject = buffer;
|
subject = buffer;
|
||||||
} else
|
} else if (opt->total == 0)
|
||||||
subject = "Subject: [PATCH] ";
|
subject = "Subject: [PATCH] ";
|
||||||
|
else
|
||||||
|
subject = "Subject: ";
|
||||||
|
|
||||||
printf("From %s Thu Apr 7 15:13:13 2005\n",
|
printf("From %s Thu Apr 7 15:13:13 2005\n",
|
||||||
sha1_to_hex(commit->object.sha1));
|
sha1_to_hex(commit->object.sha1));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue