From: Junio C Hamano Date: Fri, 19 May 2006 22:25:57 +0000 (-0700) Subject: Merge part of 'js/fmt-patch' for RFC2822 dates into 'sp/reflog' X-Git-Tag: v1.4.0-rc1~11^2~4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6858d494926437ad7b7e9199ea39953eb90c7bab;p=git.git Merge part of 'js/fmt-patch' for RFC2822 dates into 'sp/reflog' An earlier patch from Shawn Pearce dependes on a change that is only in "next". I do not want to make this series hostage to the yet-to-graduate js/fmt-patch branch, but let's try fixing it by merging the early parts of the branch to see what happens. Right now, 'sp/reflog' will not be in "next" for now, so I won't have to regret this -- if this merge causes problem down the road merging I can always rebuild the topic branch ;-). --- 6858d494926437ad7b7e9199ea39953eb90c7bab diff --cc builtin.h index 7744f7d2f,94dc0732f..97e246446 --- a/builtin.h +++ b/builtin.h @@@ -19,10 -19,6 +19,11 @@@ extern int cmd_version(int argc, const extern int cmd_whatchanged(int argc, const char **argv, char **envp); extern int cmd_show(int argc, const char **argv, char **envp); extern int cmd_log(int argc, const char **argv, char **envp); +extern int cmd_diff(int argc, const char **argv, char **envp); + extern int cmd_format_patch(int argc, const char **argv, char **envp); +extern int cmd_count_objects(int argc, const char **argv, char **envp); + +extern int cmd_push(int argc, const char **argv, char **envp); +extern int cmd_grep(int argc, const char **argv, char **envp); #endif diff --cc commit.c index 4a26070c1,42b44bba5..8317f6d26 --- a/commit.c +++ b/commit.c @@@ -22,33 -22,25 +22,34 @@@ struct sort_nod const char *commit_type = "commit"; +struct cmt_fmt_map { + const char *n; + size_t cmp_len; + enum cmit_fmt v; +} cmt_fmts[] = { + { "raw", 1, CMIT_FMT_RAW }, + { "medium", 1, CMIT_FMT_MEDIUM }, + { "short", 1, CMIT_FMT_SHORT }, ++ { "email", 1, CMIT_FMT_EMAIL }, + { "full", 5, CMIT_FMT_FULL }, + { "fuller", 5, CMIT_FMT_FULLER }, + { "oneline", 1, CMIT_FMT_ONELINE }, +}; + enum cmit_fmt get_commit_format(const char *arg) { - if (!*arg) + int i; + + if (!arg || !*arg) return CMIT_FMT_DEFAULT; - if (!strcmp(arg, "=raw")) - return CMIT_FMT_RAW; - if (!strcmp(arg, "=medium")) - return CMIT_FMT_MEDIUM; - if (!strcmp(arg, "=short")) - return CMIT_FMT_SHORT; - if (!strcmp(arg, "=full")) - return CMIT_FMT_FULL; - if (!strcmp(arg, "=fuller")) - return CMIT_FMT_FULLER; - if (!strcmp(arg, "=email")) - return CMIT_FMT_EMAIL; - if (!strcmp(arg, "=oneline")) - return CMIT_FMT_ONELINE; - die("invalid --pretty format"); + if (*arg == '=') + arg++; + for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) { + if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len)) + return cmt_fmts[i].v; + } + + die("invalid --pretty format: %s", arg); } static struct commit *check_commit(struct object *obj, diff --cc git.c index a94d9ee5a,619c6654e..84803a62e --- a/git.c +++ b/git.c @@@ -46,10 -47,7 +46,11 @@@ static void handle_internal_command(in { "log", cmd_log }, { "whatchanged", cmd_whatchanged }, { "show", cmd_show }, + { "push", cmd_push }, + { "fmt-patch", cmd_format_patch }, + { "count-objects", cmd_count_objects }, + { "diff", cmd_diff }, + { "grep", cmd_grep }, }; int i; diff --cc log-tree.c index b90ba6762,aaf2b9423..2bcf2dfaa --- a/log-tree.c +++ b/log-tree.c @@@ -49,14 -37,20 +49,22 @@@ void show_log(struct rev_info *opt, str /* * Print header line of header.. */ - printf("%s%s", - opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ", - diff_unique_abbrev(commit->object.sha1, abbrev_commit)); - if (opt->parents) - show_parents(commit, abbrev_commit); - if (parent) - printf(" (from %s)", diff_unique_abbrev(parent->object.sha1, abbrev_commit)); - putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n'); + + if (opt->commit_format == CMIT_FMT_EMAIL) + printf("From %s Thu Apr 7 15:13:13 2005\n", + sha1_to_hex(commit->object.sha1)); + else { + printf("%s%s", + opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ", + diff_unique_abbrev(commit->object.sha1, abbrev_commit)); - if (parent) ++ if (opt->parents) ++ show_parents(commit, abbrev_commit); ++ if (parent) + printf(" (from %s)", + diff_unique_abbrev(parent->object.sha1, + abbrev_commit)); + putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n'); + } /* * And then the pretty-printed message itself