git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/2] git-gui: Auto-rescan on activate
@ 2020-11-01 17:05 Stefan Haller
  2020-11-01 17:05 ` [PATCH 1/2] git-gui: Delay rescan until idle time Stefan Haller
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Stefan Haller @ 2020-11-01 17:05 UTC (permalink / raw)
  To: git; +Cc: me

Do an automatic rescan whenever the git-gui window receives focus. Most other
GUI tools do this, and it's very convenient; no more pressing F5 manually.

People who don't like this behavior can turn it off using
"git config gui.autorescan false".

Stefan Haller (2):
  git-gui: Delay rescan until idle time
  git-gui: Auto-rescan on activate

 git-gui.sh | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

--
2.29.2


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/2] git-gui: Delay rescan until idle time
  2020-11-01 17:05 [PATCH 0/2] git-gui: Auto-rescan on activate Stefan Haller
@ 2020-11-01 17:05 ` Stefan Haller
  2020-11-02 15:45   ` Pratyush Yadav
  2020-11-01 17:05 ` [PATCH 2/2] git-gui: Auto-rescan on activate Stefan Haller
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 21+ messages in thread
From: Stefan Haller @ 2020-11-01 17:05 UTC (permalink / raw)
  To: git; +Cc: me

This is to ensure that a rescan is only performed once, even if it is
requested multiple times during one event. We don't need this yet, because
we only ever call do_rescan once per event so far; this is going to change
with the next commit, when we also call it from FocusIn.

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
---
 git-gui.sh | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index 867b8ce..8864c14 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2376,8 +2376,21 @@ proc do_quit {{rc {1}}} {
 	destroy .
 }
 
+# Not to be called directly; use schedule_rescan instead
 proc do_rescan {} {
+	global rescan_id
+
 	rescan ui_ready
+	unset rescan_id
+}
+
+proc schedule_rescan {} {
+	global rescan_id
+
+	if {[info exists rescan_id]} {
+		after cancel $rescan_id
+	}
+	set rescan_id [after idle do_rescan]
 }
 
 proc ui_do_rescan {} {
@@ -3683,7 +3696,7 @@ set ui_diff_applyhunk [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]
 $ctxm add command \
 	-label [mc "Apply/Reverse Line"] \
-	-command {apply_or_revert_range_or_line $cursorX $cursorY 0; do_rescan}
+	-command {apply_or_revert_range_or_line $cursorX $cursorY 0; schedule_rescan}
 set ui_diff_applyline [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]
 $ctxm add separator
@@ -3694,12 +3707,12 @@ set ui_diff_reverthunk [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_reverthunk -state]
 $ctxm add command \
 	-label [mc "Revert Line"] \
-	-command {apply_or_revert_range_or_line $cursorX $cursorY 1; do_rescan}
+	-command {apply_or_revert_range_or_line $cursorX $cursorY 1; schedule_rescan}
 set ui_diff_revertline [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_revertline -state]
 $ctxm add command \
 	-label [mc "Undo Last Revert"] \
-	-command {undo_last_revert; do_rescan}
+	-command {undo_last_revert; schedule_rescan}
 set ui_diff_undorevert [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_undorevert -state]
 $ctxm add separator
@@ -4171,7 +4184,7 @@ after 1 {
 	if {[is_enabled initialamend]} {
 		force_amend
 	} else {
-		do_rescan
+		schedule_rescan
 	}
 
 	if {[is_enabled nocommitmsg]} {
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/2] git-gui: Auto-rescan on activate
  2020-11-01 17:05 [PATCH 0/2] git-gui: Auto-rescan on activate Stefan Haller
  2020-11-01 17:05 ` [PATCH 1/2] git-gui: Delay rescan until idle time Stefan Haller
@ 2020-11-01 17:05 ` Stefan Haller
  2020-11-02 15:48   ` Pratyush Yadav
  2020-11-02 13:15 ` [PATCH 0/2] " Pratyush Yadav
  2020-12-17 19:45 ` [PATCH 0/2] " Johannes Sixt
  3 siblings, 1 reply; 21+ messages in thread
From: Stefan Haller @ 2020-11-01 17:05 UTC (permalink / raw)
  To: git; +Cc: me

Do an automatic rescan whenever the git-gui window receives focus. Most other
GUI tools do this, and it's very convenient; no more pressing F5 manually.

People who don't like this behavior can turn it off using
"git config gui.autorescan false".

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
---
 git-gui.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/git-gui.sh b/git-gui.sh
index 8864c14..4a4ac19 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -906,6 +906,7 @@ set font_descs {
 }
 set default_config(gui.stageuntracked) ask
 set default_config(gui.displayuntracked) true
+set default_config(gui.autorescan) true
 
 ######################################################################
 ##
@@ -4020,6 +4021,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}
 bind .   <Alt-Key-3> {focus $::ui_diff}
 bind .   <Alt-Key-4> {focus $::ui_comm}
 
+if {[is_config_true gui.autorescan]} {
+	bind .   <FocusIn>  schedule_rescan
+}
+
 set file_lists_last_clicked($ui_index) {}
 set file_lists_last_clicked($ui_workdir) {}
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/2] git-gui: Auto-rescan on activate
  2020-11-01 17:05 [PATCH 0/2] git-gui: Auto-rescan on activate Stefan Haller
  2020-11-01 17:05 ` [PATCH 1/2] git-gui: Delay rescan until idle time Stefan Haller
  2020-11-01 17:05 ` [PATCH 2/2] git-gui: Auto-rescan on activate Stefan Haller
@ 2020-11-02 13:15 ` Pratyush Yadav
  2020-11-02 19:24   ` Stefan Haller
  2020-12-17 19:45 ` [PATCH 0/2] " Johannes Sixt
  3 siblings, 1 reply; 21+ messages in thread
From: Pratyush Yadav @ 2020-11-02 13:15 UTC (permalink / raw)
  To: Stefan Haller; +Cc: git

Hi Stefan,

On 01/11/20 06:05PM, Stefan Haller wrote:
> Do an automatic rescan whenever the git-gui window receives focus. Most other
> GUI tools do this, and it's very convenient; no more pressing F5 manually.

I submitted a patch for this a while back but there was a lengthy 
discussion. [0] would be a good read. IIRC the major blocker was that 
rescan is a very expensive operation on Windows.
 
> People who don't like this behavior can turn it off using
> "git config gui.autorescan false".

To make sure the experience on Windows (and for anyone who faces long 
rescan times) does not degrade, I think we should keep this off by 
default. That said, I would love to be convinced to keep this on by 
default because IMO this is a really good feature to have. I tried 
coming up with ways to avoid slowdowns while keeping the auto rescan on 
but I didn't come up with anything convincing.
 
> Stefan Haller (2):
>   git-gui: Delay rescan until idle time
>   git-gui: Auto-rescan on activate
> 
>  git-gui.sh | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
> 

[0] https://lore.kernel.org/git/20190728151726.9188-1-me@yadavpratyush.com/

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/2] git-gui: Delay rescan until idle time
  2020-11-01 17:05 ` [PATCH 1/2] git-gui: Delay rescan until idle time Stefan Haller
@ 2020-11-02 15:45   ` Pratyush Yadav
  2020-11-02 19:29     ` Stefan Haller
  0 siblings, 1 reply; 21+ messages in thread
From: Pratyush Yadav @ 2020-11-02 15:45 UTC (permalink / raw)
  To: Stefan Haller; +Cc: git

Hi Stefan,

On 01/11/20 06:05PM, Stefan Haller wrote:
> This is to ensure that a rescan is only performed once, even if it is
> requested multiple times during one event. We don't need this yet, because
> we only ever call do_rescan once per event so far; this is going to change
> with the next commit, when we also call it from FocusIn.

I don't understand what this is trying to achieve. The calls to 
do_rescan below only happen when the user explicitly does something, 
like stage/unstage selected lines. Why would that event coincide with 
the FocusIn event?

If you mean to account for a situation where the rescan for 
"Apply/Reverse Line" is executed before the rescan from FocusIn 
finishes, then in that case the procedure rescan already accounts for it 
by checking $rescan_active and the index lock.

Have you noticed multiple rescans in parallel? If yes then we might want 
to look at why the check is not working.
 
> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
> ---
>  git-gui.sh | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/git-gui.sh b/git-gui.sh
> index 867b8ce..8864c14 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -2376,8 +2376,21 @@ proc do_quit {{rc {1}}} {
>  	destroy .
>  }
>  
> +# Not to be called directly; use schedule_rescan instead
>  proc do_rescan {} {
> +	global rescan_id
> +
>  	rescan ui_ready
> +	unset rescan_id

Not sure if you're aware of it already, but it is worth mentioning that 
rescan is asynchronous. The procedure call will return before the rescan 
in actually complete. See the `fileevent` calls in rescan and 
rescan_stage2.

So in this case, rescan_id will be unset before the rescan is actually 
done. This can be the right or wrong thing depending on what you want to 
accomplish, which I'm not clear on.

> +}
> +
> +proc schedule_rescan {} {
> +	global rescan_id
> +
> +	if {[info exists rescan_id]} {
> +		after cancel $rescan_id
> +	}
> +	set rescan_id [after idle do_rescan]
>  }
>  
>  proc ui_do_rescan {} {
> @@ -3683,7 +3696,7 @@ set ui_diff_applyhunk [$ctxm index last]
>  lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]
>  $ctxm add command \
>  	-label [mc "Apply/Reverse Line"] \
> -	-command {apply_or_revert_range_or_line $cursorX $cursorY 0; do_rescan}
> +	-command {apply_or_revert_range_or_line $cursorX $cursorY 0; schedule_rescan}
>  set ui_diff_applyline [$ctxm index last]
>  lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]
>  $ctxm add separator
> @@ -3694,12 +3707,12 @@ set ui_diff_reverthunk [$ctxm index last]
>  lappend diff_actions [list $ctxm entryconf $ui_diff_reverthunk -state]
>  $ctxm add command \
>  	-label [mc "Revert Line"] \
> -	-command {apply_or_revert_range_or_line $cursorX $cursorY 1; do_rescan}
> +	-command {apply_or_revert_range_or_line $cursorX $cursorY 1; schedule_rescan}
>  set ui_diff_revertline [$ctxm index last]
>  lappend diff_actions [list $ctxm entryconf $ui_diff_revertline -state]
>  $ctxm add command \
>  	-label [mc "Undo Last Revert"] \
> -	-command {undo_last_revert; do_rescan}
> +	-command {undo_last_revert; schedule_rescan}
>  set ui_diff_undorevert [$ctxm index last]
>  lappend diff_actions [list $ctxm entryconf $ui_diff_undorevert -state]
>  $ctxm add separator
> @@ -4171,7 +4184,7 @@ after 1 {
>  	if {[is_enabled initialamend]} {
>  		force_amend
>  	} else {
> -		do_rescan
> +		schedule_rescan
>  	}
>  
>  	if {[is_enabled nocommitmsg]} {
> -- 
> 2.29.2
> 

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/2] git-gui: Auto-rescan on activate
  2020-11-01 17:05 ` [PATCH 2/2] git-gui: Auto-rescan on activate Stefan Haller
@ 2020-11-02 15:48   ` Pratyush Yadav
  2020-11-02 19:31     ` Stefan Haller
  0 siblings, 1 reply; 21+ messages in thread
From: Pratyush Yadav @ 2020-11-02 15:48 UTC (permalink / raw)
  To: Stefan Haller; +Cc: git

Hi Stefan,

On 01/11/20 06:05PM, Stefan Haller wrote:
> Do an automatic rescan whenever the git-gui window receives focus. Most other
> GUI tools do this, and it's very convenient; no more pressing F5 manually.
> 
> People who don't like this behavior can turn it off using
> "git config gui.autorescan false".
> 
> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
> ---
>  git-gui.sh | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/git-gui.sh b/git-gui.sh
> index 8864c14..4a4ac19 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -906,6 +906,7 @@ set font_descs {
>  }
>  set default_config(gui.stageuntracked) ask
>  set default_config(gui.displayuntracked) true
> +set default_config(gui.autorescan) true

Default to false. See my reply to the cover letter for more info.

It would also be a good idea to include an option for this in the 
options dialog. Check do_options in lib/options.tcl for examples.

>  
>  ######################################################################
>  ##
> @@ -4020,6 +4021,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}
>  bind .   <Alt-Key-3> {focus $::ui_diff}
>  bind .   <Alt-Key-4> {focus $::ui_comm}
>  
> +if {[is_config_true gui.autorescan]} {
> +	bind .   <FocusIn>  schedule_rescan
> +}
> +

