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

Re: [PATCH 2/2] built-in rebase: reinstate `checkout -q` behavior where appropriate

From
Jeff King <peff@peff.net>
Date
Nov 9, 2018, 10:11 UTC
Message-ID
<20181109101148.GB7410@sigill.intra.peff.net>
In-Reply-To
<070092b4309e5e74e3a1b3be54613cccf26e97da.1541756054.git.gitgitgadget@gmail.com>
On Fri, Nov 09, 2018 at 01:34:19AM -0800, Johannes Schindelin via GitGitGadget wrote:
Show 11 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> When we converted a `git checkout -q $onto^0` call to use
> `reset_head()`, we inadvertently incurred a change from a twoway_merge
> to a oneway_merge, as if we wanted a `git reset --hard` instead.
> 
> This has performance ramifications under certain, though, as the
> oneway_merge needs to lstat() every single index entry whereas
> twoway_merge does not.
> 
> So let's go back to the old behavior.

Makes sense. I didn't think too hard about any possible gotchas with the twoway/oneway switch, but if that's what git-checkout was doing before, it seems obviously safe.

Show 11 quoted lines
> diff --git a/builtin/rebase.c b/builtin/rebase.c
> index 6f6d7de156..c1cc50f3f8 100644
> --- a/builtin/rebase.c
> +++ b/builtin/rebase.c
> @@ -523,11 +523,12 @@ finished_rebase:
>  #define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
>  
>  static int reset_head(struct object_id *oid, const char *action,
> -		      const char *switch_to_branch, int detach_head,
> +		      const char *switch_to_branch,
> +		      int detach_head, int reset_hard,

It might be worth switching to a single flag variable here. It would make calls like this:

> -	if (reset_head(&options.onto->object.oid, "checkout", NULL, 1,
> +	if (reset_head(&options.onto->object.oid, "checkout", NULL, 1, 0,
>  	    NULL, msg.buf))
a little more self-documenting (if a little more verbose).
Show 10 quoted lines
> -	if (!oid) {
> -		if (get_oid("HEAD", &head_oid)) {
> -			rollback_lock_file(&lock);
> -			return error(_("could not determine HEAD revision"));
> -		}
> -		oid = &head_oid;
> +	if (get_oid("HEAD", &head_oid)) {
> +		rollback_lock_file(&lock);
> +		return error(_("could not determine HEAD revision"));
>  	}
This one could actually turn into:
  ret = error(...);
  goto leave_reset_head;

now. We don't have to worry about an uninitialized desc.buffer anymore (as I mentioned in the previous email), because "nr" would be 0.

It doesn't save any lines, though (but maybe having a single cleanup/exit point would make things easier to read; I dunno).

Take all my comments as observations, not objections. This looks OK to me either way.

-Peff
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin
Message 6 of 18 in “Fix built-in rebase perf regression”
  1. 0/2 Fix built-in rebase perf regressionJohannes Schindelin via GitGitGadget, Nov 9, 2018
  2. 1/2 rebase: consolidate clean-up code before leaving reset_head()Johannes Schindelin via GitGitGadget, Nov 9, 2018
  3. Jeff KingNov 9, 2018
  4. Johannes SchindelinNov 9, 2018
  5. 2/2 built-in rebase: reinstate `checkout -q` behavior where appropriateJohannes Schindelin via GitGitGadget, Nov 9, 2018
  6. Jeff KingNov 9, 2018
  7. Johannes SchindelinNov 9, 2018
  8. Jeff KingNov 9, 2018
  9. Johannes SchindelinNov 12, 2018
  10. Junio C HamanoNov 12, 2018
  11. Johannes SchindelinNov 12, 2018
  12. Junio C HamanoNov 13, 2018
  13. Junio C HamanoNov 13, 2018
  14. 0/3 Fix built-in rebase perf regressionJohannes Schindelin via GitGitGadget, Nov 12, 2018
  15. 1/3 rebase: consolidate clean-up code before leaving reset_head()Johannes Schindelin via GitGitGadget, Nov 12, 2018
  16. 2/3 rebase: prepare reset_head() for more flagsJohannes Schindelin via GitGitGadget, Nov 12, 2018
  17. 3/3 built-in rebase: reinstate `checkout -q` behavior where appropriateJohannes Schindelin via GitGitGadget, Nov 12, 2018
  18. Johannes SchindelinNov 12, 2018

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.