diff options
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 94 |
1 files changed, 50 insertions, 44 deletions
@@ -279,31 +279,28 @@ static int cmd_help(int argc, const char **argv, char **envp) #define LOGSIZE (65536) static int cmd_log_wc(int argc, const char **argv, char **envp, - struct whatchanged_opt *wcopt) + struct rev_info *rev) { struct commit *commit; char *buf = xmalloc(LOGSIZE); const char *commit_prefix = "commit "; int shown = 0; - struct rev_info *rev = &wcopt->revopt; - struct log_tree_opt *opt = &wcopt->logopt; - opt->commit_format = CMIT_FMT_DEFAULT; - wcopt->abbrev = DEFAULT_ABBREV; - argc = parse_whatchanged_opt(argc, argv, wcopt); - - if (opt->commit_format == CMIT_FMT_ONELINE) + if (argc > 1) + die("unrecognized argument: %s", argv[1]); + if (rev->commit_format == CMIT_FMT_ONELINE) commit_prefix = ""; prepare_revision_walk(rev); setup_pager(); while ((commit = get_revision(rev)) != NULL) { - if (shown && wcopt->do_diff && - opt->commit_format != CMIT_FMT_ONELINE) + if (shown && rev->diff && + rev->commit_format != CMIT_FMT_ONELINE) putchar('\n'); fputs(commit_prefix, stdout); - if (wcopt->abbrev_commit && wcopt->abbrev) - fputs(find_unique_abbrev(commit->object.sha1, wcopt->abbrev), + if (rev->abbrev_commit && rev->abbrev) + fputs(find_unique_abbrev(commit->object.sha1, + rev->abbrev), stdout); else fputs(sha1_to_hex(commit->object.sha1), stdout); @@ -326,16 +323,16 @@ static int cmd_log_wc(int argc, const char **argv, char **envp, parents = parents->next) parents->item->object.flags &= ~TMP_MARK; } - if (opt->commit_format == CMIT_FMT_ONELINE) + if (rev->commit_format == CMIT_FMT_ONELINE) putchar(' '); else putchar('\n'); - pretty_print_commit(opt->commit_format, commit, ~0, buf, - LOGSIZE, wcopt->abbrev); + pretty_print_commit(rev->commit_format, commit, ~0, buf, + LOGSIZE, rev->abbrev); printf("%s\n", buf); - if (wcopt->do_diff) { - printf("---\n"); - log_tree_commit(opt, commit); + if (rev->diff) { + printf("--\n"); + log_tree_commit(rev, commit); } shown = 1; free(commit->buffer); @@ -345,38 +342,47 @@ static int cmd_log_wc(int argc, const char **argv, char **envp, return 0; } -static int cmd_log(int ac, const char **av, char **ep) +static int cmd_wc(int argc, const char **argv, char **envp) { - struct whatchanged_opt wcopt; - - memset(&wcopt, 0, sizeof(wcopt)); - init_log_tree_opt(&wcopt.logopt); - return cmd_log_wc(ac, av, ep, &wcopt); + struct rev_info rev; + + init_revisions(&rev); + rev.abbrev = DEFAULT_ABBREV; + rev.no_commit_id = 1; + rev.commit_format = CMIT_FMT_DEFAULT; + rev.diff = 1; + rev.diffopt.recursive = 1; + argc = setup_revisions(argc, argv, &rev, "HEAD"); + return cmd_log_wc(argc, argv, envp, &rev); } -static int cmd_whatchanged(int ac, const char **av, char **ep) +static int cmd_show(int argc, const char **argv, char **envp) { - struct whatchanged_opt wcopt; - - memset(&wcopt, 0, sizeof(wcopt)); - wcopt.do_diff = 1; - init_log_tree_opt(&wcopt.logopt); - wcopt.logopt.diffopt.recursive = 1; - return cmd_log_wc(ac, av, ep, &wcopt); + struct rev_info rev; + + init_revisions(&rev); + rev.diff = 1; + rev.ignore_merges = 0; + rev.combine_merges = 1; + rev.dense_combined_merges = 1; + rev.abbrev = DEFAULT_ABBREV; + rev.commit_format = CMIT_FMT_DEFAULT; + rev.diffopt.recursive = 1; + rev.no_walk = 1; + argc = setup_revisions(argc, argv, &rev, "HEAD"); + return cmd_log_wc(argc, argv, envp, &rev); } -static int cmd_show(int ac, const char **av, char **ep) +static int cmd_log(int argc, const char **argv, char **envp) { - struct whatchanged_opt wcopt; - - memset(&wcopt, 0, sizeof(wcopt)); - wcopt.do_diff = 1; - init_log_tree_opt(&wcopt.logopt); - wcopt.logopt.ignore_merges = 0; - wcopt.logopt.combine_merges = 1; - wcopt.logopt.dense_combined_merges = 1; - wcopt.logopt.diffopt.recursive = 1; - return cmd_log_wc(ac, av, ep, &wcopt); + struct rev_info rev; + + init_revisions(&rev); + rev.abbrev = DEFAULT_ABBREV; + rev.no_commit_id = 1; + rev.commit_format = CMIT_FMT_DEFAULT; + argc = setup_revisions(argc, argv, &rev, "HEAD"); + return cmd_log_wc(argc, argv, envp, &rev); } static void handle_internal_command(int argc, const char **argv, char **envp) @@ -389,8 +395,8 @@ static void handle_internal_command(int argc, const char **argv, char **envp) { "version", cmd_version }, { "help", cmd_help }, { "log", cmd_log }, + { "whatchanged", cmd_wc }, { "show", cmd_show }, - { "whatchanged", cmd_whatchanged }, }; int i; |