From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Jeff King <peff@peff.net>
Subject: [PATCH 2/2] format-patch: introduce format.defaultTo
Date: Mon, 6 Jan 2014 22:48:52 +0530 [thread overview]
Message-ID: <1389028732-27760-3-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1389028732-27760-1-git-send-email-artagnon@gmail.com>
A very common workflow for preparing patches involves working off a
topic branch and generating patches against 'master' to send off to the
maintainer. However, a plain
$ git format-patch -o outgoing
is a no-op on a topic branch, and the user has to remember to specify
'master' explicitly everytime. Save the user the extra keystrokes by
introducing format.defaultTo which can contain the name of a branch
against which to base patches.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
Documentation/config.txt | 4 ++++
builtin/log.c | 7 +++++++
contrib/completion/git-completion.bash | 1 +
t/t4014-format-patch.sh | 10 ++++++++++
4 files changed, 22 insertions(+)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index a405806..b90abd1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1135,6 +1135,10 @@ format.coverLetter::
format-patch is invoked, but in addition can be set to "auto", to
generate a cover-letter only when there's more than one patch.
+format.defaultTo::
+ The name of a branch against which to generate patches by
+ default. You'd usually want this to be 'master'.
+
filter.<driver>.clean::
The command which is used to convert the content of a worktree
file to a blob upon checkin. See linkgit:gitattributes[5] for
diff --git a/builtin/log.c b/builtin/log.c
index b97373d..ebc419e 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -674,6 +674,7 @@ static int thread;
static int do_signoff;
static const char *signature = git_version_string;
static int config_cover_letter;
+static const char *config_defaultto;
enum {
COVER_UNSET,
@@ -750,6 +751,8 @@ static int git_format_config(const char *var, const char *value, void *cb)
config_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;
return 0;
}
+ if (!strcmp(var, "format.defaultto"))
+ return git_config_string(&config_defaultto, var, value);
return git_log_config(var, value, cb);
}
@@ -1324,6 +1327,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
die (_("--subject-prefix and -k are mutually exclusive."));
rev.preserve_subject = keep_subject;
+ if (argc < 2 && config_defaultto) {
+ argv[1] = config_defaultto;
+ argc++;
+ }
argc = setup_revisions(argc, argv, &rev, &s_r_opt);
if (argc > 1)
die (_("unrecognized argument: %s"), argv[1]);
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 39b81f7..75699d4 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1992,6 +1992,7 @@ _git_config ()
format.attach
format.cc
format.coverLetter
+ format.defaultTo
format.headers
format.numbered
format.pretty
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 73194b2..46c0337 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1370,4 +1370,14 @@ test_expect_success 'cover letter auto user override' '
test_line_count = 2 list
'
+test_expect_success 'defaultTo side' '
+ mkdir -p tmp &&
+ test_when_finished "rm -rf tmp;
+ git config --unset format.defaultTo" &&
+
+ git config format.defaultTo side &&
+ git format-patch -o tmp >list &&
+ test_line_count = 3 list
+'
+
test_done
--
1.8.5.2.229.g4448466.dirty
next prev parent reply other threads:[~2014-01-06 17:19 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-06 17:18 [PATCH 0/2] Minor convinience feature: format.defaultTo Ramkumar Ramachandra
2014-01-06 17:18 ` [PATCH 1/2] completion: complete format.coverLetter Ramkumar Ramachandra
2014-01-07 11:24 ` Ramkumar Ramachandra
2014-01-06 17:18 ` Ramkumar Ramachandra [this message]
2014-01-06 18:35 ` [PATCH 2/2] format-patch: introduce format.defaultTo Jonathan Nieder
2014-01-06 19:02 ` Ramkumar Ramachandra
2014-01-06 18:42 ` Junio C Hamano
2014-01-06 18:49 ` Ramkumar Ramachandra
2014-01-06 20:06 ` Junio C Hamano
2014-01-06 20:18 ` Jeff King
2014-01-06 20:29 ` John Szakmeister
2014-01-06 20:42 ` Jonathan Nieder
2014-01-06 21:13 ` John Szakmeister
2014-01-06 21:37 ` Junio C Hamano
2014-01-06 22:54 ` Ramkumar Ramachandra
2014-01-07 0:42 ` John Szakmeister
2014-01-07 16:47 ` Ramkumar Ramachandra
2014-01-06 20:43 ` Jeff King
2014-01-06 20:38 ` Junio C Hamano
2014-01-06 20:55 ` Jeff King
2014-01-06 21:21 ` Junio C Hamano
2014-01-06 22:10 ` Ramkumar Ramachandra
2014-01-07 20:56 ` Jeff King
2014-01-07 21:07 ` Junio C Hamano
2014-01-07 21:24 ` Jeff King
2014-01-07 22:06 ` Junio C Hamano
2014-01-07 22:17 ` Jeff King
2014-01-07 22:27 ` Junio C Hamano
2014-04-10 19:17 ` Felipe Contreras
2014-01-06 21:59 ` Ramkumar Ramachandra
2014-01-06 22:22 ` Junio C Hamano
2014-01-06 22:47 ` Ramkumar Ramachandra
2014-01-07 21:06 ` Jeff King
2014-01-07 21:25 ` Ramkumar Ramachandra
2014-01-07 21:30 ` Jeff King
2014-04-10 19:20 ` Felipe Contreras
2014-01-06 17:25 ` [PATCH 0/2] Minor convinience feature: format.defaultTo Ramkumar Ramachandra
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=1389028732-27760-3-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).