aboutsummaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2009-12-07 00:26:25 -0500
committerJunio C Hamano <gitster@pobox.com>2009-12-07 00:41:14 -0800
commit8661768fc9cfdeeaae76693501b82940cfcbedc2 (patch)
tree959b9d978f0f4bab17d73a1e95d396f728ac7b78 /builtin-commit.c
parent4a7cc2fdf39c90e6eff84d30b86490cac2c33705 (diff)
downloadgit-8661768fc9cfdeeaae76693501b82940cfcbedc2.tar.gz
git-8661768fc9cfdeeaae76693501b82940cfcbedc2.tar.xz
status: reduce duplicated setup code
We have three output formats: short, porcelain, and long. The short and long formats respect user-config, and the porcelain one does not. This led to us repeating config-related setup code for the short and long formats. Since the last commit, color config is explicitly cleared when showing the porcelain format. Let's do the same with relative-path configuration, which enables us to hoist the duplicated code from the switch statement in cmd_status. As a bonus, this fixes "commit --dry-run --porcelain", which was unconditionally setting up that configuration, anyway. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-commit.c')
-rw-r--r--builtin-commit.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index ded58984a..b39295fbf 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -964,14 +964,15 @@ int cmd_status(int argc, const char **argv, const char *prefix)
s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
wt_status_collect(&s);
+ if (s.relative_paths)
+ s.prefix = prefix;
+ if (s.use_color == -1)
+ s.use_color = git_use_color_default;
+ if (diff_use_color_default == -1)
+ diff_use_color_default = git_use_color_default;
+
switch (status_format) {
case STATUS_FORMAT_SHORT:
- if (s.relative_paths)
- s.prefix = prefix;
- if (s.use_color == -1)
- s.use_color = git_use_color_default;
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
wt_shortstatus_print(&s, null_termination);
break;
case STATUS_FORMAT_PORCELAIN:
@@ -979,12 +980,6 @@ int cmd_status(int argc, const char **argv, const char *prefix)
break;
case STATUS_FORMAT_LONG:
s.verbose = verbose;
- if (s.relative_paths)
- s.prefix = prefix;
- if (s.use_color == -1)
- s.use_color = git_use_color_default;
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
wt_status_print(&s);
break;
}