Ok.

>  set file_lists_last_clicked($ui_index) {}
>  set file_lists_last_clicked($ui_workdir) {}
>  
> -- 
> 2.29.2
> 

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/2] git-gui: Auto-rescan on activate
  2020-11-02 13:15 ` [PATCH 0/2] " Pratyush Yadav
@ 2020-11-02 19:24   ` Stefan Haller
  2020-11-03 16:16     ` [PATCH v2 0/1] " Stefan Haller
  0 siblings, 1 reply; 21+ messages in thread
From: Stefan Haller @ 2020-11-02 19:24 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: git

On 02.11.20 14:15, Pratyush Yadav wrote:
> Hi Stefan,
> 
> On 01/11/20 06:05PM, Stefan Haller wrote:
>> Do an automatic rescan whenever the git-gui window receives focus. Most other
>> GUI tools do this, and it's very convenient; no more pressing F5 manually.
> 
> I submitted a patch for this a while back but there was a lengthy 
> discussion. [0] would be a good read. IIRC the major blocker was that 
> rescan is a very expensive operation on Windows.

Ah, thanks for reminding me of that. I did actually read the discussion
back then, but had completely forgotten about it.

>> People who don't like this behavior can turn it off using
>> "git config gui.autorescan false".
> 
> To make sure the experience on Windows (and for anyone who faces long 
> rescan times) does not degrade, I think we should keep this off by 
> default. That said, I would love to be convinced to keep this on by 
> default because IMO this is a really good feature to have. I tried 
> coming up with ways to avoid slowdowns while keeping the auto rescan on 
> but I didn't come up with anything convincing.

I still think the default should be on; I consider it more important
that the information is accurate than that it is shown without delay. I
do use Windows occasionally myself, in a slow VM no less, and it does
annoy me that a rescan is so slow there; however, I still prefer that
over looking at stale information without realizing it.

Also, I had a look at how other git clients deal with this. I didn't do
an exhaustive research, just quickly looked at a few:

- Fork (https://git-fork.com)
  Rescans on activate. There's no setting to turn this off. (!)

- SourceTree (https://www.sourcetreeapp.com)
  Rescans on activate. There's an option to turn this off, but it
  defaults to on. (It is confusingly called "Refresh automatically when
  files change", which doesn't seem to be accurate, as far as I can
  tell.)

- Visual Studio Code
  Rescans on activate. There's an option to turn it off, but it defaults
  to on.

- Sublime Merge (https://www.sublimemerge.com)
  Watches files and rescans in the background.

So I would say there's plenty of precedence for having this behavior
default to on.

>> Stefan Haller (2):
>>   git-gui: Delay rescan until idle time
>>   git-gui: Auto-rescan on activate
>>
>>  git-gui.sh | 26 ++++++++++++++++++++++----
>>  1 file changed, 22 insertions(+), 4 deletions(-)
>>
> 
> [0] https://lore.kernel.org/git/20190728151726.9188-1-me@yadavpratyush.com/
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/2] git-gui: Delay rescan until idle time
  2020-11-02 15:45   ` Pratyush Yadav
