git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Pratyush Yadav <me@yadavpratyush.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>,
	git <git@vger.kernel.org>,
	Christian Couder <christian.couder@gmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] git-gui: Perform rescan on window focus-in
Date: Mon, 29 Jul 2019 03:40:29 +0530	[thread overview]
Message-ID: <e3f296a6-f33b-7b52-c4cb-9acf65145e64@yadavpratyush.com> (raw)
In-Reply-To: <20190728213634.GB162590@genre.crustytoothpaste.net>

Hi Brian,

On 29/07/19 3:06 AM, brian m. carlson wrote:
> On 2019-07-28 at 15:17:26, Pratyush Yadav wrote:
>> If any changes are made to the tree while git-gui is open, the user has
>> to manually rescan to see those changes in the gui. With this change, a
>> rescan will be performed whenever the window comes in focus, removing
>> the need for manual rescans in most cases. A manual rescan will still be
>> needed when something makes changes to the tree while git-gui is still
>> in focus.
> 
> I don't use git-gui, so I have no opinion on this change either way, but
> I do have some questions.
> 
> What exactly is involved in a rescan? Is it potentially expensive? If
> so, it might be better to leave it explicit, since people can
> accidentally give focus to the wrong window (bad click, focus follows
> mouse, etc.).
> 

The function is not documented, and I only started spelunking the code a 
couple days back, so I'll try to answer with what I know. It might not 
be the full picture.

Running git-gui --trace, these commands are executed during a rescan:

/usr/lib/git-core/git-rev-parse --verify HEAD
/usr/lib/git-core/git-update-index -q --unmerged --ignore-missing --refresh

Since I'm not too familiar with the details of these, I'll let you be 
the judge on how expensive these operations are. But I'll add that 
rescans are pretty fast on my relatively slow hard disk.

> Is there ever a situation in which someone might want to see the old
> state? For example, would a rescan change the active commit shown?
> Someone might be looking at a particular commit message or object ID for
> the current commit; would this interfere with that?

At least in my workflow, there is no such situation. I use git-gui to 
look at uncommitted changes, and stage and commit them. To look at older 
commits, I use gitk. And from what I understand, git-gui is not designed 
to browse old commits. In the options menu, it simply opens gitk if you 
click "Visualise master's history". There is no history browsing in 
git-gui itself.

Yes, a rescan will remove the old commit and will show the latest 
changes. This includes the old diff that was there before it was 
committed or removed from outside of git-gui. So this change will 
certainly interfere with the old state.

> 
>> diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
>> index 6de74ce639..8ca2033dc8 100755
>> --- a/git-gui/git-gui.sh
>> +++ b/git-gui/git-gui.sh
>> @@ -3849,6 +3849,7 @@ if {[is_enabled transport]} {
>>   }
>>   
>>   bind .   <Key-F5>     ui_do_rescan
>> +bind .   <FocusIn>    do_rescan
> 
> What's the difference between these two? Why are we using do_rescan
> instead of ui_do_rescan?
> 

ui_do_rescan changes the focus to the first diff. It is executed when 
you press F5 or choose Rescan from the menu. do_rescan does not do that.

Resetting to first diff on focus change will get annoying when you are 
in the middle of looking at some other file. do_rescan just updates the 
software state without changing what file you are looking at or where in 
that file you are looking at.

>>   bind .   <$M1B-Key-r> ui_do_rescan
>>   bind .   <$M1B-Key-R> ui_do_rescan
>>   bind .   <$M1B-Key-s> do_signoff
> 
> The answers to a lot of these questions can go in your commit message to
> help reviewers and future readers understand your change better.
> 

I'm never too sure what I should put in the commit message, so I took 
the conservative route. I'll add more details in the v2 patch.

-- 
Regards,
Pratyush Yadav

  reply	other threads:[~2019-07-28 22:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-28 15:17 Pratyush Yadav
2019-07-28 21:36 ` brian m. carlson
2019-07-28 22:10   ` Pratyush Yadav [this message]
2019-07-28 22:32     ` Pratyush Yadav
2019-07-28 22:49     ` brian m. carlson
2019-07-29  2:24       ` Mark Levedahl
2019-07-29  2:26       ` Mark Levedahl
2019-07-29  2:28       ` Mark Levedahl
2019-07-29  8:15         ` Pratyush Yadav
2019-07-31 19:42           ` Johannes Schindelin
2019-08-01 21:52             ` Pratyush Yadav
2019-08-02 12:39               ` Johannes Schindelin
2019-08-02 20:00                 ` Pratyush Yadav
2019-08-03 20:34                   ` Johannes Schindelin
2019-08-04 12:53                     ` Pratyush Yadav
2019-08-04 19:10                       ` Johannes Schindelin
2019-08-04 20:17                         ` Pratyush Yadav
2019-08-02 16:47               ` Junio C Hamano
2019-08-02 20:13                 ` Pratyush Yadav
2019-08-04 18:56                   ` Johannes Schindelin
2019-07-29  5:09       ` Junio C Hamano
2019-07-29  8:44         ` Pratyush Yadav
2019-07-28 21:44 ` Pratyush Yadav

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=e3f296a6-f33b-7b52-c4cb-9acf65145e64@yadavpratyush.com \
    --to=me@yadavpratyush.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sandals@crustytoothpaste.net \
    --subject='Re: [PATCH] git-gui: Perform rescan on window focus-in' \
    /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

Code repositories for project(s) associated with this 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).