]>
git.ipfire.org Git - thirdparty/git.git/blob - builtin-log.c
2 * Builtin "git log" and related commands (show, whatchanged)
4 * (C) Copyright 2006 Linus Torvalds
14 static int cmd_log_wc(int argc
, const char **argv
, char **envp
,
17 struct commit
*commit
;
19 rev
->abbrev
= DEFAULT_ABBREV
;
20 rev
->commit_format
= CMIT_FMT_DEFAULT
;
21 rev
->verbose_header
= 1;
22 argc
= setup_revisions(argc
, argv
, rev
, "HEAD");
25 die("unrecognized argument: %s", argv
[1]);
27 prepare_revision_walk(rev
);
29 while ((commit
= get_revision(rev
)) != NULL
) {
30 log_tree_commit(rev
, commit
);
32 commit
->buffer
= NULL
;
37 int cmd_whatchanged(int argc
, const char **argv
, char **envp
)
43 rev
.diffopt
.recursive
= 1;
44 return cmd_log_wc(argc
, argv
, envp
, &rev
);
47 int cmd_show(int argc
, const char **argv
, char **envp
)
53 rev
.diffopt
.recursive
= 1;
54 rev
.combine_merges
= 1;
55 rev
.dense_combined_merges
= 1;
56 rev
.always_show_header
= 1;
57 rev
.ignore_merges
= 0;
59 return cmd_log_wc(argc
, argv
, envp
, &rev
);
62 int cmd_log(int argc
, const char **argv
, char **envp
)
67 rev
.always_show_header
= 1;
68 rev
.diffopt
.recursive
= 1;
69 return cmd_log_wc(argc
, argv
, envp
, &rev
);
72 int cmd_format_patch(int argc
, const char **argv
, char **envp
)
74 struct commit
*commit
;
75 struct commit
**list
= NULL
;
80 rev
.commit_format
= CMIT_FMT_EMAIL
;
81 rev
.verbose_header
= 1;
83 rev
.diffopt
.with_raw
= 0;
84 rev
.diffopt
.with_stat
= 1;
85 rev
.combine_merges
= 0;
86 rev
.ignore_merges
= 1;
87 rev
.diffopt
.output_format
= DIFF_FORMAT_PATCH
;
88 argc
= setup_revisions(argc
, argv
, &rev
, "HEAD");
90 prepare_revision_walk(&rev
);
91 while ((commit
= get_revision(&rev
)) != NULL
) {
93 list
= realloc(list
, nr
* sizeof(list
[0]));
94 list
[nr
- 1] = commit
;
99 shown
= log_tree_commit(&rev
, commit
);
100 free(commit
->buffer
);
101 commit
->buffer
= NULL
;
103 printf("-- \n%s\n\n", git_version_string
);