@ 2020-11-02 19:29     ` Stefan Haller
  0 siblings, 0 replies; 21+ messages in thread
From: Stefan Haller @ 2020-11-02 19:29 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: git

On 02.11.20 16:45, Pratyush Yadav wrote:
> Hi Stefan,
> 
> On 01/11/20 06:05PM, Stefan Haller wrote:
>> This is to ensure that a rescan is only performed once, even if it is
>> requested multiple times during one event. We don't need this yet, because
>> we only ever call do_rescan once per event so far; this is going to change
>> with the next commit, when we also call it from FocusIn.
> 
> I don't understand what this is trying to achieve. The calls to 
> do_rescan below only happen when the user explicitly does something, 
> like stage/unstage selected lines. Why would that event coincide with 
> the FocusIn event?
> 
> If you mean to account for a situation where the rescan for 
> "Apply/Reverse Line" is executed before the rescan from FocusIn 
> finishes, then in that case the procedure rescan already accounts for it 
> by checking $rescan_active and the index lock.

I'm aware that the rescan runs asynchronously, but I wasn't worried
about the case where it's triggered concurrently while another one is
running already; I was worried about the case where a rescan (e.g.
coming from "Apply/Reverse Line") was so fast that it was already
finished by the time the FocusIn comes. But I guess I misunderstood Tk's
threading model, and this can never happen.

So it does indeed seem that the existing $rescan_active logic is enough
to prevent unnecessary rescans; I'll drop this commit.

> Have you noticed multiple rescans in parallel? If yes then we might want 
> to look at why the check is not working.
>  
>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
>> ---
>>  git-gui.sh | 21 +++++++++++++++++----
>>  1 file changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/git-gui.sh b/git-gui.sh
>> index 867b8ce..8864c14 100755
>> --- a/git-gui.sh
>> +++ b/git-gui.sh
>> @@ -2376,8 +2376,21 @@ proc do_quit {{rc {1}}} {
>>  	destroy .
>>  }
>>  
>> +# Not to be called directly; use schedule_rescan instead
>>  proc do_rescan {} {
>> +	global rescan_id
>> +
>>  	rescan ui_ready
>> +	unset rescan_id
> 
> Not sure if you're aware of it already, but it is worth mentioning that 
> rescan is asynchronous. The procedure call will return before the rescan 
> in actually complete. See the `fileevent` calls in rescan and 
> rescan_stage2.
> 
> So in this case, rescan_id will be unset before the rescan is actually 
> done. This can be the right or wrong thing depending on what you want to 
> accomplish, which I'm not clear on.
> 
>> +}
>> +
>> +proc schedule_rescan {} {
>> +	global rescan_id
>> +
>> +	if {[info exists rescan_id]} {
>> +		after cancel $rescan_id
>> +	}
>> +	set rescan_id [after idle do_rescan]
>>  }
>>  
>>  proc ui_do_rescan {} {
>> @@ -3683,7 +3696,7 @@ set ui_diff_applyhunk [$ctxm index last]
>>  lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]
>>  $ctxm add command \
>>  	-label [mc "Apply/Reverse Line"] \
>> -	-command {apply_or_revert_range_or_line $cursorX $cursorY 0; do_rescan}
>> +	-command {apply_or_revert_range_or_line $cursorX $cursorY 0; schedule_rescan}
>>  set ui_diff_applyline [$ctxm index last]
>>  lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]
>>  $ctxm add separator
>> @@ -3694,12 +3707,12 @@ set ui_diff_reverthunk [$ctxm index last]
>>  lappend diff_actions [list $ctxm entryconf $ui_diff_reverthunk -state]
>>  $ctxm add command \
>>  	-label [mc "Revert Line"] \
>> -	-command {apply_or_revert_range_or_line $cursorX $cursorY 1; do_rescan}
>> +	-command {apply_or_revert_range_or_line $cursorX $cursorY 1; schedule_rescan}
>>  set ui_diff_revertline [$ctxm index last]
>>  lappend diff_actions [list $ctxm entryconf $ui_diff_revertline -state]
>>  $ctxm add command \
>>  	-label [mc "Undo Last Revert"] \
>> -	-command {undo_last_revert; do_rescan}
>> +	-command {undo_last_revert; schedule_rescan}
>>  set ui_diff_undorevert [$ctxm index last]
>>  lappend diff_actions [list $ctxm entryconf $ui_diff_undorevert -state]
>>  $ctxm add separator
>> @@ -4171,7 +4184,7 @@ after 1 {
>>  	if {[is_enabled initialamend]} {
>>  		force_amend
>>  	} else {
>> -		do_rescan
>> +		schedule_rescan
>>  	}
>>  
>>  	if {[is_enabled nocommitmsg]} {
>> -- 
>> 2.29.2
>>
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/2] git-gui: Auto-rescan on activate
  2020-11-02 15:48   ` Pratyush Yadav
@ 2020-11-02 19:31     ` Stefan Haller
  0 siblings, 0 replies; 21+ messages in thread
From: Stefan Haller @ 2020-11-02 19:31 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: git

On 02.11.20 16:48, Pratyush Yadav wrote:
> Hi Stefan,
> 
> On 01/11/20 06:05PM, Stefan Haller wrote:
>> Do an automatic rescan whenever the git-gui window receives focus. Most other
>> GUI tools do this, and it's very convenient; no more pressing F5 manually.
>>
>> People who don't like this behavior can turn it off using
>> "git config gui.autorescan false".
>>
>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
>> ---
>>  git-gui.sh | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/git-gui.sh b/git-gui.sh
>> index 8864c14..4a4ac19 100755
>> --- a/git-gui.sh
>> +++ b/git-gui.sh
>> @@ -906,6 +906,7 @@ set font_descs {
>>  }
>>  set default_config(gui.stageuntracked) ask
>>  set default_config(gui.displayuntracked) true
>> +set default_config(gui.autorescan) true
> 
> Default to false. See my reply to the cover letter for more info.
> 
> It would also be a good idea to include an option for this in the 
> options dialog. Check do_options in lib/options.tcl for examples.

Ok, I'll see if I can add a checkbox in the dialog. Might take a few
days until I have time for doing a re-roll.


>>  
>>  ######################################################################
>>  ##
>> @@ -4020,6 +4021,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}
>>  bind .   <Alt-Key-3> {focus $::ui_diff}
>>  bind .   <Alt-Key-4> {focus $::ui_comm}
>>  
>> +if {[is_config_true gui.autorescan]} {
>> +	bind .   <FocusIn>  schedule_rescan
>> +}
>> +
> 
> Ok.
> 
>>  set file_lists_last_clicked($ui_index) {}
>>  set file_lists_last_clicked($ui_workdir) {}
>>  
>> -- 
>> 2.29.2
>>
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v2 0/1] git-gui: Auto-rescan on activate
  2020-11-02 19:24   ` Stefan Haller
@ 2020-11-03 16:16     ` Stefan Haller
  2020-11-03 16:16       ` [PATCH v2 1/1] " Stefan Haller
  0 siblings, 1 reply; 21+ messages in thread
From: Stefan Haller @ 2020-11-03 16:16 UTC (permalink / raw)
  To: me; +Cc: git

Changes in v2:
- dropped the unnecessary "after idle" logic
- do the rescan only for the top-level widget; this avoids unnecessary rescans
  when switching focus between sub-panes
- add a checkbox to the options dialog

As explained earlier, I still very much believe that "on" is a good default for
the option, so I kept it that way.

