git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Joel Teichroeb <joel@teichroeb.net>,
	Thomas Gummerer <t.gummerer@gmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [BUG] builtin "stash apply" does not refresh index
Date: Fri, 23 Aug 2019 09:56:45 -0700	[thread overview]
Message-ID: <xmqqa7bzn7le.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190823052737.GA10592@sigill.intra.peff.net> (Jeff King's message of "Fri, 23 Aug 2019 01:27:37 -0400")

Jeff King <peff@peff.net> writes:

> This started with 8a0fc8d19d (stash: convert apply to builtin,
> 2019-02-25), which is in v2.22.0. Interestingly, do_stash_apply() does
> in fact call refresh_cache(). But it looks like we don't ever write it
> out to disk. So when we later call merge_recursive(), it presumably uses
> the on-disk index, not what we have in memory.

Ouch.

> It's not clear to me where the fix should go, though. Should
> "stash apply" be writing out the refreshed index before
> proceeding? Or should merge_recursive() be more careful about
> refreshing the index after it locks it?  The former is what
> happened with stash as a shell script, but the latter would save
> us an otherwise pointless write.

I wonder if the third solution be possible.  "I am a new caller of
merge-recursive machinery, I did some operations on the working tree
and the index (in core), and while I would, in the old world order,
write out the in-core index to on-disk and call the merge-recursive
machinery, expecing the callee to read the on-disk index, for the
sake of performance, I am using this new calling convention, where a
new entry point of merge-recursivey machinery allows me to call it
and tell it to use the in-core index."  For that to happen, the
codepath in the merge-recursive machinery entered from the new entry
point needs to learn not only omit a call to read_cache() but also
it needs to write in-core index out lazily for the caller (e.g.
imagine it needs to exit early without doing any of the merge?  The
caller skipped the "otherwise pointless write", which needs to now
happen before the whole thing exits).

And before the third one, introduction of a new entry point that
makes merge-recursive machinery inherit the already populated
in-core index, happens, I think the right solution is to write the
in-core index out---the write is not pointless.






      reply	other threads:[~2019-08-23 16:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23  5:27 [BUG] builtin "stash apply" does not refresh index Jeff King
2019-08-23 16:56 ` Junio C Hamano [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqa7bzn7le.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=joel@teichroeb.net \
    --cc=peff@peff.net \
    --cc=t.gummerer@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).