summaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2009-09-05 04:55:37 -0400
committerJunio C Hamano <gitster@pobox.com>2009-09-05 23:16:31 -0700
commit6f15787181a163e158c6fee1d79085b97692ac2f (patch)
treea86a4f7b10bc564c40edc0b57306ec0f2f8f7a94 /builtin-commit.c
parentdd2be243d62260d4c825c22fdd2f61a7da12de22 (diff)
downloadgit-6f15787181a163e158c6fee1d79085b97692ac2f.tar.gz
status: add --porcelain output format
The "short" format was added to "git status" recently to provide a less verbose way of looking at the same information. This has two practical uses: 1. Users who want a more dense display of the information. 2. Scripts which want to parse the information and need a stable, easy-to-parse interface. For now, the "--short" format covers both of those uses. However, as time goes on, users of (1) may want additional format tweaks, or for "git status" to change its behavior based on configuration variables. Those wishes will be at odds with (2), which wants to stability for scripts. This patch introduces a separate --porcelain option early to avoid problems later on. Right now the --short and --porcelain outputs are identical. However, as time goes on, we will have the freedom to customize --short for human consumption while keeping --porcelain stable. 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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index aa4a358799..ffdee31bbf 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -995,12 +995,16 @@ int cmd_status(int argc, const char **argv, const char *prefix)
static enum {
STATUS_FORMAT_LONG,
STATUS_FORMAT_SHORT,
+ STATUS_FORMAT_PORCELAIN,
} status_format = STATUS_FORMAT_LONG;
unsigned char sha1[20];
static struct option builtin_status_options[] = {
OPT__VERBOSE(&verbose),
OPT_SET_INT('s', "short", &status_format,
"show status concisely", STATUS_FORMAT_SHORT),
+ OPT_SET_INT(0, "porcelain", &status_format,
+ "show porcelain output format",
+ STATUS_FORMAT_PORCELAIN),
OPT_BOOLEAN('z', "null", &null_termination,
"terminate entries with NUL"),
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
@@ -1011,7 +1015,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
};
if (null_termination && status_format == STATUS_FORMAT_LONG)
- status_format = STATUS_FORMAT_SHORT;
+ status_format = STATUS_FORMAT_PORCELAIN;
wt_status_prepare(&s);
git_config(git_status_config, &s);
@@ -1032,6 +1036,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
case STATUS_FORMAT_SHORT:
short_print(&s, null_termination);
break;
+ case STATUS_FORMAT_PORCELAIN:
+ short_print(&s, null_termination);
+ break;
case STATUS_FORMAT_LONG:
s.verbose = verbose;
if (s.relative_paths)