diff options
Diffstat (limited to 'builtin-log.c')
-rw-r--r-- | builtin-log.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/builtin-log.c b/builtin-log.c index 0c2fa0ae2d..25e21ed415 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -27,10 +27,15 @@ static int default_show_root = 1; static const char *fmt_patch_subject_prefix = "PATCH"; static const char *fmt_pretty; +static const char * const builtin_log_usage = + "git log [<options>] [<since>..<until>] [[--] <path>...]\n" + " or: git show [options] <object>..."; + 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 +62,26 @@ 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 if (!strcmp(arg, "-h")) { + usage(builtin_log_usage); } else die("unrecognized argument: %s", arg); } + if (decoration_style) { + rev->show_decorations = 1; + load_ref_decorations(decoration_style); + } } /* @@ -257,7 +275,7 @@ static void show_tagger(char *buf, int len, struct rev_info *rev) pp_user_info("Tagger", rev->commit_format, &out, buf, rev->date_mode, git_log_output_encoding ? git_log_output_encoding: git_commit_encoding); - printf("%s\n", out.buf); + printf("%s", out.buf); strbuf_release(&out); } @@ -329,11 +347,14 @@ int cmd_show(int argc, const char **argv, const char *prefix) case OBJ_TAG: { struct tag *t = (struct tag *)o; + if (rev.shown_one) + putchar('\n'); printf("%stag %s%s\n", diff_get_color_opt(&rev.diffopt, DIFF_COMMIT), t->tag, diff_get_color_opt(&rev.diffopt, DIFF_RESET)); ret = show_object(o->sha1, 1, &rev); + rev.shown_one = 1; if (ret) break; o = parse_object(t->tagged->sha1); @@ -345,12 +366,15 @@ int cmd_show(int argc, const char **argv, const char *prefix) break; } case OBJ_TREE: + if (rev.shown_one) + putchar('\n'); printf("%stree %s%s\n\n", diff_get_color_opt(&rev.diffopt, DIFF_COMMIT), name, diff_get_color_opt(&rev.diffopt, DIFF_RESET)); read_tree_recursive((struct tree *)o, "", 0, 0, NULL, show_tree_object, NULL); + rev.shown_one = 1; break; case OBJ_COMMIT: rev.pending.nr = rev.pending.alloc = 0; @@ -658,6 +682,10 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout, log_write_email_headers(rev, head, &subject_start, &extra_headers, &need_8bit_cte); + for (i = 0; !need_8bit_cte && i < nr; i++) + if (has_non_ascii(list[i]->buffer)) + need_8bit_cte = 1; + msg = body; pp_user_info(NULL, CMIT_FMT_EMAIL, &sb, committer, DATE_RFC2822, encoding); |