builtin-log.con commit Update write-tree to use cache-tree. (a52139b)
   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
  23        if (argc > 1)
  24                die("unrecognized argument: %s", argv[1]);
  25
  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;
  32        }
  33        return 0;
  34}
  35
  36int cmd_whatchanged(int argc, const char **argv, char **envp)
  37{
  38        struct rev_info rev;
  39
  40        init_revisions(&rev);
  41        rev.diff = 1;
  42        rev.diffopt.recursive = 1;
  43        return cmd_log_wc(argc, argv, envp, &rev);
  44}
  45
  46int cmd_show(int argc, const char **argv, char **envp)
  47{
  48        struct rev_info rev;
  49
  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);
  59}
  60
  61int cmd_log(int argc, const char **argv, char **envp)
  62{
  63        struct rev_info rev;
  64
  65        init_revisions(&rev);
  66        rev.always_show_header = 1;
  67        rev.diffopt.recursive = 1;
  68        return cmd_log_wc(argc, argv, envp, &rev);
  69}