git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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);
>  	}
Previous: Martin von ZweigbergkNext: Martin von Zweigbergk
Message 6 of 10 in “Small log simplifications”
  1. 0/2 Small log simplificationsMartin von Zweigbergk, Jul 27, 2012
  2. 1/2 remove unnecessary parameter from get_patch_ids()Martin von Zweigbergk, Jul 27, 2012
  3. Junio C HamanoJul 27, 2012
  4. Martin von ZweigbergkJul 28, 2012
  5. 2/2 log: remove redundant check for merge commitMartin von Zweigbergk, Jul 27, 2012
  6. Junio C HamanoJul 27, 2012
  7. Martin von ZweigbergkJul 28, 2012
  8. Junio C HamanoJul 28, 2012
  9. Martin von ZweigbergkJul 29, 2012
  10. Junio C HamanoJul 29, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.