Stefan Haller (1):
  git-gui: Auto-rescan on activate

 git-gui.sh     | 5 +++++
 lib/option.tcl | 1 +
 2 files changed, 6 insertions(+)

--
2.29.2


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v2 1/1] git-gui: Auto-rescan on activate
  2020-11-03 16:16     ` [PATCH v2 0/1] " Stefan Haller
@ 2020-11-03 16:16       ` Stefan Haller
  2020-11-14 19:14         ` Stefan Haller
  0 siblings, 1 reply; 21+ messages in thread
From: Stefan Haller @ 2020-11-03 16:16 UTC (permalink / raw)
  To: me; +Cc: git

Do an automatic rescan whenever the git-gui window receives focus. Most other
GUI tools do this, and it's very convenient; no more pressing F5 manually.

People who don't like this behavior can turn it off in the Options dialog.

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
---
 git-gui.sh     | 5 +++++
 lib/option.tcl | 1 +
 2 files changed, 6 insertions(+)

diff --git a/git-gui.sh b/git-gui.sh
index 867b8ce..14735a3 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -906,6 +906,7 @@ set font_descs {
 }
 set default_config(gui.stageuntracked) ask
 set default_config(gui.displayuntracked) true
+set default_config(gui.autorescan) true

 ######################################################################
 ##
@@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}
 bind .   <Alt-Key-3> {focus $::ui_diff}
 bind .   <Alt-Key-4> {focus $::ui_comm}

+if {[is_config_true gui.autorescan]} {
+	bind .   <FocusIn>  { if {"%W" eq "."} do_rescan }
+}
+
 set file_lists_last_clicked($ui_index) {}
 set file_lists_last_clicked($ui_workdir) {}

diff --git a/lib/option.tcl b/lib/option.tcl
index e43971b..9e83db7 100644
--- a/lib/option.tcl
+++ b/lib/option.tcl
@@ -145,6 +145,7 @@ proc do_options {} {
 		{b merge.diffstat {mc "Show Diffstat After Merge"}}
 		{t merge.tool {mc "Use Merge Tool"}}

+		{b gui.autorescan  {mc "Auto-Rescan On Activate"}}
 		{b gui.trustmtime  {mc "Trust File Modification Timestamps"}}
 		{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
 		{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
--
2.29.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/1] git-gui: Auto-rescan on activate
  2020-11-03 16:16       ` [PATCH v2 1/1] " Stefan Haller
@ 2020-11-14 19:14         ` Stefan Haller
  2020-11-17  7:36           ` Pratyush Yadav
  0 siblings, 1 reply; 21+ messages in thread
From: Stefan Haller @ 2020-11-14 19:14 UTC (permalink / raw)
  To: me; +Cc: git, mlevedahl, Johannes.Schindelin, gitster

On 03.11.20 17:16, Stefan Haller wrote:
> Do an automatic rescan whenever the git-gui window receives focus. Most other
> GUI tools do this, and it's very convenient; no more pressing F5 manually.
> 
> People who don't like this behavior can turn it off in the Options dialog.

Ping - any thoughts? I have been running with this patch for a few weeks
now, and I already don't want to miss it any more.

Cc:-ing a few people who were involved in the discussion on Pratyush's
similar patch last summer. [0]


[0] <https://lore.kernel.org/git/20190728151726.9188-1-
     me@yadavpratyush.com/>


