git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
From: Pratyush Yadav <me@yadavpratyush.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Bert Wesarg <bert.wesarg@googlemail.com>
Subject: Re: [PATCH v4 1/1] Make gitdir work with worktrees, respect core.hooksPath, etc
Date: Mon, 14 Oct 2019 00:25:40 +0530
Message-ID: <20191013185540.fwyn4ox5dbyxgvnh@yadavpratyush.com> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.1910122321211.3272@tvgsbejvaqbjf.bet>

On 12/10/19 11:24PM, Johannes Schindelin wrote:
> Hi Pratyush,
> 
> On Sat, 12 Oct 2019, Pratyush Yadav wrote:
> 
> > On 08/10/19 04:33AM, Johannes Schindelin via GitGitGadget wrote:
> >
> > > @@ -1453,10 +1501,16 @@ proc rescan {after {honor_trustmtime 1}} {
> > >  	global HEAD PARENT MERGE_HEAD commit_type
> > >  	global ui_index ui_workdir ui_comm
> > >  	global rescan_active file_states
> > > -	global repo_config
> > > +	global repo_config _gitdir_cache
> > >
> > >  	if {$rescan_active > 0 || ![lock_index read]} return
> > >
> > > +	# Only re-prime gitdir cache on a full rescan
> > > +	if {$after ne "ui_ready"} {
> >
> > What do you mean by a "full rescan"? I assume you use it as the
> > differentiator between `ui_do_rescan` (called when you hit F5 or choose
> > rescan from the menu) and `do_rescan` (called when you revert a line or
> > hunk), and a "full rescan" refers to `ui_do_rescan`.
> >
> > Well in that case, this check is incorrect. `do_rescan` passes only
> > "ui_ready" and `ui_do_rescan` passes "force_first_diff ui_ready".
> >
> > But either way, I'm not a big fan of this. This check makes assumptions
> > about the behaviour of its callers based on what they pass to $after.
> > The way I see it, $after should be a black box to `rescan`, and it
> > should make absolutely no assumptions about it.
> >
> > Doing it this way is really brittle, and would break as soon as someone
> > changes the behaviour of `ui_do_rescan`. If someone in the future passes
> > a different value in $after, this would stop working as intended and
> > would not refresh the cached list on a rescan.
> >
> > So, I think a better place for this if statement would be in
> > `ui_do_rescan`. This would mean adding a new function that does this.
> > But if we unset _gitdir_cache in prime_gitdir_cache (I see no reason not
> > to), we can get away with just something like:
> >
> >   proc ui_do_rescan {} {
> >   	rescan {prime_gitdir_cache; ui_ready}
> >   }
> >
> > Though since `prime_gitdir_cache` does not really depend on the rescan
> > being finished, something like this would also work fine:
> >
> >   proc ui_do_rescan {} {
> >   	rescan ui_ready
> >   	prime_gitdir_cache
> >   }
> 
> That was my first attempt. However, there is a very important piece of
> code that is even still quoted above: that `if {$rescan_active > 0 ||
> ![lock_index read]} return` part.
> 
> I do _not_ want to interfere with an actively-going-on rescan. If there
> is an active one, I don't want to re-prime the `_gitdir` cache.

Good catch! In that case I suppose refreshing the cache in $after would 
be the way to go (IOW, the former of my two suggestions). Anything 
$after won't get executed if we return early from that check.
 
> That was the reason why I put the additional code into `rescan` rather
> than into `ui_do_rescan()`.
> 
> Ciao,
> Johannes
> 
> >
> > This would allow us to do these two things in parallel since `rescan` is
> > asynchronous. But that would also mean it is possible that the status
> > bar would show "Ready" while `prime_gitdir_cache` is still executing.
> >
> > I can't really make up my mind on what is better. I'm inclining on using
> > the latter way, effectively trading a bit of UI inconsistency for
> > performance (at least in theory).
> >
> > Thoughts?
> >
> > > +		array unset _gitdir_cache
> > > +		prime_gitdir_cache
> > > +	}
> > > +
> > >  	repository_state newType newHEAD newMERGE_HEAD
> > >  	if {[string match amend* $commit_type]
> > >  		&& $newType eq {normal}

-- 
Regards,
Pratyush Yadav

  reply index

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-26 21:17 [PATCH 0/1] git-gui: respect core.hooksPath, falling back to .git/hooks Johannes Schindelin via GitGitGadget
2019-09-26 21:17 ` [PATCH 1/1] " Johannes Schindelin via GitGitGadget
2019-09-26 22:36   ` Pratyush Yadav
2019-09-27  6:10     ` Bert Wesarg
2019-09-27 13:05       ` Pratyush Yadav
2019-09-30  9:42         ` Johannes Schindelin
2019-10-01 13:31           ` Pratyush Yadav
2019-10-01 17:38             ` Johannes Schindelin
2019-10-04 16:48               ` Pratyush Yadav
2019-10-04 19:56                 ` Johannes Schindelin
2019-09-30  9:45 ` [PATCH v2 0/1] git-gui: " Johannes Schindelin via GitGitGadget
2019-09-30  9:45   ` [PATCH v2 1/1] " Johannes Schindelin via GitGitGadget
2019-10-04 21:41   ` [PATCH v3 0/1] git-gui: " Johannes Schindelin via GitGitGadget
2019-10-04 21:41     ` [PATCH v3 1/1] Fix gitdir e.g. to respect core.hooksPath Johannes Schindelin via GitGitGadget
2019-10-08  0:29       ` Pratyush Yadav
2019-10-08 11:30         ` Johannes Schindelin
2019-10-08 11:33     ` [PATCH v4 0/1] git-gui: respect core.hooksPath, falling back to .git/hooks Johannes Schindelin via GitGitGadget
2019-10-08 11:33       ` [PATCH v4 1/1] Make gitdir work with worktrees, respect core.hooksPath, etc Johannes Schindelin via GitGitGadget
2019-10-11 22:26         ` Pratyush Yadav
2019-10-12 21:24           ` Johannes Schindelin
2019-10-13 18:55             ` Pratyush Yadav [this message]
2019-10-13 22:18               ` Johannes Schindelin
2019-10-17 18:34                 ` Pratyush Yadav
2019-10-14  8:14               ` Johannes Schindelin

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=20191013185540.fwyn4ox5dbyxgvnh@yadavpratyush.com \
    --to=me@yadavpratyush.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=bert.wesarg@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@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

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git