threads / patch / 55030

patchgitk: add option to perform 'git fetch' command

Subject: [PATCH] gitk: add option to perform 'git fetch' command

## tl;dr

3 messages between Jan 22, 2021 and Nov 5, 2021. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

Vladimir Chigarev via GitGitGadget· Jan 22, 2021, 15:16 UTC · lore
From: Vladimir Chigarev <chiga17@mail.ru>

There wasn't ability to perform 'git fetch' from gitk tool. Add 'Fetch' option to 'File' menu. Bind it to 'F7' key.

Signed-off-by: Vladimir Chigarev <chiga17@mail.ru>
---
    gitk: add option to perform 'git fetch' command
    
    There wasn't ability to perform 'git fetch' from gitk tool. Add 'Fetch'
    option to 'File' menu. Bind it to 'F7' key.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-872%2Fchiga17%2Fgitk-fetch-option-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-872/chiga17/gitk-fetch-option-v1
Pull-Request: https://github.com/git/git/pull/872
 gitk-git/gitk | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
Show changes to gitk-git/gitk +31 −0
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 23d9dd1fe0d..1756385886f 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -499,6 +499,34 @@ proc getcommits {selid} {
     }
 }
 
+proc fetch {} {
+    global bgcolor NS fetch_output
+
+    set fetch_output {}
+    if {[catch {exec sh -c "git fetch -v 2>&1"} fetch_output]} {
+    }
+
+    set w .about
+    if {[winfo exists $w]} {
+	raise $w
+	return
+    }
+    ttk_toplevel $w
+    wm title $w [mc "Fetch"]
+    make_transient $w .
+    message $w.m -text [mc " $fetch_output "] \
+	    -justify left -aspect 600 -border 2 -bg $bgcolor -relief groove
+    pack $w.m -side top -fill x -padx 2 -pady 2
+    ${NS}::button $w.ok -text [mc "Close"] -command "destroy $w" -default active
+    pack $w.ok -side bottom
+    bind $w <Visibility> "focus $w.ok"
+    bind $w <Key-Escape> "destroy $w"
+    bind $w <Key-Return> "destroy $w"
+    tk::PlaceWindow $w widget .
+
+    reloadcommits
+}
+
 proc updatecommits {} {
     global curview vcanopt vorigargs vfilelimit viewinstances
     global viewactive viewcomplete tclencoding
@@ -2089,6 +2117,7 @@ proc makewindow {} {
         mc "&File" cascade {
             {mc "&Update" command updatecommits -accelerator F5}
             {mc "&Reload" command reloadcommits -accelerator Shift-F5}
+            {mc "&Fetch" command fetch -accelerator F7}
             {mc "Reread re&ferences" command rereadrefs}
             {mc "&List references" command showrefs -accelerator F2}
             {xx "" separator}
@@ -2609,6 +2638,7 @@ proc makewindow {} {
     bindkey f nextfile
     bind . <F5> updatecommits
     bindmodfunctionkey Shift 5 reloadcommits
+    bind . <F7> fetch
     bind . <F2> showrefs
     bindmodfunctionkey Shift 4 {newview 0}
     bind . <F4> edit_or_newview
@@ -3125,6 +3155,7 @@ proc keys {} {
 [mc "<%s-KP->	Decrease font size" $M1T]
 [mc "<%s-minus>	Decrease font size" $M1T]
 [mc "<F5>		Update"]
+[mc "<F7>		Fetch"]
 " \
             -justify left -bg $bgcolor -border 2 -relief groove
     pack $w.m -side top -fill both -padx 2 -pady 2

base-commit: 72c4083ddf91b489b7b7b812df67ee8842177d98
-- 
gitgitgadget
Johannes Schindelin· Apr 7, 2021, 19:43 UTC · re: Vladimir Chigarev via GitGitGadget · lore

Re: [PATCH] gitk: add option to perform 'git fetch' command

[Cc:ing Paul, the gitk maintainer]

Paul, this patch has been stuck on the Git mailing list for a few months. Could I ask you whether there is a chance that you could review it?

Thanks, Johannes

On Fri, 22 Jan 2021, Vladimir Chigarev via GitGitGadget wrote:
Show 89 quoted lines
> From: Vladimir Chigarev <chiga17@mail.ru>
>
> There wasn't ability to perform 'git fetch' from gitk tool.
> Add 'Fetch' option to 'File' menu.
> Bind it to 'F7' key.
>
> Signed-off-by: Vladimir Chigarev <chiga17@mail.ru>
> ---
>     gitk: add option to perform 'git fetch' command
>
>     There wasn't ability to perform 'git fetch' from gitk tool. Add 'Fetch'
>     option to 'File' menu. Bind it to 'F7' key.
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-872%2Fchiga17%2Fgitk-fetch-option-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-872/chiga17/gitk-fetch-option-v1
> Pull-Request: https://github.com/git/git/pull/872
>
>  gitk-git/gitk | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
>
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index 23d9dd1fe0d..1756385886f 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -499,6 +499,34 @@ proc getcommits {selid} {
>      }
>  }
>
> +proc fetch {} {
> +    global bgcolor NS fetch_output
> +
> +    set fetch_output {}
> +    if {[catch {exec sh -c "git fetch -v 2>&1"} fetch_output]} {
> +    }
> +
> +    set w .about
> +    if {[winfo exists $w]} {
> +	raise $w
> +	return
> +    }
> +    ttk_toplevel $w
> +    wm title $w [mc "Fetch"]
> +    make_transient $w .
> +    message $w.m -text [mc " $fetch_output "] \
> +	    -justify left -aspect 600 -border 2 -bg $bgcolor -relief groove
> +    pack $w.m -side top -fill x -padx 2 -pady 2
> +    ${NS}::button $w.ok -text [mc "Close"] -command "destroy $w" -default active
> +    pack $w.ok -side bottom
> +    bind $w <Visibility> "focus $w.ok"
> +    bind $w <Key-Escape> "destroy $w"
> +    bind $w <Key-Return> "destroy $w"
> +    tk::PlaceWindow $w widget .
> +
> +    reloadcommits
> +}
> +
>  proc updatecommits {} {
>      global curview vcanopt vorigargs vfilelimit viewinstances
>      global viewactive viewcomplete tclencoding
> @@ -2089,6 +2117,7 @@ proc makewindow {} {
>          mc "&File" cascade {
>              {mc "&Update" command updatecommits -accelerator F5}
>              {mc "&Reload" command reloadcommits -accelerator Shift-F5}
> +            {mc "&Fetch" command fetch -accelerator F7}
>              {mc "Reread re&ferences" command rereadrefs}
>              {mc "&List references" command showrefs -accelerator F2}
>              {xx "" separator}
> @@ -2609,6 +2638,7 @@ proc makewindow {} {
>      bindkey f nextfile
>      bind . <F5> updatecommits
>      bindmodfunctionkey Shift 5 reloadcommits
> +    bind . <F7> fetch
>      bind . <F2> showrefs
>      bindmodfunctionkey Shift 4 {newview 0}
>      bind . <F4> edit_or_newview
> @@ -3125,6 +3155,7 @@ proc keys {} {
>  [mc "<%s-KP->	Decrease font size" $M1T]
>  [mc "<%s-minus>	Decrease font size" $M1T]
>  [mc "<F5>		Update"]
> +[mc "<F7>		Fetch"]
>  " \
>              -justify left -bg $bgcolor -border 2 -relief groove
>      pack $w.m -side top -fill both -padx 2 -pady 2
>
> base-commit: 72c4083ddf91b489b7b7b812df67ee8842177d98
> --
> gitgitgadget
>
>
Paul Mackerras· Nov 5, 2021, 07:35 UTC · lore

Re: [PATCH] gitk: add option to perform 'git fetch' command

On Wed, Nov 03, 2021 at 01:01:14PM +0300, Vladimir Chigarev wrote:
> Hello Paul,
> 
> Just a gentle reminder.
> May I ask you to review my changes in gitk?
Thanks for the reminder.  See comments below.
Show 5 quoted lines
> > > +proc fetch {} {
> > > +    global bgcolor NS fetch_output
> > > +
> > > +    set fetch_output {}
> > > +    if {[catch {exec sh -c "git fetch -v 2>&1"} fetch_output]} {

This "exec" call is synchronous, meaning that the gitk process won't do anything else until the exec call returns. Since git fetch is a network operation, that could be quite a long time, during which the GUI will be unresponsive. It would be better to use open rather than exec, which will return a file descriptor. You would then use filerun to set up a procedure to be called when the file descriptor is readable. That way you can arrange for the GUI to continue to respond while the git fetch is happening.

Also, it may be more useful to do "git fetch --all" rather than just "git fetch", though I'm not going to insist on that.

> > > +    }
> > > +
> > > +    set w .about

Why are you reusing the "About gitk" window here? That doesn't seem right. Don't you mean "set w .fetch" or similar?

Show 9 quoted lines
> > > +    if {[winfo exists $w]} {
> > > +     raise $w
> > > +     return
> > > +    }
> > > +    ttk_toplevel $w
> > > +    wm title $w [mc "Fetch"]
> > > +    make_transient $w .
> > > +    message $w.m -text [mc " $fetch_output "] \
> > > +         -justify left -aspect 600 -border 2 -bg $bgcolor -relief groove

How long can the git fetch output be? If it can be say ten or more lines you might need to use a text widget and a scrollbar rather than a message widget.

Show 39 quoted lines
> > > +    pack $w.m -side top -fill x -padx 2 -pady 2
> > > +    ${NS}::button $w.ok -text [mc "Close"] -command "destroy $w"
> > -default active
> > > +    pack $w.ok -side bottom
> > > +    bind $w <Visibility> "focus $w.ok"
> > > +    bind $w <Key-Escape> "destroy $w"
> > > +    bind $w <Key-Return> "destroy $w"
> > > +    tk::PlaceWindow $w widget .
> > > +
> > > +    reloadcommits
> > > +}
> > > +
> > >  proc updatecommits {} {
> > >      global curview vcanopt vorigargs vfilelimit viewinstances
> > >      global viewactive viewcomplete tclencoding
> > > @@ -2089,6 +2117,7 @@ proc makewindow {} {
> > >          mc "&File" cascade {
> > >              {mc "&Update" command updatecommits -accelerator F5}
> > >              {mc "&Reload" command reloadcommits -accelerator Shift-F5}
> > > +            {mc "&Fetch" command fetch -accelerator F7}
> > >              {mc "Reread re&ferences" command rereadrefs}
> > >              {mc "&List references" command showrefs -accelerator F2}
> > >              {xx "" separator}
> > > @@ -2609,6 +2638,7 @@ proc makewindow {} {
> > >      bindkey f nextfile
> > >      bind . <F5> updatecommits
> > >      bindmodfunctionkey Shift 5 reloadcommits
> > > +    bind . <F7> fetch
> > >      bind . <F2> showrefs
> > >      bindmodfunctionkey Shift 4 {newview 0}
> > >      bind . <F4> edit_or_newview
> > > @@ -3125,6 +3155,7 @@ proc keys {} {
> > >  [mc "<%s-KP->        Decrease font size" $M1T]
> > >  [mc "<%s-minus>      Decrease font size" $M1T]
> > >  [mc "<F5>            Update"]
> > > +[mc "<F7>            Fetch"]
> > >  " \
> > >              -justify left -bg $bgcolor -border 2 -relief groove
> > >      pack $w.m -side top -fill both -padx 2 -pady 2
Paul.

← back to recent threads