> 
> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
> ---
>  git-gui.sh     | 5 +++++
>  lib/option.tcl | 1 +
>  2 files changed, 6 insertions(+)
> 
> diff --git a/git-gui.sh b/git-gui.sh
> index 867b8ce..14735a3 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -906,6 +906,7 @@ set font_descs {
>  }
>  set default_config(gui.stageuntracked) ask
>  set default_config(gui.displayuntracked) true
> +set default_config(gui.autorescan) true
> 
>  ######################################################################
>  ##
> @@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}
>  bind .   <Alt-Key-3> {focus $::ui_diff}
>  bind .   <Alt-Key-4> {focus $::ui_comm}
> 
> +if {[is_config_true gui.autorescan]} {
> +	bind .   <FocusIn>  { if {"%W" eq "."} do_rescan }
> +}
> +
>  set file_lists_last_clicked($ui_index) {}
>  set file_lists_last_clicked($ui_workdir) {}
> 
> diff --git a/lib/option.tcl b/lib/option.tcl
> index e43971b..9e83db7 100644
> --- a/lib/option.tcl
> +++ b/lib/option.tcl
> @@ -145,6 +145,7 @@ proc do_options {} {
>  		{b merge.diffstat {mc "Show Diffstat After Merge"}}
>  		{t merge.tool {mc "Use Merge Tool"}}
> 
> +		{b gui.autorescan  {mc "Auto-Rescan On Activate"}}
>  		{b gui.trustmtime  {mc "Trust File Modification Timestamps"}}
>  		{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
>  		{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
> --
> 2.29.2
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/1] git-gui: Auto-rescan on activate
  2020-11-14 19:14         ` Stefan Haller
@ 2020-11-17  7:36           ` Pratyush Yadav
  2020-11-17 11:13             ` Stefan Haller
  0 siblings, 1 reply; 21+ messages in thread
From: Pratyush Yadav @ 2020-11-17  7:36 UTC (permalink / raw)
  To: Stefan Haller; +Cc: git, mlevedahl, Johannes.Schindelin, gitster

Hi Stefan,

On 14/11/20 08:14PM, Stefan Haller wrote:
> On 03.11.20 17:16, Stefan Haller wrote:
> > Do an automatic rescan whenever the git-gui window receives focus. Most other
> > GUI tools do this, and it's very convenient; no more pressing F5 manually.
> > 
> > People who don't like this behavior can turn it off in the Options dialog.
> 
> Ping - any thoughts? I have been running with this patch for a few weeks
> now, and I already don't want to miss it any more.

I have been staring at your patch for the last few days with indecision. 
I have finally made up my mind. I do not think it is a good idea to hurt 
the experience of a significant population of our users without at least 
telling them how they can fix it.

The config option is not very visible at all. Experience has told me 
that people don't often go looking around in the options menu to find a 
fix for their problem. So we need to do a better job of educating them 
why they might be experiencing slowdowns and how they can avoid them.

Let's take inspiration from git status. When the local branch diverges 
from the upstream branch, git status shows you how many commits your 
branch is ahead and how many commits behind upstream. This can be an 
expensive operation if the divergence point is far behind. In those 
cases, git status prints something like:

  It took 30.00 seconds to calculate the branch ahead/behind values.
  You can use '--no-ahead-behind' to avoid this.

This made me aware this option existed and that I can use it to avoid 
slowdowns.

We should do something similar for the auto rescan. Measure how long it 
takes to finish the rescan and if it takes longer than X seconds then 
tell the user that they can use this option to disable this. If they 
don't mind the delay they can keep on using it.

I am working on a patch to add this. Will send it in a day or two.
 
> Cc:-ing a few people who were involved in the discussion on Pratyush's
> similar patch last summer. [0]
> 
> 
> [0] <https://lore.kernel.org/git/20190728151726.9188-1-
>      me@yadavpratyush.com/>
> 
> 
> > 
> > Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
> > ---
> >  git-gui.sh     | 5 +++++
> >  lib/option.tcl | 1 +
> >  2 files changed, 6 insertions(+)
> > 
> > diff --git a/git-gui.sh b/git-gui.sh
> > index 867b8ce..14735a3 100755
> > --- a/git-gui.sh
> > +++ b/git-gui.sh
> > @@ -906,6 +906,7 @@ set font_descs {
> >  }
> >  set default_config(gui.stageuntracked) ask
> >  set default_config(gui.displayuntracked) true
> > +set default_config(gui.autorescan) true
> > 
> >  ######################################################################
> >  ##
> > @@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}
> >  bind .   <Alt-Key-3> {focus $::ui_diff}
> >  bind .   <Alt-Key-4> {focus $::ui_comm}
> > 
> > +if {[is_config_true gui.autorescan]} {
> > +	bind .   <FocusIn>  { if {"%W" eq "."} do_rescan }
> > +}
> > +
> >  set file_lists_last_clicked($ui_index) {}
> >  set file_lists_last_clicked($ui_workdir) {}
> > 
> > diff --git a/lib/option.tcl b/lib/option.tcl
> > index e43971b..9e83db7 100644
> > --- a/lib/option.tcl
> > +++ b/lib/option.tcl
> > @@ -145,6 +145,7 @@ proc do_options {} {
> >  		{b merge.diffstat {mc "Show Diffstat After Merge"}}
> >  		{t merge.tool {mc "Use Merge Tool"}}
> > 
> > +		{b gui.autorescan  {mc "Auto-Rescan On Activate"}}
> >  		{b gui.trustmtime  {mc "Trust File Modification Timestamps"}}
> >  		{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
> >  		{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
> > --
> > 2.29.2
> > 

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/1] git-gui: Auto-rescan on activate
  2020-11-17  7:36           ` Pratyush Yadav
@ 2020-11-17 11:13             ` Stefan Haller
  2020-11-17 12:05               ` Pratyush Yadav
  0 siblings, 1 reply; 21+ messages in thread
From: Stefan Haller @ 2020-11-17 11:13 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: git, mlevedahl, Johannes.Schindelin, gitster

On 17.11.20 8:36, Pratyush Yadav wrote:
> Hi Stefan,
> 
> On 14/11/20 08:14PM, Stefan Haller wrote:
>> On 03.11.20 17:16, Stefan Haller wrote:
>>> Do an automatic rescan whenever the git-gui window receives focus. Most other
>>> GUI tools do this, and it's very convenient; no more pressing F5 manually.
>>>
>>> People who don't like this behavior can turn it off in the Options dialog.
>>
>> Ping - any thoughts? I have been running with this patch for a few weeks
>> now, and I already don't want to miss it any more.
> 
> I have been staring at your patch for the last few days with indecision. 
> I have finally made up my mind. I do not think it is a good idea to hurt 
> the experience of a significant population of our users without at least 
> telling them how they can fix it.
> 
> The config option is not very visible at all. Experience has told me 
> that people don't often go looking around in the options menu to find a 
> fix for their problem. So we need to do a better job of educating them 
> why they might be experiencing slowdowns and how they can avoid them.
> 
> Let's take inspiration from git status. When the local branch diverges 
> from the upstream branch, git status shows you how many commits your 
> branch is ahead and how many commits behind upstream. This can be an 
> expensive operation if the divergence point is far behind. In those 
> cases, git status prints something like:
> 
>   It took 30.00 seconds to calculate the branch ahead/behind values.
>   You can use '--no-ahead-behind' to avoid this.
> 
> This made me aware this option existed and that I can use it to avoid 
> slowdowns.
> 
> We should do something similar for the auto rescan. Measure how long it 
> takes to finish the rescan and if it takes longer than X seconds then 
> tell the user that they can use this option to disable this. If they 
> don't mind the delay they can keep on using it.
> 
> I am working on a patch to add this. Will send it in a day or two.

Sounds good to me. While I personally don't think such a check is
necessary in this case, I also have nothing against it if you find it
important.

It just needs to be possible to disable that check itself, too. I
certainly wouldn't want to be bothered by it, even if the rescan should
take longer than whatever threshold you decide on. So if you put up a
dialog to inform the user, the dialog should ideally have a "Don't show
again" option.


>> Cc:-ing a few people who were involved in the discussion on Pratyush's
>> similar patch last summer. [0]
>>
>>
>> [0] <https://lore.kernel.org/git/20190728151726.9188-1-
>>      me@yadavpratyush.com/>
>>
>>
>>>
>>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
>>> ---
>>>  git-gui.sh     | 5 +++++
>>>  lib/option.tcl | 1 +
>>>  2 files changed, 6 insertions(+)
>>>
>>> diff --git a/git-gui.sh b/git-gui.sh
>>> index 867b8ce..14735a3 100755
>>> --- a/git-gui.sh
>>> +++ b/git-gui.sh
>>> @@ -906,6 +906,7 @@ set font_descs {
>>>  }
>>>  set default_config(gui.stageuntracked) ask
>>>  set default_config(gui.displayuntracked) true
>>> +set default_config(gui.autorescan) true
>>>
>>>  ######################################################################
>>>  ##
>>> @@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}
>>>  bind .   <Alt-Key-3> {focus $::ui_diff}
>>>  bind .   <Alt-Key-4> {focus $::ui_comm}
>>>
>>> +if {[is_config_true gui.autorescan]} {
>>> +	bind .   <FocusIn>  { if {"%W" eq "."} do_rescan }
>>> +}
>>> +
>>>  set file_lists_last_clicked($ui_index) {}
>>>  set file_lists_last_clicked($ui_workdir) {}
>>>
>>> diff --git a/lib/option.tcl b/lib/option.tcl
>>> index e43971b..9e83db7 100644
>>> --- a/lib/option.tcl
>>> +++ b/lib/option.tcl
>>> @@ -145,6 +145,7 @@ proc do_options {} {
>>>  		{b merge.diffstat {mc "Show Diffstat After Merge"}}
>>>  		{t merge.tool {mc "Use Merge Tool"}}
>>>
>>> +		{b gui.autorescan  {mc "Auto-Rescan On Activate"}}
>>>  		{b gui.trustmtime  {mc "Trust File Modification Timestamps"}}
>>>  		{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
>>>  		{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
>>> --
>>> 2.29.2
>>>
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/1] git-gui: Auto-rescan on activate
  2020-11-17 11:13             ` Stefan Haller
@ 2020-11-17 12:05               ` Pratyush Yadav
  2020-11-18  9:17                 ` Stefan Haller
  0 siblings, 1 reply; 21+ messages in thread
From: Pratyush Yadav @ 2020-11-17 12:05 UTC (permalink / raw)
  To: Stefan Haller; +Cc: git, mlevedahl, Johannes.Schindelin, gitster

On 17/11/20 12:13PM, Stefan Haller wrote:
> On 17.11.20 8:36, Pratyush Yadav wrote:
> > Hi Stefan,
> > 
> > On 14/11/20 08:14PM, Stefan Haller wrote:
> >> On 03.11.20 17:16, Stefan Haller wrote:
> >>> Do an automatic rescan whenever the git-gui window receives focus. Most other
> >>> GUI tools do this, and it's very convenient; no more pressing F5 manually.
> >>>
> >>> People who don't like this behavior can turn it off in the Options dialog.
> >>
> >> Ping - any thoughts? I have been running with this patch for a few weeks
> >> now, and I already don't want to miss it any more.
> > 
> > I have been staring at your patch for the last few days with indecision. 
> > I have finally made up my mind. I do not think it is a good idea to hurt 
> > the experience of a significant population of our users without at least 
> > telling them how they can fix it.
> > 
> > The config option is not very visible at all. Experience has told me 
> > that people don't often go looking around in the options menu to find a 
> > fix for their problem. So we need to do a better job of educating them 
> > why they might be experiencing slowdowns and how they can avoid them.
> > 
> > Let's take inspiration from git status. When the local branch diverges 
> > from the upstream branch, git status shows you how many commits your 
> > branch is ahead and how many commits behind upstream. This can be an 
> > expensive operation if the divergence point is far behind. In those 
> > cases, git status prints something like:
> > 
> >   It took 30.00 seconds to calculate the branch ahead/behind values.
> >   You can use '--no-ahead-behind' to avoid this.
> > 
> > This made me aware this option existed and that I can use it to avoid 
> > slowdowns.
> > 
> > We should do something similar for the auto rescan. Measure how long it 
> > takes to finish the rescan and if it takes longer than X seconds then 
> > tell the user that they can use this option to disable this. If they 
> > don't mind the delay they can keep on using it.
> > 
> > I am working on a patch to add this. Will send it in a day or two.
> 
> Sounds good to me. While I personally don't think such a check is
> necessary in this case, I also have nothing against it if you find it
> important.
> 
> It just needs to be possible to disable that check itself, too. I
> certainly wouldn't want to be bothered by it, even if the rescan should
> take longer than whatever threshold you decide on. So if you put up a
> dialog to inform the user, the dialog should ideally have a "Don't show
> again" option.

That's the plan. It will be a yes/no/cancel prompt. Saying yes or no 
sets auto rescan to on/off and the message won't pop up again. Saying 
cancel does nothing and you will see the popup again on the next long 
rescan.
 
> 
> >> Cc:-ing a few people who were involved in the discussion on Pratyush's
> >> similar patch last summer. [0]
> >>
> >>
> >> [0] <https://lore.kernel.org/git/20190728151726.9188-1-
> >>      me@yadavpratyush.com/>
> >>
> >>
> >>>
> >>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
> >>> ---
> >>>  git-gui.sh     | 5 +++++
> >>>  lib/option.tcl | 1 +
> >>>  2 files changed, 6 insertions(+)
> >>>
> >>> diff --git a/git-gui.sh b/git-gui.sh
> >>> index 867b8ce..14735a3 100755
> >>> --- a/git-gui.sh
> >>> +++ b/git-gui.sh
> >>> @@ -906,6 +906,7 @@ set font_descs {
> >>>  }
> >>>  set default_config(gui.stageuntracked) ask
> >>>  set default_config(gui.displayuntracked) true
> >>> +set default_config(gui.autorescan) true
> >>>
> >>>  ######################################################################
> >>>  ##
> >>> @@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}
> >>>  bind .   <Alt-Key-3> {focus $::ui_diff}
> >>>  bind .   <Alt-Key-4> {focus $::ui_comm}
> >>>
> >>> +if {[is_config_true gui.autorescan]} {
> >>> +	bind .   <FocusIn>  { if {"%W" eq "."} do_rescan }
> >>> +}
> >>> +
> >>>  set file_lists_last_clicked($ui_index) {}
> >>>  set file_lists_last_clicked($ui_workdir) {}
> >>>
> >>> diff --git a/lib/option.tcl b/lib/option.tcl
> >>> index e43971b..9e83db7 100644
> >>> --- a/lib/option.tcl
> >>> +++ b/lib/option.tcl
> >>> @@ -145,6 +145,7 @@ proc do_options {} {
> >>>  		{b merge.diffstat {mc "Show Diffstat After Merge"}}
> >>>  		{t merge.tool {mc "Use Merge Tool"}}
> >>>
> >>> +		{b gui.autorescan  {mc "Auto-Rescan On Activate"}}
> >>>  		{b gui.trustmtime  {mc "Trust File Modification Timestamps"}}
> >>>  		{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
> >>>  		{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
> >>> --
> >>> 2.29.2
> >>>
> > 

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/1] git-gui: Auto-rescan on activate
  2020-11-17 12:05               ` Pratyush Yadav
@ 2020-11-18  9:17                 ` Stefan Haller
  0 siblings, 0 replies; 21+ messages in thread
From: Stefan Haller @ 2020-11-18  9:17 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: git, mlevedahl, Johannes.Schindelin, gitster

On 17.11.20 13:05, Pratyush Yadav wrote:
> On 17/11/20 12:13PM, Stefan Haller wrote:
>> On 17.11.20 8:36, Pratyush Yadav wrote:
>>> Hi Stefan,
>>>
>>> On 14/11/20 08:14PM, Stefan Haller wrote:
>>>> On 03.11.20 17:16, Stefan Haller wrote:
>>>>> Do an automatic rescan whenever the git-gui window receives focus. Most other
>>>>> GUI tools do this, and it's very convenient; no more pressing F5 manually.
>>>>>
>>>>> People who don't like this behavior can turn it off in the Options dialog.
>>>>
>>>> Ping - any thoughts? I have been running with this patch for a few weeks
>>>> now, and I already don't want to miss it any more.
>>>
>>> I have been staring at your patch for the last few days with indecision. 
>>> I have finally made up my mind. I do not think it is a good idea to hurt 
>>> the experience of a significant population of our users without at least 
>>> telling them how they can fix it.
>>>
>>> The config option is not very visible at all. Experience has told me 
>>> that people don't often go looking around in the options menu to find a 
>>> fix for their problem. So we need to do a better job of educating them 
>>> why they might be experiencing slowdowns and how they can avoid them.
>>>
>>> Let's take inspiration from git status. When the local branch diverges 
>>> from the upstream branch, git status shows you how many commits your 
>>> branch is ahead and how many commits behind upstream. This can be an 
>>> expensive operation if the divergence point is far behind. In those 
>>> cases, git status prints something like:
>>>
>>>   It took 30.00 seconds to calculate the branch ahead/behind values.
>>>   You can use '--no-ahead-behind' to avoid this.
>>>
>>> This made me aware this option existed and that I can use it to avoid 
>>> slowdowns.
>>>
>>> We should do something similar for the auto rescan. Measure how long it 
>>> takes to finish the rescan and if it takes longer than X seconds then 
>>> tell the user that they can use this option to disable this. If they 
>>> don't mind the delay they can keep on using it.
>>>
>>> I am working on a patch to add this. Will send it in a day or two.
>>
>> Sounds good to me. While I personally don't think such a check is
>> necessary in this case, I also have nothing against it if you find it
>> important.
>>
>> It just needs to be possible to disable that check itself, too. I
>> certainly wouldn't want to be bothered by it, even if the rescan should
>> take longer than whatever threshold you decide on. So if you put up a
>> dialog to inform the user, the dialog should ideally have a "Don't show
>> again" option.
> 
> That's the plan. It will be a yes/no/cancel prompt. Saying yes or no 
> sets auto rescan to on/off and the message won't pop up again. Saying 
> cancel does nothing and you will see the popup again on the next long 
> rescan.

Interesting. After thinking about this for a while, I'm not convinced
that a Yes/No/Cancel dialog is the best user experience for this, for
the following reasons:

- It isn't obvious whether clicking No will turn auto-rescan off only
  for this repo, or globally (unless you provide two different buttons
  for this).

- It doesn't teach users how they can turn it back on if they clicked No
  too hastily (e.g. because they didn't immediately understand the
  difference between No and Cancel).

- It isn't really intuitively obvious what "Cancel" means. What is the
  operation that is being cancelled here? The rescan itself has already
  happened. (Yes, I know that the operation being cancelled is the
  process of deciding whether the option should be turned off, but as I
  said, I don't find this intuitive.)

I think it might be a better user experience to have a dialog like this:

      The automatic rescan on activating the application has
      taken more than X seconds. If this bothers you, you can
      turn it off in the Preferences dialog.

            [x] Don't show again
                                             [OK]


The only downside is that it's more work to implement, as you can't use
tk_messageBox.

All of this is just my humble opinion; if you decide to stick to your
plan, that's ok with me too.


>>>> Cc:-ing a few people who were involved in the discussion on Pratyush's
>>>> similar patch last summer. [0]
>>>>
>>>>
>>>> [0] <https://lore.kernel.org/git/20190728151726.9188-1-
>>>>      me@yadavpratyush.com/>
>>>>
>>>>
>>>>>
>>>>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
>>>>> ---
>>>>>  git-gui.sh     | 5 +++++
>>>>>  lib/option.tcl | 1 +
>>>>>  2 files changed, 6 insertions(+)
>>>>>
>>>>> diff --git a/git-gui.sh b/git-gui.sh
>>>>> index 867b8ce..14735a3 100755
>>>>> --- a/git-gui.sh
>>>>> +++ b/git-gui.sh
>>>>> @@ -906,6 +906,7 @@ set font_descs {
>>>>>  }
>>>>>  set default_config(gui.stageuntracked) ask
>>>>>  set default_config(gui.displayuntracked) true
>>>>> +set default_config(gui.autorescan) true
>>>>>
>>>>>  ######################################################################
>>>>>  ##
>>>>> @@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}
>>>>>  bind .   <Alt-Key-3> {focus $::ui_diff}
>>>>>  bind .   <Alt-Key-4> {focus $::ui_comm}
>>>>>
>>>>> +if {[is_config_true gui.autorescan]} {
>>>>> +	bind .   <FocusIn>  { if {"%W" eq "."} do_rescan }
>>>>> +}
>>>>> +
>>>>>  set file_lists_last_clicked($ui_index) {}
>>>>>  set file_lists_last_clicked($ui_workdir) {}
>>>>>
>>>>> diff --git a/lib/option.tcl b/lib/option.tcl
>>>>> index e43971b..9e83db7 100644
>>>>> --- a/lib/option.tcl
>>>>> +++ b/lib/option.tcl
>>>>> @@ -145,6 +145,7 @@ proc do_options {} {
>>>>>  		{b merge.diffstat {mc "Show Diffstat After Merge"}}
>>>>>  		{t merge.tool {mc "Use Merge Tool"}}
>>>>>
>>>>> +		{b gui.autorescan  {mc "Auto-Rescan On Activate"}}
>>>>>  		{b gui.trustmtime  {mc "Trust File Modification Timestamps"}}
>>>>>  		{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
>>>>>  		{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
>>>>> --
>>>>> 2.29.2
>>>>>
>>>
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/2] git-gui: Auto-rescan on activate
  2020-11-01 17:05 [PATCH 0/2] git-gui: Auto-rescan on activate Stefan Haller
                   ` (2 preceding siblings ...)
  2020-11-02 13:15 ` [PATCH 0/2] " Pratyush Yadav
@ 2020-12-17 19:45 ` Johannes Sixt
  2020-12-17 20:10   ` Pratyush Yadav
  2020-12-18 10:36   ` Stefan Haller
  3 siblings, 2 replies; 21+ messages in thread
From: Johannes Sixt @ 2020-12-17 19:45 UTC (permalink / raw)
  To: Stefan Haller; +Cc: me, git

Am 01.11.20 um 18:05 schrieb Stefan Haller:
> Do an automatic rescan whenever the git-gui window receives focus. Most other
> GUI tools do this, and it's very convenient; no more pressing F5 manually.
> 
> People who don't like this behavior can turn it off using
> "git config gui.autorescan false".
> 
> Stefan Haller (2):
>   git-gui: Delay rescan until idle time
>   git-gui: Auto-rescan on activate
> 
>  git-gui.sh | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
> 

I've been using these patches in the past days.

I am still a bit ambivalent on whether I like the behavior. I do switch
among windows *a lot* and there is a short flicker on every rescan. And
there is muscle memory...

I observe a bug and a half:

It is unclear which file is selected automatically when there are
unstaged changes. But there is one misbehavior: after I have invoked the
merge tool, resolved the conflict, and then switch back to Git GUI, the
conflicted file is not selected anymore when it is not the first file in
the list. That is *very* annoying.

And then there is the following use-case. While Git GUI is not active
(think Git GUI and Gitk side-by-side and Gitk active), I click on a
particular file that is not at the top of the list; then Git GUI becomes
active and rescans, but also forgets on which file I have clicked. But I
expected the clicked-on file to become visible, which it doesn't, and I
have to click again. This is mildly annoying.

-- Hannes

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/2] git-gui: Auto-rescan on activate
  2020-12-17 19:45 ` [PATCH 0/2] " Johannes Sixt
@ 2020-12-17 20:10   ` Pratyush Yadav
  2020-12-17 22:21     ` Johannes Sixt
  2020-12-18 10:36   ` Stefan Haller
  1 sibling, 1 reply; 21+ messages in thread
From: Pratyush Yadav @ 2020-12-17 20:10 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Stefan Haller, git

Hi,

On 17/12/20 08:45PM, Johannes Sixt wrote:
> Am 01.11.20 um 18:05 schrieb Stefan Haller:
> > Do an automatic rescan whenever the git-gui window receives focus. Most other
> > GUI tools do this, and it's very convenient; no more pressing F5 manually.
> > 
> > People who don't like this behavior can turn it off using
> > "git config gui.autorescan false".
> > 
> > Stefan Haller (2):
> >   git-gui: Delay rescan until idle time
> >   git-gui: Auto-rescan on activate
> > 
> >  git-gui.sh | 26 ++++++++++++++++++++++----
> >  1 file changed, 22 insertions(+), 4 deletions(-)
> > 
> 
> I've been using these patches in the past days.
> 
> I am still a bit ambivalent on whether I like the behavior. I do switch
> among windows *a lot* and there is a short flicker on every rescan. And
> there is muscle memory...

This is part of the reason I am a little uneasy enabling it by default, 
and why I insist on having a loud and clear warning to the users about 
what is going on.
 
> I observe a bug and a half:
> 
> It is unclear which file is selected automatically when there are
> unstaged changes. But there is one misbehavior: after I have invoked the
> merge tool, resolved the conflict, and then switch back to Git GUI, the
> conflicted file is not selected anymore when it is not the first file in
> the list. That is *very* annoying.

Haven't had a chance to try this out yet but AFAIK the last file should 
be correctly remembered. See below.
 
> And then there is the following use-case. While Git GUI is not active
> (think Git GUI and Gitk side-by-side and Gitk active), I click on a
> particular file that is not at the top of the list; then Git GUI becomes
> active and rescans, but also forgets on which file I have clicked. But I
> expected the clicked-on file to become visible, which it doesn't, and I
> have to click again. This is mildly annoying.

Hmm, I don't see that on my system on Linux. The code to remember last 
open file is there in 'rescan_done'. So I don't understand why this 
becomes a problem on your system.

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/2] git-gui: Auto-rescan on activate
  2020-12-17 20:10   ` Pratyush Yadav
@ 2020-12-17 22:21     ` Johannes Sixt
  0 siblings, 0 replies; 21+ messages in thread
From: Johannes Sixt @ 2020-12-17 22:21 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: Stefan Haller, git

Am 17.12.20 um 21:10 schrieb Pratyush Yadav:
> On 17/12/20 08:45PM, Johannes Sixt wrote:
>> It is unclear which file is selected automatically when there are
>> unstaged changes. But there is one misbehavior: after I have invoked the
>> merge tool, resolved the conflict, and then switch back to Git GUI, the
>> conflicted file is not selected anymore when it is not the first file in
>> the list. That is *very* annoying.
> 
> Haven't had a chance to try this out yet but AFAIK the last file should 
> be correctly remembered. See below.

It doesn't here in the case where I invoke the merge tool via the
context menu in the diff view.

>> And then there is the following use-case. While Git GUI is not active
>> (think Git GUI and Gitk side-by-side and Gitk active), I click on a
>> particular file that is not at the top of the list; then Git GUI becomes
>> active and rescans, but also forgets on which file I have clicked. But I
>> expected the clicked-on file to become visible, which it doesn't, and I
>> have to click again. This is mildly annoying.
> 
> Hmm, I don't see that on my system on Linux. The code to remember last 
> open file is there in 'rescan_done'. So I don't understand why this 
> becomes a problem on your system.
It's not "last open file"; that works ok. It is "file A is open, I click
on file B, then rescan happens, now file A is still open"; at that point
I want file B open---that's where I clicked. The important part is that
the single click on file B must do two things: activate Git GUI, and
switch to file B. It worked that way in the past.

-- Hannes

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/2] git-gui: Auto-rescan on activate
  2020-12-17 19:45 ` [PATCH 0/2] " Johannes Sixt
  2020-12-17 20:10   ` Pratyush Yadav
