From: Junio C Hamano Date: Sun, 3 Apr 2011 19:31:59 +0000 (-0700) Subject: Merge branch 'mm/maint-log-n-with-diff-filtering' into maint X-Git-Tag: v1.7.4.4~10 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1030536153db404daba4a140d1e3fa1a7ba470a5?ds=inline;hp=-c Merge branch 'mm/maint-log-n-with-diff-filtering' into maint * mm/maint-log-n-with-diff-filtering: log: fix --max-count when used together with -S or -G --- 1030536153db404daba4a140d1e3fa1a7ba470a5 diff --combined builtin/log.c index 0f43d2ec78,2b82272eac..9a15d69617 --- a/builtin/log.c +++ b/builtin/log.c @@@ -263,7 -263,13 +263,13 @@@ static int cmd_log_walk(struct rev_inf * retain that state information if replacing rev->diffopt in this loop */ while ((commit = get_revision(rev)) != NULL) { - log_tree_commit(rev, commit); + if (!log_tree_commit(rev, commit) && + rev->max_count >= 0) + /* + * We decremented max_count in get_revision, + * but we didn't actually show the commit. + */ + rev->max_count++; if (!rev->reflog_info) { /* we allow cycles in reflog ancestry */ free(commit->buffer); @@@ -1352,23 -1358,6 +1358,23 @@@ static const char * const cherry_usage[ NULL }; +static void print_commit(char sign, struct commit *commit, int verbose, + int abbrev) +{ + if (!verbose) { + printf("%c %s\n", sign, + find_unique_abbrev(commit->object.sha1, abbrev)); + } else { + struct strbuf buf = STRBUF_INIT; + struct pretty_print_context ctx = {0}; + pretty_print_commit(CMIT_FMT_ONELINE, commit, &buf, &ctx); + printf("%c %s %s\n", sign, + find_unique_abbrev(commit->object.sha1, abbrev), + buf.buf); + strbuf_release(&buf); + } +} + int cmd_cherry(int argc, const char **argv, const char *prefix) { struct rev_info revs; @@@ -1453,7 -1442,22 +1459,7 @@@ commit = list->item; if (has_commit_patch_id(commit, &ids)) sign = '-'; - - if (verbose) { - struct strbuf buf = STRBUF_INIT; - struct pretty_print_context ctx = {0}; - pretty_print_commit(CMIT_FMT_ONELINE, commit, - &buf, &ctx); - printf("%c %s %s\n", sign, - find_unique_abbrev(commit->object.sha1, abbrev), - buf.buf); - strbuf_release(&buf); - } - else { - printf("%c %s\n", sign, - find_unique_abbrev(commit->object.sha1, abbrev)); - } - + print_commit(sign, commit, verbose, abbrev); list = list->next; }