Re: [PATCH 2/2] log: remove redundant check for merge commit
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 27, 2012, 22:30 UTC
- Message-ID
- <7vfw8czvj5.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1343409699-27199-3-git-send-email-martin.von.zweigbergk@gmail.com>
Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:
Show 9 quoted lines
> While walking the revision list in get_patch_ids and cmd_cherry, we > ignore merges by checking if there is more than one parent. However, > since the revision walk was initialized with revs.ignore_merges = 1, > this would never happen. Remove the unnecessary checks. > > Also re-initializing rev_info fields to the same values already set in > init_revisions(). > > Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
I think the in-loop checks were totally redundant. I suspect that explicit initialization to revs.ignore_merges outself can be called belt-and-braces defensive programming to avoid getting surprised by future changes to what init_revisions() would do, so I do not have strong preference either way.
Show 38 quoted lines
> ---
> builtin/log.c | 10 ----------
> 1 file changed, 10 deletions(-)
>
> diff --git a/builtin/log.c b/builtin/log.c
> index 7a92e3f..8182a18 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -726,10 +726,6 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
> die(_("revision walk setup failed"));
>
> while ((commit = get_revision(&check_rev)) != NULL) {
> - /* ignore merges */
> - if (commit->parents && commit->parents->next)
> - continue;
> -
> add_commit_patch_id(commit, ids);
> }
>
> @@ -1509,8 +1505,6 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
>
> init_revisions(&revs, prefix);
> revs.diff = 1;
> - revs.combine_merges = 0;
> - revs.ignore_merges = 1;
> DIFF_OPT_SET(&revs.diffopt, RECURSIVE);
>
> if (add_pending_commit(head, &revs, 0))
> @@ -1534,10 +1528,6 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
> if (prepare_revision_walk(&revs))
> die(_("revision walk setup failed"));
> while ((commit = get_revision(&revs)) != NULL) {
> - /* ignore merges */
> - if (commit->parents && commit->parents->next)
> - continue;
> -
> commit_list_insert(commit, &list);
> }