{"thread":{"id":"54549","subject":"[PATCH 2/2] git-gui: Auto-rescan on activate","startedAt":"2020-11-01T17:05:27Z","lastAt":"2020-12-18T18:08:42Z","messageCount":21,"participants":["Stefan Haller","Pratyush Yadav","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"408811","messageId":"20201101170505.71246-3-stefan@haller-berlin.de","threadId":"54549","inReplyTo":"20201101170505.71246-1-stefan@haller-berlin.de","subject":"[PATCH 2/2] git-gui: Auto-rescan on activate","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-01T17:05:05Z","receivedAt":"2020-11-01T17:05:27Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"Do an automatic rescan whenever the git-gui window receives focus. Most other\nGUI tools do this, and it's very convenient; no more pressing F5 manually.\n\nPeople who don't like this behavior can turn it off using\n\"git config gui.autorescan false\".\n\nSigned-off-by: Stefan Haller <stefan@haller-berlin.de>\n---\n git-gui.sh | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 8864c14..4a4ac19 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -906,6 +906,7 @@ set font_descs {\n }\n set default_config(gui.stageuntracked) ask\n set default_config(gui.displayuntracked) true\n+set default_config(gui.autorescan) true\n \n ######################################################################\n ##\n@@ -4020,6 +4021,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}\n bind .   <Alt-Key-3> {focus $::ui_diff}\n bind .   <Alt-Key-4> {focus $::ui_comm}\n \n+if {[is_config_true gui.autorescan]} {\n+\tbind .   <FocusIn>  schedule_rescan\n+}\n+\n set file_lists_last_clicked($ui_index) {}\n set file_lists_last_clicked($ui_workdir) {}\n \n-- \n2.29.2\n\n"},{"id":"408812","messageId":"20201101170505.71246-1-stefan@haller-berlin.de","threadId":"54549","inReplyTo":null,"subject":"[PATCH 0/2] git-gui: Auto-rescan on activate","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-01T17:05:03Z","receivedAt":"2020-11-01T17:05:27Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"Do an automatic rescan whenever the git-gui window receives focus. Most other\nGUI tools do this, and it's very convenient; no more pressing F5 manually.\n\nPeople who don't like this behavior can turn it off using\n\"git config gui.autorescan false\".\n\nStefan Haller (2):\n  git-gui: Delay rescan until idle time\n  git-gui: Auto-rescan on activate\n\n git-gui.sh | 26 ++++++++++++++++++++++----\n 1 file changed, 22 insertions(+), 4 deletions(-)\n\n--\n2.29.2\n\n"},{"id":"408813","messageId":"20201101170505.71246-2-stefan@haller-berlin.de","threadId":"54549","inReplyTo":"20201101170505.71246-1-stefan@haller-berlin.de","subject":"[PATCH 1/2] git-gui: Delay rescan until idle time","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-01T17:05:04Z","receivedAt":"2020-11-01T17:05:27Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"This is to ensure that a rescan is only performed once, even if it is\nrequested multiple times during one event. We don't need this yet, because\nwe only ever call do_rescan once per event so far; this is going to change\nwith the next commit, when we also call it from FocusIn.\n\nSigned-off-by: Stefan Haller <stefan@haller-berlin.de>\n---\n git-gui.sh | 21 +++++++++++++++++----\n 1 file changed, 17 insertions(+), 4 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 867b8ce..8864c14 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -2376,8 +2376,21 @@ proc do_quit {{rc {1}}} {\n \tdestroy .\n }\n \n+# Not to be called directly; use schedule_rescan instead\n proc do_rescan {} {\n+\tglobal rescan_id\n+\n \trescan ui_ready\n+\tunset rescan_id\n+}\n+\n+proc schedule_rescan {} {\n+\tglobal rescan_id\n+\n+\tif {[info exists rescan_id]} {\n+\t\tafter cancel $rescan_id\n+\t}\n+\tset rescan_id [after idle do_rescan]\n }\n \n proc ui_do_rescan {} {\n@@ -3683,7 +3696,7 @@ set ui_diff_applyhunk [$ctxm index last]\n lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]\n $ctxm add command \\\n \t-label [mc \"Apply/Reverse Line\"] \\\n-\t-command {apply_or_revert_range_or_line $cursorX $cursorY 0; do_rescan}\n+\t-command {apply_or_revert_range_or_line $cursorX $cursorY 0; schedule_rescan}\n set ui_diff_applyline [$ctxm index last]\n lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]\n $ctxm add separator\n@@ -3694,12 +3707,12 @@ set ui_diff_reverthunk [$ctxm index last]\n lappend diff_actions [list $ctxm entryconf $ui_diff_reverthunk -state]\n $ctxm add command \\\n \t-label [mc \"Revert Line\"] \\\n-\t-command {apply_or_revert_range_or_line $cursorX $cursorY 1; do_rescan}\n+\t-command {apply_or_revert_range_or_line $cursorX $cursorY 1; schedule_rescan}\n set ui_diff_revertline [$ctxm index last]\n lappend diff_actions [list $ctxm entryconf $ui_diff_revertline -state]\n $ctxm add command \\\n \t-label [mc \"Undo Last Revert\"] \\\n-\t-command {undo_last_revert; do_rescan}\n+\t-command {undo_last_revert; schedule_rescan}\n set ui_diff_undorevert [$ctxm index last]\n lappend diff_actions [list $ctxm entryconf $ui_diff_undorevert -state]\n $ctxm add separator\n@@ -4171,7 +4184,7 @@ after 1 {\n \tif {[is_enabled initialamend]} {\n \t\tforce_amend\n \t} else {\n-\t\tdo_rescan\n+\t\tschedule_rescan\n \t}\n \n \tif {[is_enabled nocommitmsg]} {\n-- \n2.29.2\n\n"},{"id":"408862","messageId":"20201102131522.coj5gb2bssvjqngo@yadavpratyush.com","threadId":"54549","inReplyTo":"20201101170505.71246-1-stefan@haller-berlin.de","subject":"Re: [PATCH 0/2] git-gui: Auto-rescan on activate","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2020-11-02T13:15:22Z","receivedAt":"2020-11-02T13:15:29Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi Stefan,\n\nOn 01/11/20 06:05PM, Stefan Haller wrote:\n> Do an automatic rescan whenever the git-gui window receives focus. Most other\n> GUI tools do this, and it's very convenient; no more pressing F5 manually.\n\nI submitted a patch for this a while back but there was a lengthy \ndiscussion. [0] would be a good read. IIRC the major blocker was that \nrescan is a very expensive operation on Windows.\n \n> People who don't like this behavior can turn it off using\n> \"git config gui.autorescan false\".\n\nTo make sure the experience on Windows (and for anyone who faces long \nrescan times) does not degrade, I think we should keep this off by \ndefault. That said, I would love to be convinced to keep this on by \ndefault because IMO this is a really good feature to have. I tried \ncoming up with ways to avoid slowdowns while keeping the auto rescan on \nbut I didn't come up with anything convincing.\n \n> Stefan Haller (2):\n>   git-gui: Delay rescan until idle time\n>   git-gui: Auto-rescan on activate\n> \n>  git-gui.sh | 26 ++++++++++++++++++++++----\n>  1 file changed, 22 insertions(+), 4 deletions(-)\n> \n\n[0] https://lore.kernel.org/git/20190728151726.9188-1-me@yadavpratyush.com/\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"408866","messageId":"20201102154550.2tvvsswokscg42ba@yadavpratyush.com","threadId":"54549","inReplyTo":"20201101170505.71246-2-stefan@haller-berlin.de","subject":"Re: [PATCH 1/2] git-gui: Delay rescan until idle time","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2020-11-02T15:45:50Z","receivedAt":"2020-11-02T15:47:31Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi Stefan,\n\nOn 01/11/20 06:05PM, Stefan Haller wrote:\n> This is to ensure that a rescan is only performed once, even if it is\n> requested multiple times during one event. We don't need this yet, because\n> we only ever call do_rescan once per event so far; this is going to change\n> with the next commit, when we also call it from FocusIn.\n\nI don't understand what this is trying to achieve. The calls to \ndo_rescan below only happen when the user explicitly does something, \nlike stage/unstage selected lines. Why would that event coincide with \nthe FocusIn event?\n\nIf you mean to account for a situation where the rescan for \n\"Apply/Reverse Line\" is executed before the rescan from FocusIn \nfinishes, then in that case the procedure rescan already accounts for it \nby checking $rescan_active and the index lock.\n\nHave you noticed multiple rescans in parallel? If yes then we might want \nto look at why the check is not working.\n \n> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n> ---\n>  git-gui.sh | 21 +++++++++++++++++----\n>  1 file changed, 17 insertions(+), 4 deletions(-)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index 867b8ce..8864c14 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -2376,8 +2376,21 @@ proc do_quit {{rc {1}}} {\n>  \tdestroy .\n>  }\n>  \n> +# Not to be called directly; use schedule_rescan instead\n>  proc do_rescan {} {\n> +\tglobal rescan_id\n> +\n>  \trescan ui_ready\n> +\tunset rescan_id\n\nNot sure if you're aware of it already, but it is worth mentioning that \nrescan is asynchronous. The procedure call will return before the rescan \nin actually complete. See the `fileevent` calls in rescan and \nrescan_stage2.\n\nSo in this case, rescan_id will be unset before the rescan is actually \ndone. This can be the right or wrong thing depending on what you want to \naccomplish, which I'm not clear on.\n\n> +}\n> +\n> +proc schedule_rescan {} {\n> +\tglobal rescan_id\n> +\n> +\tif {[info exists rescan_id]} {\n> +\t\tafter cancel $rescan_id\n> +\t}\n> +\tset rescan_id [after idle do_rescan]\n>  }\n>  \n>  proc ui_do_rescan {} {\n> @@ -3683,7 +3696,7 @@ set ui_diff_applyhunk [$ctxm index last]\n>  lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]\n>  $ctxm add command \\\n>  \t-label [mc \"Apply/Reverse Line\"] \\\n> -\t-command {apply_or_revert_range_or_line $cursorX $cursorY 0; do_rescan}\n> +\t-command {apply_or_revert_range_or_line $cursorX $cursorY 0; schedule_rescan}\n>  set ui_diff_applyline [$ctxm index last]\n>  lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]\n>  $ctxm add separator\n> @@ -3694,12 +3707,12 @@ set ui_diff_reverthunk [$ctxm index last]\n>  lappend diff_actions [list $ctxm entryconf $ui_diff_reverthunk -state]\n>  $ctxm add command \\\n>  \t-label [mc \"Revert Line\"] \\\n> -\t-command {apply_or_revert_range_or_line $cursorX $cursorY 1; do_rescan}\n> +\t-command {apply_or_revert_range_or_line $cursorX $cursorY 1; schedule_rescan}\n>  set ui_diff_revertline [$ctxm index last]\n>  lappend diff_actions [list $ctxm entryconf $ui_diff_revertline -state]\n>  $ctxm add command \\\n>  \t-label [mc \"Undo Last Revert\"] \\\n> -\t-command {undo_last_revert; do_rescan}\n> +\t-command {undo_last_revert; schedule_rescan}\n>  set ui_diff_undorevert [$ctxm index last]\n>  lappend diff_actions [list $ctxm entryconf $ui_diff_undorevert -state]\n>  $ctxm add separator\n> @@ -4171,7 +4184,7 @@ after 1 {\n>  \tif {[is_enabled initialamend]} {\n>  \t\tforce_amend\n>  \t} else {\n> -\t\tdo_rescan\n> +\t\tschedule_rescan\n>  \t}\n>  \n>  \tif {[is_enabled nocommitmsg]} {\n> -- \n> 2.29.2\n> \n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"408867","messageId":"20201102154815.4incizurpmdhhmjh@yadavpratyush.com","threadId":"54549","inReplyTo":"20201101170505.71246-3-stefan@haller-berlin.de","subject":"Re: [PATCH 2/2] git-gui: Auto-rescan on activate","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2020-11-02T15:48:15Z","receivedAt":"2020-11-02T15:48:35Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi Stefan,\n\nOn 01/11/20 06:05PM, Stefan Haller wrote:\n> Do an automatic rescan whenever the git-gui window receives focus. Most other\n> GUI tools do this, and it's very convenient; no more pressing F5 manually.\n> \n> People who don't like this behavior can turn it off using\n> \"git config gui.autorescan false\".\n> \n> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n> ---\n>  git-gui.sh | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index 8864c14..4a4ac19 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -906,6 +906,7 @@ set font_descs {\n>  }\n>  set default_config(gui.stageuntracked) ask\n>  set default_config(gui.displayuntracked) true\n> +set default_config(gui.autorescan) true\n\nDefault to false. See my reply to the cover letter for more info.\n\nIt would also be a good idea to include an option for this in the \noptions dialog. Check do_options in lib/options.tcl for examples.\n\n>  \n>  ######################################################################\n>  ##\n> @@ -4020,6 +4021,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}\n>  bind .   <Alt-Key-3> {focus $::ui_diff}\n>  bind .   <Alt-Key-4> {focus $::ui_comm}\n>  \n> +if {[is_config_true gui.autorescan]} {\n> +\tbind .   <FocusIn>  schedule_rescan\n> +}\n> +\n\nOk.\n\n>  set file_lists_last_clicked($ui_index) {}\n>  set file_lists_last_clicked($ui_workdir) {}\n>  \n> -- \n> 2.29.2\n> \n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"408897","messageId":"fe2f24e8-52f2-81fe-0ebd-ecd90b1acfb4@haller-berlin.de","threadId":"54549","inReplyTo":"20201102131522.coj5gb2bssvjqngo@yadavpratyush.com","subject":"Re: [PATCH 0/2] git-gui: Auto-rescan on activate","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-02T19:24:34Z","receivedAt":"2020-11-02T19:24:38Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"On 02.11.20 14:15, Pratyush Yadav wrote:\n> Hi Stefan,\n> \n> On 01/11/20 06:05PM, Stefan Haller wrote:\n>> Do an automatic rescan whenever the git-gui window receives focus. Most other\n>> GUI tools do this, and it's very convenient; no more pressing F5 manually.\n> \n> I submitted a patch for this a while back but there was a lengthy \n> discussion. [0] would be a good read. IIRC the major blocker was that \n> rescan is a very expensive operation on Windows.\n\nAh, thanks for reminding me of that. I did actually read the discussion\nback then, but had completely forgotten about it.\n\n>> People who don't like this behavior can turn it off using\n>> \"git config gui.autorescan false\".\n> \n> To make sure the experience on Windows (and for anyone who faces long \n> rescan times) does not degrade, I think we should keep this off by \n> default. That said, I would love to be convinced to keep this on by \n> default because IMO this is a really good feature to have. I tried \n> coming up with ways to avoid slowdowns while keeping the auto rescan on \n> but I didn't come up with anything convincing.\n\nI still think the default should be on; I consider it more important\nthat the information is accurate than that it is shown without delay. I\ndo use Windows occasionally myself, in a slow VM no less, and it does\nannoy me that a rescan is so slow there; however, I still prefer that\nover looking at stale information without realizing it.\n\nAlso, I had a look at how other git clients deal with this. I didn't do\nan exhaustive research, just quickly looked at a few:\n\n- Fork (https://git-fork.com)\n  Rescans on activate. There's no setting to turn this off. (!)\n\n- SourceTree (https://www.sourcetreeapp.com)\n  Rescans on activate. There's an option to turn this off, but it\n  defaults to on. (It is confusingly called \"Refresh automatically when\n  files change\", which doesn't seem to be accurate, as far as I can\n  tell.)\n\n- Visual Studio Code\n  Rescans on activate. There's an option to turn it off, but it defaults\n  to on.\n\n- Sublime Merge (https://www.sublimemerge.com)\n  Watches files and rescans in the background.\n\nSo I would say there's plenty of precedence for having this behavior\ndefault to on.\n\n>> Stefan Haller (2):\n>>   git-gui: Delay rescan until idle time\n>>   git-gui: Auto-rescan on activate\n>>\n>>  git-gui.sh | 26 ++++++++++++++++++++++----\n>>  1 file changed, 22 insertions(+), 4 deletions(-)\n>>\n> \n> [0] https://lore.kernel.org/git/20190728151726.9188-1-me@yadavpratyush.com/\n> \n"},{"id":"408898","messageId":"def489e0-c888-8a2b-e49c-598034f683e7@haller-berlin.de","threadId":"54549","inReplyTo":"20201102154550.2tvvsswokscg42ba@yadavpratyush.com","subject":"Re: [PATCH 1/2] git-gui: Delay rescan until idle time","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-02T19:29:24Z","receivedAt":"2020-11-02T19:29:28Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"On 02.11.20 16:45, Pratyush Yadav wrote:\n> Hi Stefan,\n> \n> On 01/11/20 06:05PM, Stefan Haller wrote:\n>> This is to ensure that a rescan is only performed once, even if it is\n>> requested multiple times during one event. We don't need this yet, because\n>> we only ever call do_rescan once per event so far; this is going to change\n>> with the next commit, when we also call it from FocusIn.\n> \n> I don't understand what this is trying to achieve. The calls to \n> do_rescan below only happen when the user explicitly does something, \n> like stage/unstage selected lines. Why would that event coincide with \n> the FocusIn event?\n> \n> If you mean to account for a situation where the rescan for \n> \"Apply/Reverse Line\" is executed before the rescan from FocusIn \n> finishes, then in that case the procedure rescan already accounts for it \n> by checking $rescan_active and the index lock.\n\nI'm aware that the rescan runs asynchronously, but I wasn't worried\nabout the case where it's triggered concurrently while another one is\nrunning already; I was worried about the case where a rescan (e.g.\ncoming from \"Apply/Reverse Line\") was so fast that it was already\nfinished by the time the FocusIn comes. But I guess I misunderstood Tk's\nthreading model, and this can never happen.\n\nSo it does indeed seem that the existing $rescan_active logic is enough\nto prevent unnecessary rescans; I'll drop this commit.\n\n> Have you noticed multiple rescans in parallel? If yes then we might want \n> to look at why the check is not working.\n>  \n>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n>> ---\n>>  git-gui.sh | 21 +++++++++++++++++----\n>>  1 file changed, 17 insertions(+), 4 deletions(-)\n>>\n>> diff --git a/git-gui.sh b/git-gui.sh\n>> index 867b8ce..8864c14 100755\n>> --- a/git-gui.sh\n>> +++ b/git-gui.sh\n>> @@ -2376,8 +2376,21 @@ proc do_quit {{rc {1}}} {\n>>  \tdestroy .\n>>  }\n>>  \n>> +# Not to be called directly; use schedule_rescan instead\n>>  proc do_rescan {} {\n>> +\tglobal rescan_id\n>> +\n>>  \trescan ui_ready\n>> +\tunset rescan_id\n> \n> Not sure if you're aware of it already, but it is worth mentioning that \n> rescan is asynchronous. The procedure call will return before the rescan \n> in actually complete. See the `fileevent` calls in rescan and \n> rescan_stage2.\n> \n> So in this case, rescan_id will be unset before the rescan is actually \n> done. This can be the right or wrong thing depending on what you want to \n> accomplish, which I'm not clear on.\n> \n>> +}\n>> +\n>> +proc schedule_rescan {} {\n>> +\tglobal rescan_id\n>> +\n>> +\tif {[info exists rescan_id]} {\n>> +\t\tafter cancel $rescan_id\n>> +\t}\n>> +\tset rescan_id [after idle do_rescan]\n>>  }\n>>  \n>>  proc ui_do_rescan {} {\n>> @@ -3683,7 +3696,7 @@ set ui_diff_applyhunk [$ctxm index last]\n>>  lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]\n>>  $ctxm add command \\\n>>  \t-label [mc \"Apply/Reverse Line\"] \\\n>> -\t-command {apply_or_revert_range_or_line $cursorX $cursorY 0; do_rescan}\n>> +\t-command {apply_or_revert_range_or_line $cursorX $cursorY 0; schedule_rescan}\n>>  set ui_diff_applyline [$ctxm index last]\n>>  lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]\n>>  $ctxm add separator\n>> @@ -3694,12 +3707,12 @@ set ui_diff_reverthunk [$ctxm index last]\n>>  lappend diff_actions [list $ctxm entryconf $ui_diff_reverthunk -state]\n>>  $ctxm add command \\\n>>  \t-label [mc \"Revert Line\"] \\\n>> -\t-command {apply_or_revert_range_or_line $cursorX $cursorY 1; do_rescan}\n>> +\t-command {apply_or_revert_range_or_line $cursorX $cursorY 1; schedule_rescan}\n>>  set ui_diff_revertline [$ctxm index last]\n>>  lappend diff_actions [list $ctxm entryconf $ui_diff_revertline -state]\n>>  $ctxm add command \\\n>>  \t-label [mc \"Undo Last Revert\"] \\\n>> -\t-command {undo_last_revert; do_rescan}\n>> +\t-command {undo_last_revert; schedule_rescan}\n>>  set ui_diff_undorevert [$ctxm index last]\n>>  lappend diff_actions [list $ctxm entryconf $ui_diff_undorevert -state]\n>>  $ctxm add separator\n>> @@ -4171,7 +4184,7 @@ after 1 {\n>>  \tif {[is_enabled initialamend]} {\n>>  \t\tforce_amend\n>>  \t} else {\n>> -\t\tdo_rescan\n>> +\t\tschedule_rescan\n>>  \t}\n>>  \n>>  \tif {[is_enabled nocommitmsg]} {\n>> -- \n>> 2.29.2\n>>\n> \n"},{"id":"408899","messageId":"9e3ceab4-319e-8766-1a7e-ddb36e8ecabb@haller-berlin.de","threadId":"54549","inReplyTo":"20201102154815.4incizurpmdhhmjh@yadavpratyush.com","subject":"Re: [PATCH 2/2] git-gui: Auto-rescan on activate","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-02T19:31:13Z","receivedAt":"2020-11-02T19:31:16Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"On 02.11.20 16:48, Pratyush Yadav wrote:\n> Hi Stefan,\n> \n> On 01/11/20 06:05PM, Stefan Haller wrote:\n>> Do an automatic rescan whenever the git-gui window receives focus. Most other\n>> GUI tools do this, and it's very convenient; no more pressing F5 manually.\n>>\n>> People who don't like this behavior can turn it off using\n>> \"git config gui.autorescan false\".\n>>\n>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n>> ---\n>>  git-gui.sh | 5 +++++\n>>  1 file changed, 5 insertions(+)\n>>\n>> diff --git a/git-gui.sh b/git-gui.sh\n>> index 8864c14..4a4ac19 100755\n>> --- a/git-gui.sh\n>> +++ b/git-gui.sh\n>> @@ -906,6 +906,7 @@ set font_descs {\n>>  }\n>>  set default_config(gui.stageuntracked) ask\n>>  set default_config(gui.displayuntracked) true\n>> +set default_config(gui.autorescan) true\n> \n> Default to false. See my reply to the cover letter for more info.\n> \n> It would also be a good idea to include an option for this in the \n> options dialog. Check do_options in lib/options.tcl for examples.\n\nOk, I'll see if I can add a checkbox in the dialog. Might take a few\ndays until I have time for doing a re-roll.\n\n\n>>  \n>>  ######################################################################\n>>  ##\n>> @@ -4020,6 +4021,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}\n>>  bind .   <Alt-Key-3> {focus $::ui_diff}\n>>  bind .   <Alt-Key-4> {focus $::ui_comm}\n>>  \n>> +if {[is_config_true gui.autorescan]} {\n>> +\tbind .   <FocusIn>  schedule_rescan\n>> +}\n>> +\n> \n> Ok.\n> \n>>  set file_lists_last_clicked($ui_index) {}\n>>  set file_lists_last_clicked($ui_workdir) {}\n>>  \n>> -- \n>> 2.29.2\n>>\n> \n"},{"id":"409010","messageId":"20201103161631.89971-1-stefan@haller-berlin.de","threadId":"54549","inReplyTo":"fe2f24e8-52f2-81fe-0ebd-ecd90b1acfb4@haller-berlin.de","subject":"[PATCH v2 0/1] git-gui: Auto-rescan on activate","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-03T16:16:30Z","receivedAt":"2020-11-03T16:16:38Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"Changes in v2:\n- dropped the unnecessary \"after idle\" logic\n- do the rescan only for the top-level widget; this avoids unnecessary rescans\n  when switching focus between sub-panes\n- add a checkbox to the options dialog\n\nAs explained earlier, I still very much believe that \"on\" is a good default for\nthe option, so I kept it that way.\n\nStefan Haller (1):\n  git-gui: Auto-rescan on activate\n\n git-gui.sh     | 5 +++++\n lib/option.tcl | 1 +\n 2 files changed, 6 insertions(+)\n\n--\n2.29.2\n\n"},{"id":"409011","messageId":"20201103161631.89971-2-stefan@haller-berlin.de","threadId":"54549","inReplyTo":"20201103161631.89971-1-stefan@haller-berlin.de","subject":"[PATCH v2 1/1] git-gui: Auto-rescan on activate","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-03T16:16:31Z","receivedAt":"2020-11-03T16:16:39Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"Do an automatic rescan whenever the git-gui window receives focus. Most other\nGUI tools do this, and it's very convenient; no more pressing F5 manually.\n\nPeople who don't like this behavior can turn it off in the Options dialog.\n\nSigned-off-by: Stefan Haller <stefan@haller-berlin.de>\n---\n git-gui.sh     | 5 +++++\n lib/option.tcl | 1 +\n 2 files changed, 6 insertions(+)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 867b8ce..14735a3 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -906,6 +906,7 @@ set font_descs {\n }\n set default_config(gui.stageuntracked) ask\n set default_config(gui.displayuntracked) true\n+set default_config(gui.autorescan) true\n\n ######################################################################\n ##\n@@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}\n bind .   <Alt-Key-3> {focus $::ui_diff}\n bind .   <Alt-Key-4> {focus $::ui_comm}\n\n+if {[is_config_true gui.autorescan]} {\n+\tbind .   <FocusIn>  { if {\"%W\" eq \".\"} do_rescan }\n+}\n+\n set file_lists_last_clicked($ui_index) {}\n set file_lists_last_clicked($ui_workdir) {}\n\ndiff --git a/lib/option.tcl b/lib/option.tcl\nindex e43971b..9e83db7 100644\n--- a/lib/option.tcl\n+++ b/lib/option.tcl\n@@ -145,6 +145,7 @@ proc do_options {} {\n \t\t{b merge.diffstat {mc \"Show Diffstat After Merge\"}}\n \t\t{t merge.tool {mc \"Use Merge Tool\"}}\n\n+\t\t{b gui.autorescan  {mc \"Auto-Rescan On Activate\"}}\n \t\t{b gui.trustmtime  {mc \"Trust File Modification Timestamps\"}}\n \t\t{b gui.pruneduringfetch {mc \"Prune Tracking Branches During Fetch\"}}\n \t\t{b gui.matchtrackingbranch {mc \"Match Tracking Branches\"}}\n--\n2.29.2\n\n"},{"id":"409961","messageId":"14be00ae-c2b6-87eb-2f4b-964a6df7b230@haller-berlin.de","threadId":"54549","inReplyTo":"20201103161631.89971-2-stefan@haller-berlin.de","subject":"Re: [PATCH v2 1/1] git-gui: Auto-rescan on activate","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-14T19:14:52Z","receivedAt":"2020-11-14T19:15:16Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"On 03.11.20 17:16, Stefan Haller wrote:\n> Do an automatic rescan whenever the git-gui window receives focus. Most other\n> GUI tools do this, and it's very convenient; no more pressing F5 manually.\n> \n> People who don't like this behavior can turn it off in the Options dialog.\n\nPing - any thoughts? I have been running with this patch for a few weeks\nnow, and I already don't want to miss it any more.\n\nCc:-ing a few people who were involved in the discussion on Pratyush's\nsimilar patch last summer. [0]\n\n\n[0] <https://lore.kernel.org/git/20190728151726.9188-1-\n     me@yadavpratyush.com/>\n\n\n> \n> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n> ---\n>  git-gui.sh     | 5 +++++\n>  lib/option.tcl | 1 +\n>  2 files changed, 6 insertions(+)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index 867b8ce..14735a3 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -906,6 +906,7 @@ set font_descs {\n>  }\n>  set default_config(gui.stageuntracked) ask\n>  set default_config(gui.displayuntracked) true\n> +set default_config(gui.autorescan) true\n> \n>  ######################################################################\n>  ##\n> @@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}\n>  bind .   <Alt-Key-3> {focus $::ui_diff}\n>  bind .   <Alt-Key-4> {focus $::ui_comm}\n> \n> +if {[is_config_true gui.autorescan]} {\n> +\tbind .   <FocusIn>  { if {\"%W\" eq \".\"} do_rescan }\n> +}\n> +\n>  set file_lists_last_clicked($ui_index) {}\n>  set file_lists_last_clicked($ui_workdir) {}\n> \n> diff --git a/lib/option.tcl b/lib/option.tcl\n> index e43971b..9e83db7 100644\n> --- a/lib/option.tcl\n> +++ b/lib/option.tcl\n> @@ -145,6 +145,7 @@ proc do_options {} {\n>  \t\t{b merge.diffstat {mc \"Show Diffstat After Merge\"}}\n>  \t\t{t merge.tool {mc \"Use Merge Tool\"}}\n> \n> +\t\t{b gui.autorescan  {mc \"Auto-Rescan On Activate\"}}\n>  \t\t{b gui.trustmtime  {mc \"Trust File Modification Timestamps\"}}\n>  \t\t{b gui.pruneduringfetch {mc \"Prune Tracking Branches During Fetch\"}}\n>  \t\t{b gui.matchtrackingbranch {mc \"Match Tracking Branches\"}}\n> --\n> 2.29.2\n> \n"},{"id":"410075","messageId":"20201117073618.fjbi4ranmh5x3uxk@yadavpratyush.com","threadId":"54549","inReplyTo":"14be00ae-c2b6-87eb-2f4b-964a6df7b230@haller-berlin.de","subject":"Re: [PATCH v2 1/1] git-gui: Auto-rescan on activate","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2020-11-17T07:36:18Z","receivedAt":"2020-11-17T07:36:36Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi Stefan,\n\nOn 14/11/20 08:14PM, Stefan Haller wrote:\n> On 03.11.20 17:16, Stefan Haller wrote:\n> > Do an automatic rescan whenever the git-gui window receives focus. Most other\n> > GUI tools do this, and it's very convenient; no more pressing F5 manually.\n> > \n> > People who don't like this behavior can turn it off in the Options dialog.\n> \n> Ping - any thoughts? I have been running with this patch for a few weeks\n> now, and I already don't want to miss it any more.\n\nI have been staring at your patch for the last few days with indecision. \nI have finally made up my mind. I do not think it is a good idea to hurt \nthe experience of a significant population of our users without at least \ntelling them how they can fix it.\n\nThe config option is not very visible at all. Experience has told me \nthat people don't often go looking around in the options menu to find a \nfix for their problem. So we need to do a better job of educating them \nwhy they might be experiencing slowdowns and how they can avoid them.\n\nLet's take inspiration from git status. When the local branch diverges \nfrom the upstream branch, git status shows you how many commits your \nbranch is ahead and how many commits behind upstream. This can be an \nexpensive operation if the divergence point is far behind. In those \ncases, git status prints something like:\n\n  It took 30.00 seconds to calculate the branch ahead/behind values.\n  You can use '--no-ahead-behind' to avoid this.\n\nThis made me aware this option existed and that I can use it to avoid \nslowdowns.\n\nWe should do something similar for the auto rescan. Measure how long it \ntakes to finish the rescan and if it takes longer than X seconds then \ntell the user that they can use this option to disable this. If they \ndon't mind the delay they can keep on using it.\n\nI am working on a patch to add this. Will send it in a day or two.\n \n> Cc:-ing a few people who were involved in the discussion on Pratyush's\n> similar patch last summer. [0]\n> \n> \n> [0] <https://lore.kernel.org/git/20190728151726.9188-1-\n>      me@yadavpratyush.com/>\n> \n> \n> > \n> > Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n> > ---\n> >  git-gui.sh     | 5 +++++\n> >  lib/option.tcl | 1 +\n> >  2 files changed, 6 insertions(+)\n> > \n> > diff --git a/git-gui.sh b/git-gui.sh\n> > index 867b8ce..14735a3 100755\n> > --- a/git-gui.sh\n> > +++ b/git-gui.sh\n> > @@ -906,6 +906,7 @@ set font_descs {\n> >  }\n> >  set default_config(gui.stageuntracked) ask\n> >  set default_config(gui.displayuntracked) true\n> > +set default_config(gui.autorescan) true\n> > \n> >  ######################################################################\n> >  ##\n> > @@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}\n> >  bind .   <Alt-Key-3> {focus $::ui_diff}\n> >  bind .   <Alt-Key-4> {focus $::ui_comm}\n> > \n> > +if {[is_config_true gui.autorescan]} {\n> > +\tbind .   <FocusIn>  { if {\"%W\" eq \".\"} do_rescan }\n> > +}\n> > +\n> >  set file_lists_last_clicked($ui_index) {}\n> >  set file_lists_last_clicked($ui_workdir) {}\n> > \n> > diff --git a/lib/option.tcl b/lib/option.tcl\n> > index e43971b..9e83db7 100644\n> > --- a/lib/option.tcl\n> > +++ b/lib/option.tcl\n> > @@ -145,6 +145,7 @@ proc do_options {} {\n> >  \t\t{b merge.diffstat {mc \"Show Diffstat After Merge\"}}\n> >  \t\t{t merge.tool {mc \"Use Merge Tool\"}}\n> > \n> > +\t\t{b gui.autorescan  {mc \"Auto-Rescan On Activate\"}}\n> >  \t\t{b gui.trustmtime  {mc \"Trust File Modification Timestamps\"}}\n> >  \t\t{b gui.pruneduringfetch {mc \"Prune Tracking Branches During Fetch\"}}\n> >  \t\t{b gui.matchtrackingbranch {mc \"Match Tracking Branches\"}}\n> > --\n> > 2.29.2\n> > \n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"410077","messageId":"4a37f6ce-276f-1c7e-1252-085a6f28c95b@haller-berlin.de","threadId":"54549","inReplyTo":"20201117073618.fjbi4ranmh5x3uxk@yadavpratyush.com","subject":"Re: [PATCH v2 1/1] git-gui: Auto-rescan on activate","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-17T11:13:02Z","receivedAt":"2020-11-17T11:13:27Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"On 17.11.20 8:36, Pratyush Yadav wrote:\n> Hi Stefan,\n> \n> On 14/11/20 08:14PM, Stefan Haller wrote:\n>> On 03.11.20 17:16, Stefan Haller wrote:\n>>> Do an automatic rescan whenever the git-gui window receives focus. Most other\n>>> GUI tools do this, and it's very convenient; no more pressing F5 manually.\n>>>\n>>> People who don't like this behavior can turn it off in the Options dialog.\n>>\n>> Ping - any thoughts? I have been running with this patch for a few weeks\n>> now, and I already don't want to miss it any more.\n> \n> I have been staring at your patch for the last few days with indecision. \n> I have finally made up my mind. I do not think it is a good idea to hurt \n> the experience of a significant population of our users without at least \n> telling them how they can fix it.\n> \n> The config option is not very visible at all. Experience has told me \n> that people don't often go looking around in the options menu to find a \n> fix for their problem. So we need to do a better job of educating them \n> why they might be experiencing slowdowns and how they can avoid them.\n> \n> Let's take inspiration from git status. When the local branch diverges \n> from the upstream branch, git status shows you how many commits your \n> branch is ahead and how many commits behind upstream. This can be an \n> expensive operation if the divergence point is far behind. In those \n> cases, git status prints something like:\n> \n>   It took 30.00 seconds to calculate the branch ahead/behind values.\n>   You can use '--no-ahead-behind' to avoid this.\n> \n> This made me aware this option existed and that I can use it to avoid \n> slowdowns.\n> \n> We should do something similar for the auto rescan. Measure how long it \n> takes to finish the rescan and if it takes longer than X seconds then \n> tell the user that they can use this option to disable this. If they \n> don't mind the delay they can keep on using it.\n> \n> I am working on a patch to add this. Will send it in a day or two.\n\nSounds good to me. While I personally don't think such a check is\nnecessary in this case, I also have nothing against it if you find it\nimportant.\n\nIt just needs to be possible to disable that check itself, too. I\ncertainly wouldn't want to be bothered by it, even if the rescan should\ntake longer than whatever threshold you decide on. So if you put up a\ndialog to inform the user, the dialog should ideally have a \"Don't show\nagain\" option.\n\n\n>> Cc:-ing a few people who were involved in the discussion on Pratyush's\n>> similar patch last summer. [0]\n>>\n>>\n>> [0] <https://lore.kernel.org/git/20190728151726.9188-1-\n>>      me@yadavpratyush.com/>\n>>\n>>\n>>>\n>>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n>>> ---\n>>>  git-gui.sh     | 5 +++++\n>>>  lib/option.tcl | 1 +\n>>>  2 files changed, 6 insertions(+)\n>>>\n>>> diff --git a/git-gui.sh b/git-gui.sh\n>>> index 867b8ce..14735a3 100755\n>>> --- a/git-gui.sh\n>>> +++ b/git-gui.sh\n>>> @@ -906,6 +906,7 @@ set font_descs {\n>>>  }\n>>>  set default_config(gui.stageuntracked) ask\n>>>  set default_config(gui.displayuntracked) true\n>>> +set default_config(gui.autorescan) true\n>>>\n>>>  ######################################################################\n>>>  ##\n>>> @@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}\n>>>  bind .   <Alt-Key-3> {focus $::ui_diff}\n>>>  bind .   <Alt-Key-4> {focus $::ui_comm}\n>>>\n>>> +if {[is_config_true gui.autorescan]} {\n>>> +\tbind .   <FocusIn>  { if {\"%W\" eq \".\"} do_rescan }\n>>> +}\n>>> +\n>>>  set file_lists_last_clicked($ui_index) {}\n>>>  set file_lists_last_clicked($ui_workdir) {}\n>>>\n>>> diff --git a/lib/option.tcl b/lib/option.tcl\n>>> index e43971b..9e83db7 100644\n>>> --- a/lib/option.tcl\n>>> +++ b/lib/option.tcl\n>>> @@ -145,6 +145,7 @@ proc do_options {} {\n>>>  \t\t{b merge.diffstat {mc \"Show Diffstat After Merge\"}}\n>>>  \t\t{t merge.tool {mc \"Use Merge Tool\"}}\n>>>\n>>> +\t\t{b gui.autorescan  {mc \"Auto-Rescan On Activate\"}}\n>>>  \t\t{b gui.trustmtime  {mc \"Trust File Modification Timestamps\"}}\n>>>  \t\t{b gui.pruneduringfetch {mc \"Prune Tracking Branches During Fetch\"}}\n>>>  \t\t{b gui.matchtrackingbranch {mc \"Match Tracking Branches\"}}\n>>> --\n>>> 2.29.2\n>>>\n> \n"},{"id":"410078","messageId":"20201117120519.nlm7hwnilzwalgho@yadavpratyush.com","threadId":"54549","inReplyTo":"4a37f6ce-276f-1c7e-1252-085a6f28c95b@haller-berlin.de","subject":"Re: [PATCH v2 1/1] git-gui: Auto-rescan on activate","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2020-11-17T12:05:19Z","receivedAt":"2020-11-17T12:05:46Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 17/11/20 12:13PM, Stefan Haller wrote:\n> On 17.11.20 8:36, Pratyush Yadav wrote:\n> > Hi Stefan,\n> > \n> > On 14/11/20 08:14PM, Stefan Haller wrote:\n> >> On 03.11.20 17:16, Stefan Haller wrote:\n> >>> Do an automatic rescan whenever the git-gui window receives focus. Most other\n> >>> GUI tools do this, and it's very convenient; no more pressing F5 manually.\n> >>>\n> >>> People who don't like this behavior can turn it off in the Options dialog.\n> >>\n> >> Ping - any thoughts? I have been running with this patch for a few weeks\n> >> now, and I already don't want to miss it any more.\n> > \n> > I have been staring at your patch for the last few days with indecision. \n> > I have finally made up my mind. I do not think it is a good idea to hurt \n> > the experience of a significant population of our users without at least \n> > telling them how they can fix it.\n> > \n> > The config option is not very visible at all. Experience has told me \n> > that people don't often go looking around in the options menu to find a \n> > fix for their problem. So we need to do a better job of educating them \n> > why they might be experiencing slowdowns and how they can avoid them.\n> > \n> > Let's take inspiration from git status. When the local branch diverges \n> > from the upstream branch, git status shows you how many commits your \n> > branch is ahead and how many commits behind upstream. This can be an \n> > expensive operation if the divergence point is far behind. In those \n> > cases, git status prints something like:\n> > \n> >   It took 30.00 seconds to calculate the branch ahead/behind values.\n> >   You can use '--no-ahead-behind' to avoid this.\n> > \n> > This made me aware this option existed and that I can use it to avoid \n> > slowdowns.\n> > \n> > We should do something similar for the auto rescan. Measure how long it \n> > takes to finish the rescan and if it takes longer than X seconds then \n> > tell the user that they can use this option to disable this. If they \n> > don't mind the delay they can keep on using it.\n> > \n> > I am working on a patch to add this. Will send it in a day or two.\n> \n> Sounds good to me. While I personally don't think such a check is\n> necessary in this case, I also have nothing against it if you find it\n> important.\n> \n> It just needs to be possible to disable that check itself, too. I\n> certainly wouldn't want to be bothered by it, even if the rescan should\n> take longer than whatever threshold you decide on. So if you put up a\n> dialog to inform the user, the dialog should ideally have a \"Don't show\n> again\" option.\n\nThat's the plan. It will be a yes/no/cancel prompt. Saying yes or no \nsets auto rescan to on/off and the message won't pop up again. Saying \ncancel does nothing and you will see the popup again on the next long \nrescan.\n \n> \n> >> Cc:-ing a few people who were involved in the discussion on Pratyush's\n> >> similar patch last summer. [0]\n> >>\n> >>\n> >> [0] <https://lore.kernel.org/git/20190728151726.9188-1-\n> >>      me@yadavpratyush.com/>\n> >>\n> >>\n> >>>\n> >>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n> >>> ---\n> >>>  git-gui.sh     | 5 +++++\n> >>>  lib/option.tcl | 1 +\n> >>>  2 files changed, 6 insertions(+)\n> >>>\n> >>> diff --git a/git-gui.sh b/git-gui.sh\n> >>> index 867b8ce..14735a3 100755\n> >>> --- a/git-gui.sh\n> >>> +++ b/git-gui.sh\n> >>> @@ -906,6 +906,7 @@ set font_descs {\n> >>>  }\n> >>>  set default_config(gui.stageuntracked) ask\n> >>>  set default_config(gui.displayuntracked) true\n> >>> +set default_config(gui.autorescan) true\n> >>>\n> >>>  ######################################################################\n> >>>  ##\n> >>> @@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}\n> >>>  bind .   <Alt-Key-3> {focus $::ui_diff}\n> >>>  bind .   <Alt-Key-4> {focus $::ui_comm}\n> >>>\n> >>> +if {[is_config_true gui.autorescan]} {\n> >>> +\tbind .   <FocusIn>  { if {\"%W\" eq \".\"} do_rescan }\n> >>> +}\n> >>> +\n> >>>  set file_lists_last_clicked($ui_index) {}\n> >>>  set file_lists_last_clicked($ui_workdir) {}\n> >>>\n> >>> diff --git a/lib/option.tcl b/lib/option.tcl\n> >>> index e43971b..9e83db7 100644\n> >>> --- a/lib/option.tcl\n> >>> +++ b/lib/option.tcl\n> >>> @@ -145,6 +145,7 @@ proc do_options {} {\n> >>>  \t\t{b merge.diffstat {mc \"Show Diffstat After Merge\"}}\n> >>>  \t\t{t merge.tool {mc \"Use Merge Tool\"}}\n> >>>\n> >>> +\t\t{b gui.autorescan  {mc \"Auto-Rescan On Activate\"}}\n> >>>  \t\t{b gui.trustmtime  {mc \"Trust File Modification Timestamps\"}}\n> >>>  \t\t{b gui.pruneduringfetch {mc \"Prune Tracking Branches During Fetch\"}}\n> >>>  \t\t{b gui.matchtrackingbranch {mc \"Match Tracking Branches\"}}\n> >>> --\n> >>> 2.29.2\n> >>>\n> > \n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"410213","messageId":"e691c62c-7fb2-6a7d-0f02-7c0ab021f738@haller-berlin.de","threadId":"54549","inReplyTo":"20201117120519.nlm7hwnilzwalgho@yadavpratyush.com","subject":"Re: [PATCH v2 1/1] git-gui: Auto-rescan on activate","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2020-11-18T09:17:21Z","receivedAt":"2020-11-18T09:17:27Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"On 17.11.20 13:05, Pratyush Yadav wrote:\n> On 17/11/20 12:13PM, Stefan Haller wrote:\n>> On 17.11.20 8:36, Pratyush Yadav wrote:\n>>> Hi Stefan,\n>>>\n>>> On 14/11/20 08:14PM, Stefan Haller wrote:\n>>>> On 03.11.20 17:16, Stefan Haller wrote:\n>>>>> Do an automatic rescan whenever the git-gui window receives focus. Most other\n>>>>> GUI tools do this, and it's very convenient; no more pressing F5 manually.\n>>>>>\n>>>>> People who don't like this behavior can turn it off in the Options dialog.\n>>>>\n>>>> Ping - any thoughts? I have been running with this patch for a few weeks\n>>>> now, and I already don't want to miss it any more.\n>>>\n>>> I have been staring at your patch for the last few days with indecision. \n>>> I have finally made up my mind. I do not think it is a good idea to hurt \n>>> the experience of a significant population of our users without at least \n>>> telling them how they can fix it.\n>>>\n>>> The config option is not very visible at all. Experience has told me \n>>> that people don't often go looking around in the options menu to find a \n>>> fix for their problem. So we need to do a better job of educating them \n>>> why they might be experiencing slowdowns and how they can avoid them.\n>>>\n>>> Let's take inspiration from git status. When the local branch diverges \n>>> from the upstream branch, git status shows you how many commits your \n>>> branch is ahead and how many commits behind upstream. This can be an \n>>> expensive operation if the divergence point is far behind. In those \n>>> cases, git status prints something like:\n>>>\n>>>   It took 30.00 seconds to calculate the branch ahead/behind values.\n>>>   You can use '--no-ahead-behind' to avoid this.\n>>>\n>>> This made me aware this option existed and that I can use it to avoid \n>>> slowdowns.\n>>>\n>>> We should do something similar for the auto rescan. Measure how long it \n>>> takes to finish the rescan and if it takes longer than X seconds then \n>>> tell the user that they can use this option to disable this. If they \n>>> don't mind the delay they can keep on using it.\n>>>\n>>> I am working on a patch to add this. Will send it in a day or two.\n>>\n>> Sounds good to me. While I personally don't think such a check is\n>> necessary in this case, I also have nothing against it if you find it\n>> important.\n>>\n>> It just needs to be possible to disable that check itself, too. I\n>> certainly wouldn't want to be bothered by it, even if the rescan should\n>> take longer than whatever threshold you decide on. So if you put up a\n>> dialog to inform the user, the dialog should ideally have a \"Don't show\n>> again\" option.\n> \n> That's the plan. It will be a yes/no/cancel prompt. Saying yes or no \n> sets auto rescan to on/off and the message won't pop up again. Saying \n> cancel does nothing and you will see the popup again on the next long \n> rescan.\n\nInteresting. After thinking about this for a while, I'm not convinced\nthat a Yes/No/Cancel dialog is the best user experience for this, for\nthe following reasons:\n\n- It isn't obvious whether clicking No will turn auto-rescan off only\n  for this repo, or globally (unless you provide two different buttons\n  for this).\n\n- It doesn't teach users how they can turn it back on if they clicked No\n  too hastily (e.g. because they didn't immediately understand the\n  difference between No and Cancel).\n\n- It isn't really intuitively obvious what \"Cancel\" means. What is the\n  operation that is being cancelled here? The rescan itself has already\n  happened. (Yes, I know that the operation being cancelled is the\n  process of deciding whether the option should be turned off, but as I\n  said, I don't find this intuitive.)\n\nI think it might be a better user experience to have a dialog like this:\n\n      The automatic rescan on activating the application has\n      taken more than X seconds. If this bothers you, you can\n      turn it off in the Preferences dialog.\n\n            [x] Don't show again\n                                             [OK]\n\n\nThe only downside is that it's more work to implement, as you can't use\ntk_messageBox.\n\nAll of this is just my humble opinion; if you decide to stick to your\nplan, that's ok with me too.\n\n\n>>>> Cc:-ing a few people who were involved in the discussion on Pratyush's\n>>>> similar patch last summer. [0]\n>>>>\n>>>>\n>>>> [0] <https://lore.kernel.org/git/20190728151726.9188-1-\n>>>>      me@yadavpratyush.com/>\n>>>>\n>>>>\n>>>>>\n>>>>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n>>>>> ---\n>>>>>  git-gui.sh     | 5 +++++\n>>>>>  lib/option.tcl | 1 +\n>>>>>  2 files changed, 6 insertions(+)\n>>>>>\n>>>>> diff --git a/git-gui.sh b/git-gui.sh\n>>>>> index 867b8ce..14735a3 100755\n>>>>> --- a/git-gui.sh\n>>>>> +++ b/git-gui.sh\n>>>>> @@ -906,6 +906,7 @@ set font_descs {\n>>>>>  }\n>>>>>  set default_config(gui.stageuntracked) ask\n>>>>>  set default_config(gui.displayuntracked) true\n>>>>> +set default_config(gui.autorescan) true\n>>>>>\n>>>>>  ######################################################################\n>>>>>  ##\n>>>>> @@ -4007,6 +4008,10 @@ bind .   <Alt-Key-2> {focus_widget $::ui_index}\n>>>>>  bind .   <Alt-Key-3> {focus $::ui_diff}\n>>>>>  bind .   <Alt-Key-4> {focus $::ui_comm}\n>>>>>\n>>>>> +if {[is_config_true gui.autorescan]} {\n>>>>> +\tbind .   <FocusIn>  { if {\"%W\" eq \".\"} do_rescan }\n>>>>> +}\n>>>>> +\n>>>>>  set file_lists_last_clicked($ui_index) {}\n>>>>>  set file_lists_last_clicked($ui_workdir) {}\n>>>>>\n>>>>> diff --git a/lib/option.tcl b/lib/option.tcl\n>>>>> index e43971b..9e83db7 100644\n>>>>> --- a/lib/option.tcl\n>>>>> +++ b/lib/option.tcl\n>>>>> @@ -145,6 +145,7 @@ proc do_options {} {\n>>>>>  \t\t{b merge.diffstat {mc \"Show Diffstat After Merge\"}}\n>>>>>  \t\t{t merge.tool {mc \"Use Merge Tool\"}}\n>>>>>\n>>>>> +\t\t{b gui.autorescan  {mc \"Auto-Rescan On Activate\"}}\n>>>>>  \t\t{b gui.trustmtime  {mc \"Trust File Modification Timestamps\"}}\n>>>>>  \t\t{b gui.pruneduringfetch {mc \"Prune Tracking Branches During Fetch\"}}\n>>>>>  \t\t{b gui.matchtrackingbranch {mc \"Match Tracking Branches\"}}\n>>>>> --\n>>>>> 2.29.2\n>>>>>\n>>>\n> \n"},{"id":"412500","messageId":"e5f6753b-10b3-1291-1b39-34af63792037@kdbg.org","threadId":"54549","inReplyTo":"20201101170505.71246-1-stefan@haller-berlin.de","subject":"Re: [PATCH 0/2] git-gui: Auto-rescan on activate","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2020-12-17T19:45:38Z","receivedAt":"2020-12-17T19:46:39Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 01.11.20 um 18:05 schrieb Stefan Haller:\n> Do an automatic rescan whenever the git-gui window receives focus. Most other\n> GUI tools do this, and it's very convenient; no more pressing F5 manually.\n> \n> People who don't like this behavior can turn it off using\n> \"git config gui.autorescan false\".\n> \n> Stefan Haller (2):\n>   git-gui: Delay rescan until idle time\n>   git-gui: Auto-rescan on activate\n> \n>  git-gui.sh | 26 ++++++++++++++++++++++----\n>  1 file changed, 22 insertions(+), 4 deletions(-)\n> \n\nI've been using these patches in the past days.\n\nI am still a bit ambivalent on whether I like the behavior. I do switch\namong windows *a lot* and there is a short flicker on every rescan. And\nthere is muscle memory...\n\nI observe a bug and a half:\n\nIt is unclear which file is selected automatically when there are\nunstaged changes. But there is one misbehavior: after I have invoked the\nmerge tool, resolved the conflict, and then switch back to Git GUI, the\nconflicted file is not selected anymore when it is not the first file in\nthe list. That is *very* annoying.\n\nAnd then there is the following use-case. While Git GUI is not active\n(think Git GUI and Gitk side-by-side and Gitk active), I click on a\nparticular file that is not at the top of the list; then Git GUI becomes\nactive and rescans, but also forgets on which file I have clicked. But I\nexpected the clicked-on file to become visible, which it doesn't, and I\nhave to click again. This is mildly annoying.\n\n-- Hannes\n"},{"id":"412503","messageId":"20201217201051.am33p6h2xu6wq34s@yadavpratyush.com","threadId":"54549","inReplyTo":"e5f6753b-10b3-1291-1b39-34af63792037@kdbg.org","subject":"Re: [PATCH 0/2] git-gui: Auto-rescan on activate","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2020-12-17T20:10:51Z","receivedAt":"2020-12-17T20:11:37Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi,\n\nOn 17/12/20 08:45PM, Johannes Sixt wrote:\n> Am 01.11.20 um 18:05 schrieb Stefan Haller:\n> > Do an automatic rescan whenever the git-gui window receives focus. Most other\n> > GUI tools do this, and it's very convenient; no more pressing F5 manually.\n> > \n> > People who don't like this behavior can turn it off using\n> > \"git config gui.autorescan false\".\n> > \n> > Stefan Haller (2):\n> >   git-gui: Delay rescan until idle time\n> >   git-gui: Auto-rescan on activate\n> > \n> >  git-gui.sh | 26 ++++++++++++++++++++++----\n> >  1 file changed, 22 insertions(+), 4 deletions(-)\n> > \n> \n> I've been using these patches in the past days.\n> \n> I am still a bit ambivalent on whether I like the behavior. I do switch\n> among windows *a lot* and there is a short flicker on every rescan. And\n> there is muscle memory...\n\nThis is part of the reason I am a little uneasy enabling it by default, \nand why I insist on having a loud and clear warning to the users about \nwhat is going on.\n \n> I observe a bug and a half:\n> \n> It is unclear which file is selected automatically when there are\n> unstaged changes. But there is one misbehavior: after I have invoked the\n> merge tool, resolved the conflict, and then switch back to Git GUI, the\n> conflicted file is not selected anymore when it is not the first file in\n> the list. That is *very* annoying.\n\nHaven't had a chance to try this out yet but AFAIK the last file should \nbe correctly remembered. See below.\n \n> And then there is the following use-case. While Git GUI is not active\n> (think Git GUI and Gitk side-by-side and Gitk active), I click on a\n> particular file that is not at the top of the list; then Git GUI becomes\n> active and rescans, but also forgets on which file I have clicked. But I\n> expected the clicked-on file to become visible, which it doesn't, and I\n> have to click again. This is mildly annoying.\n\nHmm, I don't see that on my system on Linux. The code to remember last \nopen file is there in 'rescan_done'. So I don't understand why this \nbecomes a problem on your system.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"412508","messageId":"f4e51020-e7e2-cfd6-7631-ca5f32850746@kdbg.org","threadId":"54549","inReplyTo":"20201217201051.am33p6h2xu6wq34s@yadavpratyush.com","subject":"Re: [PATCH 0/2] git-gui: Auto-rescan on activate","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2020-12-17T22:21:04Z","receivedAt":"2020-12-17T22:22:04Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 17.12.20 um 21:10 schrieb Pratyush Yadav:\n> On 17/12/20 08:45PM, Johannes Sixt wrote:\n>> It is unclear which file is selected automatically when there are\n>> unstaged changes. But there is one misbehavior: after I have invoked the\n>> merge tool, resolved the conflict, and then switch back to Git GUI, the\n>> conflicted file is not selected anymore when it is not the first file in\n>> the list. That is *very* annoying.\n> \n> Haven't had a chance to try this out yet but AFAIK the last file should \n> be correctly remembered. See below.\n\nIt doesn't here in the case where I invoke the merge tool via the\ncontext menu in the diff view.\n\n>> And then there is the following use-case. While Git GUI is not active\n>> (think Git GUI and Gitk side-by-side and Gitk active), I click on a\n>> particular file that is not at the top of the list; then Git GUI becomes\n>> active and rescans, but also forgets on which file I have clicked. But I\n>> expected the clicked-on file to become visible, which it doesn't, and I\n>> have to click again. This is mildly annoying.\n> \n> Hmm, I don't see that on my system on Linux. The code to remember last \n> open file is there in 'rescan_done'. So I don't understand why this \n> becomes a problem on your system.\nIt's not \"last open file\"; that works ok. It is \"file A is open, I click\non file B, then rescan happens, now file A is still open\"; at that point\nI want file B open---that's where I clicked. The important part is that\nthe single click on file B must do two things: activate Git GUI, and\nswitch to file B. It worked that way in the past.\n\n-- Hannes\n"},{"id":"412550","messageId":"1271e604-d016-1ddf-8370-49f5d3db44be@haller-berlin.de","threadId":"54549","inReplyTo":"e5f6753b-10b3-1291-1b39-34af63792037@kdbg.org","subject":"Re: [PATCH 0/2] git-gui: Auto-rescan on activate","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2020-12-18T10:36:00Z","receivedAt":"2020-12-18T10:36:59Z","isPatch":true,"sender":{"key":"lists@haller-berlin.de","avatar":null},"body":"Hi Johannes,\n\nthanks for testing! It's good to have people who care about details.\n\n\nOn 17.12.20 20:45, Johannes Sixt wrote:\n> Am 01.11.20 um 18:05 schrieb Stefan Haller:\n>> Do an automatic rescan whenever the git-gui window receives focus. Most other\n>> GUI tools do this, and it's very convenient; no more pressing F5 manually.\n>>\n>> People who don't like this behavior can turn it off using\n>> \"git config gui.autorescan false\".\n>>\n>> Stefan Haller (2):\n>>   git-gui: Delay rescan until idle time\n>>   git-gui: Auto-rescan on activate\n>>\n>>  git-gui.sh | 26 ++++++++++++++++++++++----\n>>  1 file changed, 22 insertions(+), 4 deletions(-)\n>>\n> \n> I've been using these patches in the past days.\n> \n> I am still a bit ambivalent on whether I like the behavior. I do switch\n> among windows *a lot* and there is a short flicker on every rescan. And\n> there is muscle memory...\n\nYes, the flicker is annoying. It also happens when you manually rescan\n(F5) though, so it's not a new problem. You just see it more often now.\nI didn't succeed to fix it yet, but I also didn't try very hard.\n\nAnother problem that's related and can be annoying is that the text\nselection is lost on rescan; so if you select some lines because you\nwant to stage them, and then before staging you briefly switch back to\nyour editor to check something else, then you have to start over when\nyou come back. I guess this could be fixed by remembering the selection\non rescan, in a similar way how we remember the scroll position.\n\nAs for muscle memory, in my experience this is something that you\nunlearn pretty quickly. On the contrary, I'm now having having trouble\nusing git gui on machines that don't have the patch, because I got so\nused to relying on the window to always be up to date automatically.\n\nFor me, I have to say that the auto-rescan is a total game-changer, even\nwith all the problems that it still has. I don't want to do without it\nany more.\n\n> It is unclear which file is selected automatically when there are\n> unstaged changes. But there is one misbehavior: after I have invoked the\n> merge tool, resolved the conflict, and then switch back to Git GUI, the\n> conflicted file is not selected anymore when it is not the first file in\n> the list. That is *very* annoying.\n\nI tried to reproduce this, but couldn't. It would be helpful if you\ncould post a more detailed reproduction recipe.\n\nAnother related aspect: if you select an untracked file and then trigger\na manual rescan, the file is no longer selected; it selects the first\ntracked, modified file instead. I don't know why it does this, I find\nthis annoying. The auto-rescan doesn't have this behavior, it keeps the\nuntracked file selected, which I like.\n\n> And then there is the following use-case. While Git GUI is not active\n> (think Git GUI and Gitk side-by-side and Gitk active), I click on a\n> particular file that is not at the top of the list; then Git GUI becomes\n> active and rescans, but also forgets on which file I have clicked. But I\n> expected the clicked-on file to become visible, which it doesn't, and I\n> have to click again. This is mildly annoying.\n\nLike Pratyush, I can't see why this should happen, and I can't reproduce\nit on my machine (Mac). What system are you on?\n\n-Stefan\n"},{"id":"412578","messageId":"dbe7278e-8a2c-e208-e482-435b9194c0d7@kdbg.org","threadId":"54549","inReplyTo":"1271e604-d016-1ddf-8370-49f5d3db44be@haller-berlin.de","subject":"Re: [PATCH 0/2] git-gui: Auto-rescan on activate","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2020-12-18T18:07:58Z","receivedAt":"2020-12-18T18:08:42Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 18.12.20 um 11:36 schrieb Stefan Haller:\n> On 17.12.20 20:45, Johannes Sixt wrote:\n>> It is unclear which file is selected automatically when there are\n>> unstaged changes. But there is one misbehavior: after I have invoked the\n>> merge tool, resolved the conflict, and then switch back to Git GUI, the\n>> conflicted file is not selected anymore when it is not the first file in\n>> the list. That is *very* annoying.\n> \n> I tried to reproduce this, but couldn't. It would be helpful if you\n> could post a more detailed reproduction recipe.\n\nI cannot reproduce this on Linux. But I am on Windows most of the time,\nwhere it happens always. Note that you need two conflicted files. For\nexample (in a temporary git.git worktree):\n\n   git checkout b4100f366c1e~\n   git -c rerere.enabled=0 merge b4100f366c1e^2\n\nSelect the second conflicted file, invoke the merge tool via the context\nmenu, resolve the conflict, save and close the merge tool. Notice that\nthe first conflicted file is now selected.\n\nNote that a rescan happens automatically even without the patch under\ndiscussion when the merge tool (when invoked via the context menu) is\nclosed. This patch starts a simultaneous rescan. Perhaps it is a timing\nproblem of some sort.\n\n> Another related aspect: if you select an untracked file and then trigger\n> a manual rescan, the file is no longer selected; it selects the first\n> tracked, modified file instead. I don't know why it does this, I find\n> this annoying. The auto-rescan doesn't have this behavior, it keeps the\n> untracked file selected, which I like.\n\nThe idea behind the old behavior is that a change is more important than\nan untracked file. Also, a conflicted file is more important than a\nchange; hence, if you have a normal unstaged change selected, and then\nrescan, a conflicted file is selected.\n\n>> And then there is the following use-case. While Git GUI is not active\n>> (think Git GUI and Gitk side-by-side and Gitk active), I click on a\n>> particular file that is not at the top of the list; then Git GUI becomes\n>> active and rescans, but also forgets on which file I have clicked. But I\n>> expected the clicked-on file to become visible, which it doesn't, and I\n>> have to click again. This is mildly annoying.\n> \n> Like Pratyush, I can't see why this should happen, and I can't reproduce\n> it on my machine (Mac). What system are you on?\n\nI can reproduce this on my Linux box the same way as it happens on\nWindows. Just have two files with changes, then activate another window\nsuch that the unstaged file list remains visible, then click on the\nunselected file in Git GUI. Notice that it is not selected after Git GUI\nbecomes active.\n\n-- Hannes\n"}]}