#define LOGSIZE (65536)
-static int cmd_log(int argc, const char **argv, char **envp)
+static int cmd_log_wc(int argc, const char **argv, char **envp,
+ struct whatchanged_opt *wcopt)
{
- struct whatchanged_opt wcopt;
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;
+ struct rev_info *rev = &wcopt->revopt;
+ struct log_tree_opt *opt = &wcopt->logopt;
- memset(&wcopt, 0, sizeof(wcopt));
- init_log_tree_opt(&wcopt.logopt);
opt->commit_format = CMIT_FMT_DEFAULT;
- wcopt.abbrev = DEFAULT_ABBREV;
- argc = parse_whatchanged_opt(argc, argv, &wcopt);
+ wcopt->abbrev = DEFAULT_ABBREV;
+ argc = parse_whatchanged_opt(argc, argv, wcopt);
if (opt->commit_format == CMIT_FMT_ONELINE)
commit_prefix = "";
prepare_revision_walk(rev);
setup_pager();
while ((commit = get_revision(rev)) != NULL) {
- if (shown && wcopt.do_diff &&
+ if (shown && wcopt->do_diff &&
opt->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 (wcopt->abbrev_commit && wcopt->abbrev)
+ fputs(find_unique_abbrev(commit->object.sha1, wcopt->abbrev),
stdout);
else
fputs(sha1_to_hex(commit->object.sha1), stdout);
else
putchar('\n');
pretty_print_commit(opt->commit_format, commit, ~0, buf,
- LOGSIZE, wcopt.abbrev);
+ LOGSIZE, wcopt->abbrev);
printf("%s\n", buf);
- if (wcopt.do_diff)
+ if (wcopt->do_diff)
log_tree_commit(opt, commit);
shown = 1;
free(commit->buffer);
return 0;
}
+static int cmd_log(int ac, const char **av, char **ep)
+{
+ struct whatchanged_opt wcopt;
+
+ memset(&wcopt, 0, sizeof(wcopt));
+ init_log_tree_opt(&wcopt.logopt);
+ return cmd_log_wc(ac, av, ep, &wcopt);
+}
+
+static int cmd_whatchanged(int ac, const char **av, char **ep)
+{
+ 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);
+}
+
static void handle_internal_command(int argc, const char **argv, char **envp)
{
const char *cmd = argv[0];
{ "version", cmd_version },
{ "help", cmd_help },
{ "log", cmd_log },
+ { "whatchanged", cmd_whatchanged },
};
int i;