@ 2020-12-18 10:36   ` Stefan Haller
  2020-12-18 18:07     ` Johannes Sixt
  1 sibling, 1 reply; 21+ messages in thread
From: Stefan Haller @ 2020-12-18 10:36 UTC (permalink / raw)
  To: Johannes Sixt, Stefan Haller; +Cc: me, git

Hi Johannes,

thanks for testing! It's good to have people who care about details.


On 17.12.20 20:45, Johannes Sixt wrote:
> Am 01.11.20 um 18:05 schrieb Stefan Haller:
>> Do an automatic rescan whenever the git-gui window receives focus. Most other
>> GUI tools do this, and it's very convenient; no more pressing F5 manually.
>>
>> People who don't like this behavior can turn it off using
>> "git config gui.autorescan false".
>>
>> Stefan Haller (2):
>>   git-gui: Delay rescan until idle time
>>   git-gui: Auto-rescan on activate
>>
>>  git-gui.sh | 26 ++++++++++++++++++++++----
>>  1 file changed, 22 insertions(+), 4 deletions(-)
>>
> 
> I've been using these patches in the past days.
> 
> I am still a bit ambivalent on whether I like the behavior. I do switch
> among windows *a lot* and there is a short flicker on every rescan. And
> there is muscle memory...

Yes, the flicker is annoying. It also happens when you manually rescan
(F5) though, so it's not a new problem. You just see it more often now.
I didn't succeed to fix it yet, but I also didn't try very hard.

