+static int cmd_log_wc(int argc, const char **argv, char **envp,
+ struct rev_info *rev)
+{
+ struct commit *commit;
+ char *buf = xmalloc(LOGSIZE);
+ const char *commit_prefix = "commit ";
+ int shown = 0;
+
+ if (argc > 1)
+ die("unrecognized argument: %s", argv[1]);
+ if (rev->commit_format == CMIT_FMT_ONELINE)
+ commit_prefix = "";
+
+ prepare_revision_walk(rev);
+ setup_pager();
+ while ((commit = get_revision(rev)) != NULL) {
+ if (shown && rev->diff &&
+ rev->commit_format != CMIT_FMT_ONELINE)
+ putchar('\n');
+ fputs(commit_prefix, stdout);
+ if (rev->abbrev_commit && rev->abbrev)
+ fputs(find_unique_abbrev(commit->object.sha1,
+ rev->abbrev),
+ stdout);
+ else
+ fputs(sha1_to_hex(commit->object.sha1), stdout);
+ if (rev->parents) {
+ struct commit_list *parents = commit->parents;
+ while (parents) {
+ struct object *o = &(parents->item->object);
+ parents = parents->next;
+ if (o->flags & TMP_MARK)
+ continue;
+ printf(" %s", sha1_to_hex(o->sha1));
+ o->flags |= TMP_MARK;
+ }
+ /* TMP_MARK is a general purpose flag that can
+ * be used locally, but the user should clean
+ * things up after it is done with them.
+ */
+ for (parents = commit->parents;
+ parents;
+ parents = parents->next)
+ parents->item->object.flags &= ~TMP_MARK;
+ }
+ if (rev->commit_format == CMIT_FMT_ONELINE)
+ putchar(' ');
+ else
+ putchar('\n');
+ pretty_print_commit(rev->commit_format, commit, ~0, buf,
+ LOGSIZE, rev->abbrev);
+ printf("%s\n", buf);
+ if (rev->diff) {
+ printf("---\n");
+ log_tree_commit(rev, commit);