aboutsummaryrefslogtreecommitdiff
path: root/builtin-log.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2009-08-15 16:23:12 +0200
committerJunio C Hamano <gitster@pobox.com>2009-08-26 12:05:58 -0700
commitd8526a4c3b31d91b623f698be6ed7552ed4fdc52 (patch)
tree6cf828ca0790e42da48c2fe1fde37eaa3a48cace /builtin-log.c
parent8d9518439595c9d2c601e841a6792d9ee30f9293 (diff)
downloadgit-d8526a4c3b31d91b623f698be6ed7552ed4fdc52.tar.gz
git-d8526a4c3b31d91b623f698be6ed7552ed4fdc52.tar.xz
git-log: allow --decorate[=short|full]
Commit de435ac0 changed the behavior of --decorate from printing the full ref (e.g., "refs/heads/master") to a shorter, more human-readable version (e.g., just "master"). While this is nice for human readers, external tools using the output from "git log" may prefer the full version. This patch introduces an extension to --decorate to allow the caller to specify either the short or the full versions. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-log.c')
-rw-r--r--builtin-log.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/builtin-log.c b/builtin-log.c
index 5f3133079..8d93c1a2a 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -31,6 +31,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
struct rev_info *rev)
{
int i;
+ int decoration_style = 0;
rev->abbrev = DEFAULT_ABBREV;
rev->commit_format = CMIT_FMT_DEFAULT;
@@ -57,13 +58,24 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (!strcmp(arg, "--decorate")) {
- load_ref_decorations();
- rev->show_decorations = 1;
+ decoration_style = DECORATE_SHORT_REFS;
+ } else if (!prefixcmp(arg, "--decorate=")) {
+ const char *v = skip_prefix(arg, "--decorate=");
+ if (!strcmp(v, "full"))
+ decoration_style = DECORATE_FULL_REFS;
+ else if (!strcmp(v, "short"))
+ decoration_style = DECORATE_SHORT_REFS;
+ else
+ die("invalid --decorate option: %s", arg);
} else if (!strcmp(arg, "--source")) {
rev->show_source = 1;
} else
die("unrecognized argument: %s", arg);
}
+ if (decoration_style) {
+ rev->show_decorations = 1;
+ load_ref_decorations(decoration_style);
+ }
}
/*