diff options
author | Jeff King <peff@peff.net> | 2012-05-07 15:35:03 -0400 |
---|---|---|
committer | Jeff King <peff@peff.net> | 2012-05-08 04:57:42 -0400 |
commit | 4d2292e9a90465cbfa23f1c170c11423d11830df (patch) | |
tree | 6d0520696bf47710ff46d19f5d46d08b8de7f633 /builtin | |
parent | 5410ae422b0f3cfe604d393addcd13526e940112 (diff) | |
download | git-4d2292e9a90465cbfa23f1c170c11423d11830df.tar.gz git-4d2292e9a90465cbfa23f1c170c11423d11830df.tar.xz |
status: refactor colopts handling
The current code reads the config and command-line options
into a separate "colopts" variable, and then copies the
contents of that variable into the "struct wt_status". We
can eliminate the extra variable and copy just write
straight into the wt_status struct.
This simplifies the "status" code a little bit.
Unfortunately, it makes the "commit" code one line more
complex; a side effect of the separate variable was that
"commit" did not copy the colopts variable, so any
column.status configuration had no effect.
The result still ends up cleaner, though. In the previous
version, it was unclear whether commit simply forgot to copy
the colopt variable, or whether it was intentional. Now it
explicitly turns off column options. Furthermore, if commit
later learns to respect column.status, this will make the
end result simpler. I punted on just adding that feature
now, because it was sufficiently non-obvious that it should
not go into a refactoring patch.
Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/commit.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index b15e3119d..a2ec73d73 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -89,7 +89,6 @@ static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship; static int no_post_rewrite, allow_empty_message; static char *untracked_files_arg, *force_date, *ignore_submodule_arg; static char *sign_commit; -static unsigned int colopts; /* * The default commit message cleanup mode will remove the lines @@ -1121,7 +1120,7 @@ static int git_status_config(const char *k, const char *v, void *cb) struct wt_status *s = cb; if (!prefixcmp(k, "column.")) - return git_column_config(k, v, "status", &colopts); + return git_column_config(k, v, "status", &s->colopts); if (!strcmp(k, "status.submodulesummary")) { int is_bool; s->submodule_summary = git_config_bool_or_int(k, v, &is_bool); @@ -1187,7 +1186,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) { OPTION_STRING, 0, "ignore-submodules", &ignore_submodule_arg, "when", "ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" }, - OPT_COLUMN(0, "column", &colopts, "list untracked files in columns"), + OPT_COLUMN(0, "column", &s.colopts, "list untracked files in columns"), OPT_END(), }; @@ -1201,8 +1200,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, builtin_status_options, builtin_status_usage, 0); - finalize_colopts(&colopts, -1); - s.colopts = colopts; + finalize_colopts(&s.colopts, -1); if (s.null_termination && status_format == STATUS_FORMAT_LONG) status_format = STATUS_FORMAT_PORCELAIN; @@ -1439,6 +1437,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) wt_status_prepare(&s); git_config(git_commit_config, &s); determine_whence(&s); + s.colopts = 0; if (get_sha1("HEAD", sha1)) current_head = NULL; |