All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Pratyush Yadav <me@yadavpratyush.com>
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: Sat, 12 Oct 2019 23:24:12 +0200 (CEST)	[thread overview]
Message-ID: <nycvar.QRO.7.76.6.1910122321211.3272@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <20191011222611.le5lyf6mr5lmvbbd@yadavpratyush.com>

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.

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	other threads:[~2019-10-12 21:24 UTC|newest]

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 [this message]
2019-10-13 18:55             ` Pratyush Yadav
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

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

  git send-email \
    --in-reply-to=nycvar.QRO.7.76.6.1910122321211.3272@tvgsbejvaqbjf.bet \
    --to=johannes.schindelin@gmx.de \
    --cc=bert.wesarg@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=me@yadavpratyush.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.