From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org, gitster@pobox.com
Cc: javierdo1@gmail.com, jrnieder@gmail.com, judge.packham@gmail.com,
peff@peff.net, Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH v2 1/3] commit: factor status configuration is a helper function
Date: Thu, 12 Sep 2013 12:50:04 +0200 [thread overview]
Message-ID: <1378983006-3980-1-git-send-email-Matthieu.Moy@imag.fr> (raw)
cmd_commit and cmd_status use very similar code to initialize the
wt_status structure. Factor this code into a function to ensure future
changes will keep both versions consistent.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
New patch, as discussed with Peff.
builtin/commit.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 60812b5..dc957a9 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -163,6 +163,14 @@ static void determine_whence(struct wt_status *s)
s->whence = whence;
}
+static void status_init_config(struct wt_status *s, config_fn_t fn)
+{
+ wt_status_prepare(s);
+ gitmodules_config();
+ git_config(fn, s);
+ determine_whence(s);
+}
+
static void rollback_index_files(void)
{
switch (commit_style) {
@@ -1246,10 +1254,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
if (argc == 2 && !strcmp(argv[1], "-h"))
usage_with_options(builtin_status_usage, builtin_status_options);
- wt_status_prepare(&s);
- gitmodules_config();
- git_config(git_status_config, &s);
- determine_whence(&s);
+ status_init_config(&s, git_status_config);
argc = parse_options(argc, argv, prefix,
builtin_status_options,
builtin_status_usage, 0);
@@ -1490,11 +1495,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (argc == 2 && !strcmp(argv[1], "-h"))
usage_with_options(builtin_commit_usage, builtin_commit_options);
- wt_status_prepare(&s);
- gitmodules_config();
- git_config(git_commit_config, &s);
+ status_init_config(&s, git_commit_config);
status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
- determine_whence(&s);
s.colopts = 0;
if (get_sha1("HEAD", sha1))
--
1.8.4.8.g834017f
next reply other threads:[~2013-09-12 10:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-12 10:50 Matthieu Moy [this message]
2013-09-12 10:50 ` [PATCH v2 2/3] wt-status: turn advice_status_hints into a field of wt_status Matthieu Moy
2013-09-12 10:50 ` [PATCH v2 3/3] commit: disable status hints when writing to COMMIT_EDITMSG Matthieu Moy
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=1378983006-3980-1-git-send-email-Matthieu.Moy@imag.fr \
--to=matthieu.moy@imag.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=javierdo1@gmail.com \
--cc=jrnieder@gmail.com \
--cc=judge.packham@gmail.com \
--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).