All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Fix git-gui when recentrepo list has duplicates
@ 2015-12-16 23:58 Philip Oakley
  2015-12-16 23:58 ` [PATCH v2 1/4] git-gui: de-dup entries from gui.recentrepo Philip Oakley
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Philip Oakley @ 2015-12-16 23:58 UTC (permalink / raw)
  To: GitList; +Cc: Eric Sunshine, Pat Thoyts, Alexey Astakhov, Philip Oakley

git-gui won't start if either there are duplicate invalid entries or
the user selects a duplicated entry from the gui.recentrepo list. Such
duplicates have been found in the wild.

V2 corrects the spellings, grammar and quoting errors in the commit
messages as noted by Eric Sunshine ($gmane/282430 & $gmane/282432)

Also patch 1/4 title has been shortened

This re-roll will hopefully give Pat an opportunity to consider including
the fix into the git-gui for Git V2.7

V1 series at $gmane/282360


Philip Oakley (4):
  git-gui: de-dup entries from gui.recentrepo
  git gui: cope with duplicates in _get_recentrepo
  git gui: de-dup selected repo from recentrepo history
  git gui: allow for a long recentrepo list

 git-gui/lib/choose_repository.tcl | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

-- 
2.6.4.windows.1

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

* [PATCH v2 1/4] git-gui: de-dup entries from gui.recentrepo
  2015-12-16 23:58 [PATCH v2 0/4] Fix git-gui when recentrepo list has duplicates Philip Oakley
@ 2015-12-16 23:58 ` Philip Oakley
  2015-12-16 23:58 ` [PATCH v2 2/4] git gui: cope with duplicates in _get_recentrepo Philip Oakley
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Philip Oakley @ 2015-12-16 23:58 UTC (permalink / raw)
  To: GitList; +Cc: Eric Sunshine, Pat Thoyts, Alexey Astakhov, Philip Oakley

The git gui's recent repo list may become contaminated with duplicate
entries. The git gui would barf when attempting to remove one entry.
Remove them all - there is no option within 'git config' to selectively
remove one of the entries.

This issue was reported on the 'Git User' list
(https://groups.google.com/forum/#!topic/git-users/msev4KsQGFc,
"Warning: gui.recentrepo has multiply values while executing").

On startup the gui checks that entries in the recentrepo list are still
valid repos and deletes those that are not. If duplicate entries are
present, then 'git config --unset' will barf and this prevents the gui
from starting.

Subsequent patches fix other parts of recentrepo logic used for syncing
internal lists with the external .gitconfig.

Reported-by: Alexey Astakhov <asstv7@gmail.com>
Signed-off-by: Philip Oakley <philipoakley@iee.org>
---
tightened the patch title
user report thread title now quoted
spelling corrected
fixed grammar (comma)
Eric's comments $gmane/282430
---
 git-gui/lib/choose_repository.tcl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index 75d1da8..133ca0a 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -247,7 +247,7 @@ proc _get_recentrepos {} {
 
 proc _unset_recentrepo {p} {
 	regsub -all -- {([()\[\]{}\.^$+*?\\])} $p {\\\1} p
-	git config --global --unset gui.recentrepo "^$p\$"
+	git config --global --unset-all gui.recentrepo "^$p\$"
 	load_config 1
 }
 
-- 
2.6.4.windows.1

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

* [PATCH v2 2/4] git gui: cope with duplicates in _get_recentrepo
  2015-12-16 23:58 [PATCH v2 0/4] Fix git-gui when recentrepo list has duplicates Philip Oakley
  2015-12-16 23:58 ` [PATCH v2 1/4] git-gui: de-dup entries from gui.recentrepo Philip Oakley
