diff options
author | Matthieu Moy <Matthieu.Moy@imag.fr> | 2013-09-12 12:50:04 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-09-12 11:45:03 -0700 |
commit | 5c25dfaa794c7bbfa1b4d234b10f94ee371b1db0 (patch) | |
tree | c2a62bf666908fca08aedff3229a3b4703b68d28 /builtin/commit.c | |
parent | e230c568c4b9a991e3175e5f65171a566fd8e39c (diff) | |
download | git-5c25dfaa794c7bbfa1b4d234b10f94ee371b1db0.tar.gz git-5c25dfaa794c7bbfa1b4d234b10f94ee371b1db0.tar.xz |
commit: factor status configuration is a helper function
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r-- | builtin/commit.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index 10acc53f8..94512c05b 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); @@ -1492,11 +1497,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)) |