mailinfo: More carefully parse header lines in read_one_header_line()
[git/spearce.git] / builtin-log.c
blobc4ceee0f9801dcfbfb6aafe386dad3cc48b31560
1 /*
2 * Builtin "git log" and related commands (show, whatchanged)
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"
13 static int cmd_log_wc(int argc, const char **argv, char **envp,
14 struct rev_info *rev)
16 struct commit *commit;
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;
30 if (argc > 1)
31 die("unrecognized argument: %s", argv[1]);
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;
40 return 0;
43 int cmd_whatchanged(int argc, const char **argv, char **envp)
45 struct rev_info rev;
47 init_revisions(&rev);
48 rev.diff = 1;
49 rev.diffopt.recursive = 1;
50 return cmd_log_wc(argc, argv, envp, &rev);
53 int cmd_show(int argc, const char **argv, char **envp)
55 struct rev_info rev;
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);
68 int cmd_log(int argc, const char **argv, char **envp)
70 struct rev_info rev;
72 init_revisions(&rev);
73 rev.always_show_header = 1;
74 rev.diffopt.recursive = 1;
75 return cmd_log_wc(argc, argv, envp, &rev);