1/*
2 * Builtin "git log" and related commands (show, whatchanged)
3 *
4 * (C) Copyright 2006 Linus Torvalds
5 * 2006 Junio Hamano
6 */
7#include "cache.h"
8#include "commit.h"
9#include "diff.h"
10#include "revision.h"
11#include "log-tree.h"
12
13static int cmd_log_wc(int argc, const char **argv, char **envp,
14 struct rev_info *rev)
15{
16 struct commit *commit;
17
18 rev->abbrev = DEFAULT_ABBREV;
19 rev->commit_format = CMIT_FMT_DEFAULT;
20 rev->verbose_header = 1;
21 argc = setup_revisions(argc, argv, rev, "HEAD");
22 if (rev->always_show_header) {
23 if (rev->diffopt.pickaxe || rev->diffopt.filter) {
24 rev->always_show_header = 0;
25 if (rev->diffopt.output_format == DIFF_FORMAT_RAW)
26 rev->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT;
27 }
28 }
29
30 if (argc > 1)
31 die("unrecognized argument: %s", argv[1]);
32
33 prepare_revision_walk(rev);
34 setup_pager();
35 while ((commit = get_revision(rev)) != NULL) {
36 log_tree_commit(rev, commit);
37 free(commit->buffer);
38 commit->buffer = NULL;
39 }
40 return 0;
41}
42
43int cmd_whatchanged(int argc, const char **argv, char **envp)
44{
45 struct rev_info rev;
46
47 init_revisions(&rev);
48 rev.diff = 1;
49 rev.diffopt.recursive = 1;
50 return cmd_log_wc(argc, argv, envp, &rev);
51}
52
53int cmd_show(int argc, const char **argv, char **envp)
54{
55 struct rev_info rev;
56
57 init_revisions(&rev);
58 rev.diff = 1;
59 rev.diffopt.recursive = 1;
60 rev.combine_merges = 1;
61 rev.dense_combined_merges = 1;
62 rev.always_show_header = 1;
63 rev.ignore_merges = 0;
64 rev.no_walk = 1;
65 return cmd_log_wc(argc, argv, envp, &rev);
66}
67
68int cmd_log(int argc, const char **argv, char **envp)
69{
70 struct rev_info rev;
71
72 init_revisions(&rev);
73 rev.always_show_header = 1;
74 rev.diffopt.recursive = 1;
75 return cmd_log_wc(argc, argv, envp, &rev);
76}