@ 2015-12-16 23:58 ` Philip Oakley
  2015-12-16 23:58 ` [PATCH v2 3/4] git gui: de-dup selected repo from recentrepo history Philip Oakley
  2015-12-16 23:58 ` [PATCH v2 4/4] git gui: allow for a long recentrepo list Philip Oakley
  3 siblings, 0 replies; 11+ messages in thread
From: Philip Oakley @ 2015-12-16 23:58 UTC (permalink / raw)
  To: GitList; +Cc: Eric Sunshine, Pat Thoyts, Alexey Astakhov, Philip Oakley

_get_recentrepo will fail if duplicate invalid entries are present
in the recentrepo config list. The previous commit fixed the
'git config' limitations in _unset_recentrepo by unsetting all config
entries, however this code would fail on the second attempt to unset it.

Refactor the code to pre-sort and de-duplicate the recentrepo list to
avoid a potential second unset attempt.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
---
 git-gui/lib/choose_repository.tcl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index 133ca0a..aa87bcc 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -235,14 +235,14 @@ method _invoke_next {} {
 
 proc _get_recentrepos {} {
 	set recent [list]
-	foreach p [get_config gui.recentrepo] {
+	foreach p [lsort -unique [get_config gui.recentrepo]] {
 		if {[_is_git [file join $p .git]]} {
 			lappend recent $p
 		} else {
 			_unset_recentrepo $p
 		}
 	}
-	return [lsort $recent]
+	return $recent
 }
 
 proc _unset_recentrepo {p} {
-- 
2.6.4.windows.1

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

* [PATCH v2 3/4] git gui: de-dup selected repo from recentrepo history
  2015-12-16 23:58 [PATCH v2 0/4] Fix git-gui when recentrepo list has duplicates Philip Oakley
  2015-12-16 23:58 ` [PATCH v2 1/4] git-gui: de-dup entries from gui.recentrepo Philip Oakley
  2015-12-16 23:58 ` [PATCH v2 2/4] git gui: cope with duplicates in _get_recentrepo Philip Oakley
@ 2015-12-16 23:58 ` Philip Oakley
  2015-12-16 23:58 ` [PATCH v2 4/4] git gui: allow for a long recentrepo list Philip Oakley
  3 siblings, 0 replies; 11+ messages in thread
From: Philip Oakley @ 2015-12-16 23:58 UTC (permalink / raw)
  To: GitList; +Cc: Eric Sunshine, Pat Thoyts, Alexey Astakhov, Philip Oakley

When the gui/user selects a repo for display, that repo is brought to
the end of the recentrepo config list. The logic can fail if there are
duplicate old entries for the repo (you cannot unset a single config
entry when duplicates are present).

Similarly, the maxrecentrepo logic could fail if older duplicate entries
are present.

The first commit of this series ({this}~2) fixed the config unsetting
issue. Rather than manipulating a local copy of the $recent list (one
cannot know how many entries were removed), simply re-read it.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
---
 git-gui/lib/choose_repository.tcl | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index aa87bcc..ad7a888 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -262,12 +262,11 @@ proc _append_recentrepos {path} {
 	set i [lsearch $recent $path]
 	if {$i >= 0} {
 		_unset_recentrepo $path
-		set recent [lreplace $recent $i $i]
 	}
 
-	lappend recent $path
 	git config --global --add gui.recentrepo $path
 	load_config 1
+	set recent [get_config gui.recentrepo]
 
 	if {[set maxrecent [get_config gui.maxrecentrepo]] eq {}} {
 		set maxrecent 10
@@ -275,7 +274,7 @@ proc _append_recentrepos {path} {
 
 	while {[llength $recent] > $maxrecent} {
 		_unset_recentrepo [lindex $recent 0]
-		set recent [lrange $recent 1 end]
+		set recent [get_config gui.recentrepo]
 	}
 }
 
-- 
2.6.4.windows.1

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

* [PATCH v2 4/4] git gui: allow for a long recentrepo list
  2015-12-16 23:58 [PATCH v2 0/4] Fix git-gui when recentrepo list has duplicates Philip Oakley
                   ` (2 preceding siblings ...)
  2015-12-16 23:58 ` [PATCH v2 3/4] git gui: de-dup selected repo from recentrepo history Philip Oakley
@ 2015-12-16 23:58 ` Philip Oakley
  2015-12-17 19:32   ` Junio C Hamano
  3 siblings, 1 reply; 11+ messages in thread
From: Philip Oakley @ 2015-12-16 23:58 UTC (permalink / raw)
  To: GitList; +Cc: Eric Sunshine, Pat Thoyts, Alexey Astakhov, Philip Oakley

The gui.recentrepo list may be longer than the maxrecent setting.
Allow extra space to show any extra entries.

In an ideal world, the git gui would limit the number of entries
to the maxrecent setting, however the recentrepo config list may
have been extended outside of the gui, or the maxrecent setting changed
to a reduced value. Further, when testing the gui's recentrepo
logic it is useful to show these extra, but valid, entries.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
---
word usage corrected.
Eric's comments $gmane/282432
---
 git-gui/lib/choose_repository.tcl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index ad7a888..a08ed4f 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -153,7 +153,7 @@ constructor pick {} {
 			-background [get_bg_color $w_body.recentlabel] \
 			-wrap none \
 			-width 50 \
-			-height $maxrecent
+			-height [expr {$maxrecent + 5}]
 		$w_recentlist tag conf link \
 			-foreground blue \
 			-underline 1
-- 
2.6.4.windows.1

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

* Re: [PATCH v2 4/4] git gui: allow for a long recentrepo list
  2015-12-16 23:58 ` [PATCH v2 4/4] git gui: allow for a long recentrepo list Philip Oakley
