From: Andy Whitcroft <apw@shadowen.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
git@vger.kernel.org, Josh Boyer <jwboyer@gmail.com>
Subject: Re: [PATCH] Introduce 'git-format-patch --suffix=patch'
Date: Wed, 17 Jan 2007 19:20:48 +0000 [thread overview]
Message-ID: <45AE7710.40503@shadowen.org> (raw)
In-Reply-To: <7v4pqpsbre.fsf_-_@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
> The default can also be changed with "format.suffix" configuration.
>
> Signed-off-by: Junio C Hamano <junkio@cox.net>
> ---
>
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > Why not
> >
> > static const char *file_extension = ".txt"
> >
> > Hmm?
>
> Let's do this instead. By the way, there is a bug in the
> configuration parsing for format.headers from commit 20ff0680,
> which needs to be check NULLness of the value the same way as
> this one deals with format.suffix, which I've already fixed in
> my tree.
>
> Documentation/git-format-patch.txt | 13 ++++++++++++-
> builtin-log.c | 19 ++++++++++++++++---
> 2 files changed, 28 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
> index 67425dc..34abd2f 100644
> --- a/Documentation/git-format-patch.txt
> +++ b/Documentation/git-format-patch.txt
> @@ -11,7 +11,7 @@ SYNOPSIS
> [verse]
> 'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach] [--thread]
> [-s | --signoff] [--diff-options] [--start-number <n>]
> - [--in-reply-to=Message-Id]
> + [--in-reply-to=Message-Id] [--suffix=<sfx>]
> <since>[..<until>]
>
> DESCRIPTION
> @@ -78,6 +78,12 @@ OPTIONS
> reply to the given Message-Id, which avoids breaking threads to
> provide a new patch series.
>
> +--suffix=<sfx>::
> + Instead of using `txt` as the suffix for generated
> + filenames, use specifed suffix. A common alternative is
> + `--suffix=patch`.
> +
> +
> CONFIGURATION
> -------------
> You can specify extra mail header lines to be added to each
> @@ -86,6 +92,11 @@ message in the repository configuration as follows:
> [format]
> headers = "Organization: git-foo\n"
>
> +You can specify default suffix used:
> +
> +[format]
> + suffix = patch
> +
>
> EXAMPLES
> --------
> diff --git a/builtin-log.c b/builtin-log.c
> index a59b4ac..04e3144 100644
> --- a/builtin-log.c
> +++ b/builtin-log.c
> @@ -197,6 +197,7 @@ static int istitlechar(char c)
>
> static char *extra_headers = NULL;
> static int extra_headers_size = 0;
> +static const char *fmt_patch_suffix = "txt";
>
> static int git_format_config(const char *var, const char *value)
> {
> @@ -208,6 +209,12 @@ static int git_format_config(const char *var, const char *value)
> strcat(extra_headers, value);
> return 0;
> }
> + if (!strcmp(var, "format.suffix")) {
> + if (!value)
> + die("format.suffix without value");
> + fmt_patch_suffix = xstrdup(value);
> + return 0;
> + }
> if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
> return 0;
> }
> @@ -223,9 +230,10 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
> char filename[1024];
> char *sol;
> int len = 0;
> + int suffix_len = strlen(fmt_patch_suffix) + 10; /* ., NUL and slop */
>
> if (output_directory) {
> - strlcpy(filename, output_directory, 1010);
> + strlcpy(filename, output_directory, 1000);
> len = strlen(filename);
> if (filename[len - 1] != '/')
> filename[len++] = '/';
> @@ -249,7 +257,10 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
> }
> }
>
> - for (j = 0; len < 1024 - 6 && sol[j] && sol[j] != '\n'; j++) {
> + for (j = 0;
> + len < sizeof(filename) - suffix_len &&
> + sol[j] && sol[j] != '\n';
> + j++) {
> if (istitlechar(sol[j])) {
> if (space) {
> filename[len++] = '-';
> @@ -265,7 +276,7 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
> while (filename[len - 1] == '.' || filename[len - 1] == '-')
> len--;
> }
> - strcpy(filename + len, ".txt");
> + sprintf(filename + len, ".%s", fmt_patch_suffix);
This doesn't give us any possibility of not having a suffix. Can we not
include the . in the suffix here so that we can specify it as "".
> fprintf(realstdout, "%s\n", filename);
> freopen(filename, "w", stdout);
> }
> @@ -436,6 +447,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
> die("Need a Message-Id for --in-reply-to");
> in_reply_to = argv[i];
> }
> + else if (!strncmp(argv[i], "--suffix=", 9))
> + fmt_patch_suffix = argv[i] + 9;
> else
> argv[j++] = argv[i];
> }
-apw
next prev parent reply other threads:[~2007-01-17 19:21 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-17 13:10 [RFC] Add a suffix option to git-format-patch Josh Boyer
2007-01-17 13:49 ` Johannes Schindelin
2007-01-17 14:50 ` Josh Boyer
2007-01-17 16:39 ` Horst H. von Brand
2007-01-17 19:18 ` [PATCH] Introduce 'git-format-patch --suffix=patch' Junio C Hamano
2007-01-17 19:20 ` Andy Whitcroft [this message]
2007-01-17 19:27 ` Junio C Hamano
2007-01-17 19:51 ` Brian Gernhardt
2007-01-17 19:57 ` Junio C Hamano
2007-01-17 20:08 ` Brian Gernhardt
2007-01-17 20:22 ` [PATCH] Make format-patch --suffix="" not add any suffix Brian Gernhardt
2007-01-18 1:11 ` [PATCH] Introduce 'git-format-patch --suffix=patch' Johannes Schindelin
2007-01-17 15:43 ` [RFC] Add a suffix option to git-format-patch David Kågedal
2007-01-17 16:57 ` Andreas Ericsson
2007-01-17 17:05 ` Johannes Schindelin
2007-01-17 17:33 ` Junio C Hamano
2007-01-17 18:15 ` David Kågedal
2007-01-17 20:18 ` Josh Boyer
2007-01-17 20:20 ` Josh Boyer
[not found] ` <7vsle9p8pg.fsf@assigned-by-dhcp.cox.net>
2007-01-18 0:06 ` [PATCH/POLL] git-format-patch: the default suffix is now .patch, not .txt Junio C Hamano
2007-01-18 1:06 ` Johannes Schindelin
2007-01-18 7:59 ` Alex Riesen
2007-01-18 8:06 ` Shawn O. Pearce
2007-01-18 8:18 ` Alex Riesen
2007-01-18 9:10 ` Junio C Hamano
2007-01-18 9:21 ` Alex Riesen
2007-01-18 8:43 ` Junio C Hamano
2007-01-18 9:35 ` Alex Riesen
2007-01-18 11:52 ` Josh Boyer
2007-01-18 13:33 ` Johannes Schindelin
2007-01-18 13:46 ` Alex Riesen
2007-01-18 13:40 ` Alex Riesen
2007-01-18 14:10 ` Andreas Ericsson
2007-01-18 14:15 ` Johannes Schindelin
2007-01-18 14:41 ` Alex Riesen
2007-01-18 14:49 ` Johannes Schindelin
2007-01-18 14:53 ` Alex Riesen
2007-01-18 15:16 ` Johannes Schindelin
2007-01-18 15:37 ` Alex Riesen
2007-01-18 15:42 ` Josh Boyer
2007-01-18 20:03 ` Johannes Schindelin
2007-01-18 20:12 ` Josh Boyer
2007-01-18 15:26 ` Shawn O. Pearce
2007-01-18 15:52 ` Alex Riesen
2007-01-18 19:29 ` Steven Grimm
2007-01-18 19:57 ` Johannes Schindelin
2007-01-18 16:09 ` Johannes Sixt
2007-01-19 10:11 ` Jakub Narebski
2007-01-18 15:42 ` Shawn O. Pearce
2007-01-18 16:05 ` Alex Riesen
2007-01-18 16:29 ` Andreas Ericsson
2007-01-18 16:51 ` Shawn O. Pearce
2007-01-18 17:03 ` Andreas Ericsson
2007-01-18 19:30 ` Martin Langhoff
2007-01-18 19:19 ` Martin Langhoff
2007-01-18 12:40 ` Andreas Ericsson
2007-01-18 15:10 ` Lukas Sandström
2007-01-18 15:29 ` Brian Gernhardt
2007-01-18 9:57 ` Alexandre Julliard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45AE7710.40503@shadowen.org \
--to=apw@shadowen.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=jwboyer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.