Split up builtin commands into separate files from git.c
[git/git-svn.git] / builtin-log.c
blob69f2911cb4739ba211ac692ded2aa0a6d31cb989
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");
23 if (argc > 1)
24 die("unrecognized argument: %s", argv[1]);
26 prepare_revision_walk(rev);
27 setup_pager();
28 while ((commit = get_revision(rev)) != NULL) {
29 log_tree_commit(rev, commit);
30 free(commit->buffer);
31 commit->buffer = NULL;
33 return 0;
36 int cmd_whatchanged(int argc, const char **argv, char **envp)
38 struct rev_info rev;
40 init_revisions(&rev);
41 rev.diff = 1;
42 rev.diffopt.recursive = 1;
43 return cmd_log_wc(argc, argv, envp, &rev);
46 int cmd_show(int argc, const char **argv, char **envp)
48 struct rev_info rev;
50 init_revisions(&rev);
51 rev.diff = 1;
52 rev.diffopt.recursive = 1;
53 rev.combine_merges = 1;
54 rev.dense_combined_merges = 1;
55 rev.always_show_header = 1;
56 rev.ignore_merges = 0;
57 rev.no_walk = 1;
58 return cmd_log_wc(argc, argv, envp, &rev);
61 int cmd_log(int argc, const char **argv, char **envp)
63 struct rev_info rev;
65 init_revisions(&rev);
66 rev.always_show_header = 1;
67 rev.diffopt.recursive = 1;
68 return cmd_log_wc(argc, argv, envp, &rev);