@ 2015-12-17 19:32   ` Junio C Hamano
  2015-12-17 20:09     ` Philip Oakley
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2015-12-17 19:32 UTC (permalink / raw)
  To: Philip Oakley; +Cc: GitList, Eric Sunshine, Pat Thoyts, Alexey Astakhov

Philip Oakley <philipoakley@iee.org> writes:

> The gui.recentrepo list may be longer than the maxrecent setting.
> Allow extra space to show any extra entries.
>
> In an ideal world, the git gui would limit the number of entries
> to the maxrecent setting, however the recentrepo config list may
> have been extended outside of the gui, or the maxrecent setting changed
> to a reduced value. Further, when testing the gui's recentrepo
> logic it is useful to show these extra, but valid, entries.

I do not have a strong objection either way, but the magic number 5
smells like an indication that this is solving a wrong problem or
solving a problem in a wrong approach.  What happens to the entries
beyond $maxrecent-th in the recent list with the current code?  The
list effectively truncated and not shown?  Wouldn't the same thing
happen to the entries beyond ($maxrecent+5)-th in the recent list
with your patch?

Truncating the list at $maxrecent-th to match the display
(i.e. declare that "$maxrecent" is really the max number of entries
we would keep track of), or allowing the UI to scroll so that
entries beyond $maxrecent-th one can be shown, perhaps?

