Re: [PATCH 2/2] log: remove redundant check for merge commit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martin von Zweigbergk <martin.von.zweigbergk@xxxxxxxxx> writes:

> 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@xxxxxxxxx>

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.

> ---
>  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);
>  	}
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]