Another problem that's related and can be annoying is that the text
selection is lost on rescan; so if you select some lines because you
want to stage them, and then before staging you briefly switch back to
your editor to check something else, then you have to start over when
you come back. I guess this could be fixed by remembering the selection
on rescan, in a similar way how we remember the scroll position.

As for muscle memory, in my experience this is something that you
unlearn pretty quickly. On the contrary, I'm now having having trouble
using git gui on machines that don't have the patch, because I got so
used to relying on the window to always be up to date automatically.

For me, I have to say that the auto-rescan is a total game-changer, even
with all the problems that it still has. I don't want to do without it
any more.

> It is unclear which file is selected automatically when there are
> unstaged changes. But there is one misbehavior: after I have invoked the
> merge tool, resolved the conflict, and then switch back to Git GUI, the
> conflicted file is not selected anymore when it is not the first file in
> the list. That is *very* annoying.

I tried to reproduce this, but couldn't. It would be helpful if you
could post a more detailed reproduction recipe.

Another related aspect: if you select an untracked file and then trigger
a manual rescan, the file is no longer selected; it selects the first
tracked, modified file instead. I don't know why it does this, I find
this annoying. The auto-rescan doesn't have this behavior, it keeps the
untracked file selected, which I like.

> And then there is the following use-case. While Git GUI is not active
> (think Git GUI and Gitk side-by-side and Gitk active), I click on a
> particular file that is not at the top of the list; then Git GUI becomes
> active and rescans, but also forgets on which file I have clicked. But I
> expected the clicked-on file to become visible, which it doesn't, and I
> have to click again. This is mildly annoying.

