git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Jayati Shrivastava via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Hariom verma <hariom18599@gmail.com>,
	Christian Couder <christian.couder@gmail.com>,
	Jayati Shrivastava <gaurijove@gmail.com>
Subject: Re: [PATCH] Use reverse_commit_list helper function for in-place list reversal
Date: Tue, 15 Mar 2022 15:53:51 -0700	[thread overview]
Message-ID: <xmqq4k3yddz4.fsf@gitster.g> (raw)
In-Reply-To: pull.1177.git.1647373314457.gitgitgadget@gmail.com

"Jayati Shrivastava via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> Subject: Re: [PATCH] Use reverse_commit_list helper function for in-place list reversal

Perhaps

    Subject: [PATCH] sequencer: use reverse_commit_list_helper()

cf. Documentation/SubmittingPatches::[[summary-section]]

> From: JAYATI SHRIVASTAVA <gaurijove@gmail.com>

This name should match what is on Signed-off-by: line.  Check your
user.name configuration, perhaps?

> Here, a reverse copy of a list is being created by iterating
> over the list after which the original list is discarded.
> Instead of creating a new allocation, we can reverse the
> original list in-place using the reverse_commit_list helper
> function.

Perhaps

    Instead of creating a new allocation, reverse the list in-place
    by calling the reverse_commit_list() helper.

cf. Documentation/SubmittingPatches::[[imperative-mood]]
>
> Signed-off-by: Jayati Shrivastava <gaurijove@gmail.com>
> ---

> @@ -3984,9 +3984,7 @@ static int do_merge(struct repository *r,
>  		      git_path_merge_head(r), 0);
>  	write_message("no-ff", 5, git_path_merge_mode(r), 0);
>  
> -	for (j = bases; j; j = j->next)
> -		commit_list_insert(j->item, &reversed);
> -	free_commit_list(bases);
> +	bases = reverse_commit_list(bases);

If the code in the original code that followed from here used both
"bases" and "reversed", this would not have worked, but because the
original gets rid of "bases", we can just reverse the list in-place
with reverse_commit_list() helper and reuse the same variable.

>  	repo_read_index(r);
>  	init_merge_options(&o, r);
> @@ -4002,10 +4000,10 @@ static int do_merge(struct repository *r,
>  		 * update the index and working copy immediately.
>  		 */
>  		ret = merge_ort_recursive(&o,
> -					  head_commit, merge_commit, reversed,
> +					  head_commit, merge_commit, bases,
>  					  &i);
>  	} else {
> -		ret = merge_recursive(&o, head_commit, merge_commit, reversed,
> +		ret = merge_recursive(&o, head_commit, merge_commit, bases,
>  				      &i);
>  	}

Looks good.

Thanks.

  reply	other threads:[~2022-03-15 22:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 19:41 [PATCH] Use reverse_commit_list helper function for in-place list reversal Jayati Shrivastava via GitGitGadget
2022-03-15 22:53 ` Junio C Hamano [this message]
2022-03-16 10:42 ` [PATCH v2] sequencer.c: use reverse_commit_list() helper Jayati Shrivastava via GitGitGadget
2022-03-16 11:20   ` [PATCH v3] " Jayati Shrivastava via GitGitGadget
2022-03-16 19:44     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq4k3yddz4.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=christian.couder@gmail.com \
    --cc=gaurijove@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=hariom18599@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).