>
> Signed-off-by: Philip Oakley <philipoakley@iee.org>
> ---
> word usage corrected.
> Eric's comments $gmane/282432
> ---
>  git-gui/lib/choose_repository.tcl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
> index ad7a888..a08ed4f 100644
> --- a/git-gui/lib/choose_repository.tcl
> +++ b/git-gui/lib/choose_repository.tcl
> @@ -153,7 +153,7 @@ constructor pick {} {
>  			-background [get_bg_color $w_body.recentlabel] \
>  			-wrap none \
>  			-width 50 \
> -			-height $maxrecent
> +			-height [expr {$maxrecent + 5}]
>  		$w_recentlist tag conf link \
>  			-foreground blue \
>  			-underline 1

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

* Re: [PATCH v2 4/4] git gui: allow for a long recentrepo list
  2015-12-17 19:32   ` Junio C Hamano
@ 2015-12-17 20:09     ` Philip Oakley
  2015-12-17 22:11       ` Philip Oakley
  0 siblings, 1 reply; 11+ messages in thread
From: Philip Oakley @ 2015-12-17 20:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: GitList, Eric Sunshine, Pat Thoyts, Alexey Astakhov

From: "Junio C Hamano" <gitster@pobox.com>, December 17, 2015 7:32 PM
> Philip Oakley <philipoakley@iee.org> writes:
>
>> The gui.recentrepo list may be longer than the maxrecent setting.
>> Allow extra space to show any extra entries.
>>
>> In an ideal world, the git gui would limit the number of entries
>> to the maxrecent setting, however the recentrepo config list may
>> have been extended outside of the gui, or the maxrecent setting changed
>> to a reduced value. Further, when testing the gui's recentrepo
>> logic it is useful to show these extra, but valid, entries.
>
> I do not have a strong objection either way, but the magic number 5
> smells like an indication that this is solving a wrong problem or
> solving a problem in a wrong approach.  What happens to the entries
> beyond $maxrecent-th in the recent list with the current code?  The
> list effectively truncated and not shown?  Wouldn't the same thing
> happen to the entries beyond ($maxrecent+5)-th in the recent list
> with your patch?

True, it was a magic number selected as being a moderate overspill 
allowance.
I tried 3 and 5 as possible values, and 5 didn't look ungainly, even on my 
small netbook, and covered all my test hacking cases.

The issue was that the prior code assumed that the fault could never happen 
and limited the display, which is sorted, to the max value, so in a fault 
condition the most recent repo could fall off the bottom.

As a bit of 'monkey patching' I wasn't sure how the dialog creation could 
know in advance how long the list would be, so I simply added on a small 
margin.

>
> Truncating the list at $maxrecent-th to match the display
> (i.e. declare that "$maxrecent" is really the max number of entries
> we would keep track of), or allowing the UI to scroll so that
> entries beyond $maxrecent-th one can be shown, perhaps?

This would certainly be a reasonable approach, but I don't know enough of 
the tcl to know how to make it happen. If anyone has suggestions...

>
>>
>> Signed-off-by: Philip Oakley <philipoakley@iee.org>
>> ---
>> word usage corrected.
>> Eric's comments $gmane/282432
>> ---
>>  git-gui/lib/choose_repository.tcl | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/git-gui/lib/choose_repository.tcl 
>> b/git-gui/lib/choose_repository.tcl
>> index ad7a888..a08ed4f 100644
>> --- a/git-gui/lib/choose_repository.tcl
>> +++ b/git-gui/lib/choose_repository.tcl
>> @@ -153,7 +153,7 @@ constructor pick {} {
>>  -background [get_bg_color $w_body.recentlabel] \
>>  -wrap none \
>>  -width 50 \
>> - -height $maxrecent
>> + -height [expr {$maxrecent + 5}]
>>  $w_recentlist tag conf link \
>>  -foreground blue \
>>  -underline 1
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH v2 4/4] git gui: allow for a long recentrepo list
  2015-12-17 20:09     ` Philip Oakley
@ 2015-12-17 22:11       ` Philip Oakley
  2015-12-17 22:40         ` [PATCH v3 " Philip Oakley
  0 siblings, 1 reply; 11+ messages in thread
From: Philip Oakley @ 2015-12-17 22:11 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: GitList, Eric Sunshine, Pat Thoyts, Alexey Astakhov

From: "Philip Oakley" <philipoakley@iee.org>
> From: "Junio C Hamano" <gitster@pobox.com>, December 17, 2015 7:32 PM
>> Philip Oakley <philipoakley@iee.org> writes:
>>
>>> The gui.recentrepo list may be longer than the maxrecent setting.
>>> Allow extra space to show any extra entries.
>>>
>>> In an ideal world, the git gui would limit the number of entries
>>> to the maxrecent setting, however the recentrepo config list may
>>> have been extended outside of the gui, or the maxrecent setting changed
>>> to a reduced value. Further, when testing the gui's recentrepo
>>> logic it is useful to show these extra, but valid, entries.
>>
>> I do not have a strong objection either way, but the magic number 5
>> smells like an indication that this is solving a wrong problem or
>> solving a problem in a wrong approach.  What happens to the entries
>> beyond $maxrecent-th in the recent list with the current code?  The
>> list effectively truncated and not shown?  Wouldn't the same thing
>> happen to the entries beyond ($maxrecent+5)-th in the recent list
>> with your patch?
>
> True, it was a magic number selected as being a moderate overspill 
> allowance.
> I tried 3 and 5 as possible values, and 5 didn't look ungainly, even on my 
> small netbook, and covered all my test hacking cases.
>
> The issue was that the prior code assumed that the fault could never 
> happen and limited the display, which is sorted, to the max value, so in a 
> fault condition the most recent repo could fall off the bottom.
>
> As a bit of 'monkey patching' I wasn't sure how the dialog creation could 
> know in advance how long the list would be, so I simply added on a small 
> margin.
>
>>
>> Truncating the list at $maxrecent-th to match the display
>> (i.e. declare that "$maxrecent" is really the max number of entries
>> we would keep track of), or allowing the UI to scroll so that
>> entries beyond $maxrecent-th one can be shown, perhaps?
>
> This would certainly be a reasonable approach, but I don't know enough of 
> the tcl to know how to make it happen. If anyone has suggestions...

I think I see the way to do it. V3 Patch 4/4 to follow.
>
>>
>>>
>>> Signed-off-by: Philip Oakley <philipoakley@iee.org>
>>> ---
>>> word usage corrected.
>>> Eric's comments $gmane/282432
>>> ---
>>>  git-gui/lib/choose_repository.tcl | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/git-gui/lib/choose_repository.tcl 
>>> b/git-gui/lib/choose_repository.tcl
>>> index ad7a888..a08ed4f 100644
>>> --- a/git-gui/lib/choose_repository.tcl
>>> +++ b/git-gui/lib/choose_repository.tcl
>>> @@ -153,7 +153,7 @@ constructor pick {} {
>>>  -background [get_bg_color $w_body.recentlabel] \
>>>  -wrap none \
>>>  -width 50 \
>>> - -height $maxrecent
>>> + -height [expr {$maxrecent + 5}]
>>>  $w_recentlist tag conf link \
>>>  -foreground blue \
>>>  -underline 1
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* [PATCH v3 4/4] git gui: allow for a long recentrepo list
  2015-12-17 22:11       ` Philip Oakley
@ 2015-12-17 22:40         ` Philip Oakley
  2015-12-17 23:29           ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Philip Oakley @ 2015-12-17 22:40 UTC (permalink / raw)
  To: GitList, Junio C Hamano, Pat Thoyts
  Cc: Eric Sunshine, Alexey Astakhov, Philip Oakley

The gui.recentrepo list may be longer than the maxrecent setting.
Use the actual length determined earlier, now saved as $lenrecent.

In an ideal world, the git gui would limit the number of entries
to the maxrecent setting, however the recentrepo config list may
have been extended outside of the gui, or the maxrecent setting changed
to a reduced value. Further, when testing the gui's recentrepo
logic it is useful to show these extra, but valid, entries.

The list length will be trimmed to $maxrecent after the user selects
a repo to open.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
---
V2:
word usage corrected.
Eric's comments $gmane/282432
V3: 
Updated list length measure following Junio's comments $gmane/282669

Replaces the previous V2 Patch 4/4.

---
 git-gui/lib/choose_repository.tcl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index ad7a888..b4cc7dd 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -134,7 +134,8 @@ constructor pick {} {
 	$opts conf -state disabled
 
 	set sorted_recent [_get_recentrepos]
-	if {[llength $sorted_recent] > 0} {
+	set lenrecent [llength $sorted_recent]
+	if {$lenrecent > 0} {
 		if {$m_repo ne {}} {
 			$m_repo add separator
 			$m_repo add command \
@@ -153,7 +154,7 @@ constructor pick {} {
 			-background [get_bg_color $w_body.recentlabel] \
 			-wrap none \
 			-width 50 \
-			-height $maxrecent
+			-height $lenrecent
 		$w_recentlist tag conf link \
 			-foreground blue \
 			-underline 1
-- 
2.6.4.windows.1

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

* Re: [PATCH v3 4/4] git gui: allow for a long recentrepo list
  2015-12-17 22:40         ` [PATCH v3 " Philip Oakley
@ 2015-12-17 23:29           ` Junio C Hamano
  2015-12-18  0:26             ` Philip Oakley
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2015-12-17 23:29 UTC (permalink / raw)
  To: Philip Oakley; +Cc: GitList, Pat Thoyts, Eric Sunshine, Alexey Astakhov

Philip Oakley <philipoakley@iee.org> writes:

> The gui.recentrepo list may be longer than the maxrecent setting.
> Use the actual length determined earlier, now saved as $lenrecent.
>
> In an ideal world, the git gui would limit the number of entries
> to the maxrecent setting, however the recentrepo config list may
> have been extended outside of the gui, or the maxrecent setting changed
> to a reduced value. Further, when testing the gui's recentrepo
> logic it is useful to show these extra, but valid, entries.
>
> The list length will be trimmed to $maxrecent after the user selects
> a repo to open.
>
> Signed-off-by: Philip Oakley <philipoakley@iee.org>
> ---
> V2:
> word usage corrected.
> Eric's comments $gmane/282432
> V3: 
> Updated list length measure following Junio's comments $gmane/282669
>
> Replaces the previous V2 Patch 4/4.
>
> ---
>  git-gui/lib/choose_repository.tcl | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
> index ad7a888..b4cc7dd 100644
> --- a/git-gui/lib/choose_repository.tcl
> +++ b/git-gui/lib/choose_repository.tcl
> @@ -134,7 +134,8 @@ constructor pick {} {
>  	$opts conf -state disabled
>  
>  	set sorted_recent [_get_recentrepos]
> -	if {[llength $sorted_recent] > 0} {
> +	set lenrecent [llength $sorted_recent]
> +	if {$lenrecent > 0} {
>  		if {$m_repo ne {}} {
>  			$m_repo add separator
>  			$m_repo add command \
> @@ -153,7 +154,7 @@ constructor pick {} {
>  			-background [get_bg_color $w_body.recentlabel] \
>  			-wrap none \
>  			-width 50 \
> -			-height $maxrecent
> +			-height $lenrecent
>  		$w_recentlist tag conf link \
>  			-foreground blue \
>  			-underline 1

Natural questions that come to mind after seeing the above are like
these:

 - Does maxrecent still get used after this change?

 - Does the remainder of the code get upset if -height is set to too
   small (lenrecent might turn out to be 1, for example)?

And grepping for maxrecent shows there is _append_recentrepos that
does this:

proc _append_recentrepos {path} {
	set path [file normalize $path]
	set recent [get_config gui.recentrepo]

	...
	if {[set maxrecent [get_config gui.maxrecentrepo]] eq {}} {
		set maxrecent 10
	}

	while {[llength $recent] > $maxrecent} {
		_unset_recentrepo [lindex $recent 0]
		set recent [lrange $recent 1 end]
	}
}

The last while loop looks to me like truncating the overlong recent
list down to maxrecent.  Perhaps a similar logic needs to be at the
end of _get_recentrepos?

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

* Re: [PATCH v3 4/4] git gui: allow for a long recentrepo list
  2015-12-17 23:29           ` Junio C Hamano
@ 2015-12-18  0:26             ` Philip Oakley
  0 siblings, 0 replies; 11+ messages in thread
From: Philip Oakley @ 2015-12-18  0:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: GitList, Pat Thoyts, Eric Sunshine, Alexey Astakhov

From: "Junio C Hamano" <gitster@pobox.com>
> Philip Oakley <philipoakley@iee.org> writes:
>
>> The gui.recentrepo list may be longer than the maxrecent setting.
>> Use the actual length determined earlier, now saved as $lenrecent.
>>
>> In an ideal world, the git gui would limit the number of entries
>> to the maxrecent setting, however the recentrepo config list may
>> have been extended outside of the gui, or the maxrecent setting changed
>> to a reduced value. Further, when testing the gui's recentrepo
>> logic it is useful to show these extra, but valid, entries.
>>
>> The list length will be trimmed to $maxrecent after the user selects
>> a repo to open.
>>
>> Signed-off-by: Philip Oakley <philipoakley@iee.org>
>> ---
>> V2:
>> word usage corrected.
>> Eric's comments $gmane/282432
>> V3:
>> Updated list length measure following Junio's comments $gmane/282669
>>
>> Replaces the previous V2 Patch 4/4.
>>
>> ---
>>  git-gui/lib/choose_repository.tcl | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/git-gui/lib/choose_repository.tcl 
>> b/git-gui/lib/choose_repository.tcl
>> index ad7a888..b4cc7dd 100644
>> --- a/git-gui/lib/choose_repository.tcl
>> +++ b/git-gui/lib/choose_repository.tcl
>> @@ -134,7 +134,8 @@ constructor pick {} {
>>  $opts conf -state disabled
>>
>>  set sorted_recent [_get_recentrepos]
>> - if {[llength $sorted_recent] > 0} {
>> + set lenrecent [llength $sorted_recent]
>> + if {$lenrecent > 0} {
>>  if {$m_repo ne {}} {
>>  $m_repo add separator
>>  $m_repo add command \
>> @@ -153,7 +154,7 @@ constructor pick {} {
>>  -background [get_bg_color $w_body.recentlabel] \
>>  -wrap none \
>>  -width 50 \
>> - -height $maxrecent
>> + -height $lenrecent
>>  $w_recentlist tag conf link \
>>  -foreground blue \
>>  -underline 1
>
> Natural questions that come to mind after seeing the above are like
> these:
>
> - Does maxrecent still get used after this change?

Yes, essentially as you describe....

>
> - Does the remainder of the code get upset if -height is set to too
>   small (lenrecent might turn out to be 1, for example)?

No it's OK, the code has at least checked it is positive..

>
> And grepping for maxrecent shows there is _append_recentrepos that
> does this:

It does three things:
- removes the current (selected) repo from the list of past repos (and 
removes any duplicates)
- places the current repo at the end
- trims the list to back to max repos.

Nominally, it can't do anything about non-selected valid repos which may be 
listed in the config twice because git config won't selectively remove just 
one of two identical key/values, however in Patch 3 I do remove both older & 
newer entries and re-read the config (some may consider that a small 
regression).

It's not easy working around the contrary assumptions of the gui.recentrepo 
list (once only) and the reality of the .gitconfig (duplicates possible) and 
'git config's --unset/--unset-all limitation.

Exactly how those extra entries get there is an open question, but it does 
happen (so say's google, as well as the user report, I've seen it myself ;-)

>
> proc _append_recentrepos {path} {
> set path [file normalize $path]
> set recent [get_config gui.recentrepo]
>
> ...
> if {[set maxrecent [get_config gui.maxrecentrepo]] eq {}} {
> set maxrecent 10
> }
>
> while {[llength $recent] > $maxrecent} {
> _unset_recentrepo [lindex $recent 0]
> set recent [lrange $recent 1 end]
> }
> }
>
> The last while loop looks to me like truncating the overlong recent
> list down to maxrecent.

Yes

>   Perhaps a similar logic needs to be at the
> end of _get_recentrepos?

The logic here is to show what is in the config to the user, *before* we 
trim the list, hence we wait until the user has selected a repo to open and 
do the purging in _append_recentrepos.

As an aside, there's also a long standing 'feature' that if one works both 
on and off network, then network repo paths get trimmed as soon as the user 
starts the gui while off-net (or the network goes down;-) because those 
recent repo paths become 'invalid' and are purged, but let's not go there.

--
Philip 

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

end of thread, other threads:[~2015-12-18  0:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-16 23:58 [PATCH v2 0/4] Fix git-gui when recentrepo list has duplicates Philip Oakley
2015-12-16 23:58 ` [PATCH v2 1/4] git-gui: de-dup entries from gui.recentrepo Philip Oakley
2015-12-16 23:58 ` [PATCH v2 2/4] git gui: cope with duplicates in _get_recentrepo Philip Oakley
2015-12-16 23:58 ` [PATCH v2 3/4] git gui: de-dup selected repo from recentrepo history Philip Oakley
2015-12-16 23:58 ` [PATCH v2 4/4] git gui: allow for a long recentrepo list Philip Oakley
2015-12-17 19:32   ` Junio C Hamano
2015-12-17 20:09     ` Philip Oakley
2015-12-17 22:11       ` Philip Oakley
2015-12-17 22:40         ` [PATCH v3 " Philip Oakley
2015-12-17 23:29           ` Junio C Hamano
2015-12-18  0:26             ` Philip Oakley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.