Like Pratyush, I can't see why this should happen, and I can't reproduce
it on my machine (Mac). What system are you on?

-Stefan

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/2] git-gui: Auto-rescan on activate
  2020-12-18 10:36   ` Stefan Haller
@ 2020-12-18 18:07     ` Johannes Sixt
  0 siblings, 0 replies; 21+ messages in thread
From: Johannes Sixt @ 2020-12-18 18:07 UTC (permalink / raw)
  To: Stefan Haller, Stefan Haller; +Cc: me, git

Am 18.12.20 um 11:36 schrieb Stefan Haller:
> On 17.12.20 20:45, Johannes Sixt wrote:
>> It is unclear which file is selected automatically when there are
>> unstaged changes. But there is one misbehavior: after I have invoked the
>> merge tool, resolved the conflict, and then switch back to Git GUI, the
>> conflicted file is not selected anymore when it is not the first file in
>> the list. That is *very* annoying.
> 
> I tried to reproduce this, but couldn't. It would be helpful if you
> could post a more detailed reproduction recipe.

I cannot reproduce this on Linux. But I am on Windows most of the time,
where it happens always. Note that you need two conflicted files. For
example (in a temporary git.git worktree):

   git checkout b4100f366c1e~
   git -c rerere.enabled=0 merge b4100f366c1e^2

Select the second conflicted file, invoke the merge tool via the context
menu, resolve the conflict, save and close the merge tool. Notice that
the first conflicted file is now selected.

Note that a rescan happens automatically even without the patch under
discussion when the merge tool (when invoked via the context menu) is
closed. This patch starts a simultaneous rescan. Perhaps it is a timing
problem of some sort.

> Another related aspect: if you select an untracked file and then trigger
> a manual rescan, the file is no longer selected; it selects the first
> tracked, modified file instead. I don't know why it does this, I find
> this annoying. The auto-rescan doesn't have this behavior, it keeps the
> untracked file selected, which I like.

The idea behind the old behavior is that a change is more important than
an untracked file. Also, a conflicted file is more important than a
change; hence, if you have a normal unstaged change selected, and then
rescan, a conflicted file is selected.

>> And then there is the following use-case. While Git GUI is not active
>> (think Git GUI and Gitk side-by-side and Gitk active), I click on a
>> particular file that is not at the top of the list; then Git GUI becomes
>> active and rescans, but also forgets on which file I have clicked. But I
>> expected the clicked-on file to become visible, which it doesn't, and I
>> have to click again. This is mildly annoying.
> 
> Like Pratyush, I can't see why this should happen, and I can't reproduce
> it on my machine (Mac). What system are you on?

I can reproduce this on my Linux box the same way as it happens on
Windows. Just have two files with changes, then activate another window
such that the unstaged file list remains visible, then click on the
unselected file in Git GUI. Notice that it is not selected after Git GUI
becomes active.

-- Hannes

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2020-12-18 18:10 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-01 17:05 [PATCH 0/2] git-gui: Auto-rescan on activate Stefan Haller
2020-11-01 17:05 ` [PATCH 1/2] git-gui: Delay rescan until idle time Stefan Haller
2020-11-02 15:45   ` Pratyush Yadav
2020-11-02 19:29     ` Stefan Haller
2020-11-01 17:05 ` [PATCH 2/2] git-gui: Auto-rescan on activate Stefan Haller
2020-11-02 15:48   ` Pratyush Yadav
2020-11-02 19:31     ` Stefan Haller
2020-11-02 13:15 ` [PATCH 0/2] " Pratyush Yadav
2020-11-02 19:24   ` Stefan Haller
2020-11-03 16:16     ` [PATCH v2 0/1] " Stefan Haller
2020-11-03 16:16       ` [PATCH v2 1/1] " Stefan Haller
2020-11-14 19:14         ` Stefan Haller
2020-11-17  7:36           ` Pratyush Yadav
2020-11-17 11:13             ` Stefan Haller
2020-11-17 12:05               ` Pratyush Yadav
2020-11-18  9:17                 ` Stefan Haller
2020-12-17 19:45 ` [PATCH 0/2] " Johannes Sixt
2020-12-17 20:10   ` Pratyush Yadav
2020-12-17 22:21     ` Johannes Sixt
2020-12-18 10:36   ` Stefan Haller
2020-12-18 18:07     ` Johannes Sixt

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).