git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: Yann Dirson <ydirson@altern.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time.
Date: Sat, 17 Nov 2007 22:44:00 +1100	[thread overview]
Message-ID: <18238.54272.198637.788805@cargo.ozlabs.ibm.com> (raw)
In-Reply-To: <20071102222436.23191.91785.stgit@gandelf.nowhere.earth>

Yann Dirson writes:

> This allows to display a set of refs, when the refs in the set may
> themselves change between two refresh operations (eg. the set of
> patches in a patch stack), and is expected to be called from other
> porcelain suites.
> 
> The command is expected to generate a list of commits, which will be
> appended to the commits litterally passed on the command-line.  That
> command is handled similarly to the litteral refs, and has its own
> field in the saved view, and an edit field in the view editor.

The idea is fine, but I have some comments on the implementation:

> +--argscmd=<command>::
> +	Command to be run each time gitk has to determine the list of
> +	<revs> to show.  The command is expected to print on its
> +	standard output a list of additional revs to be shown.  Use

, one per line

> +	this instead of explicitely specifying <revs> if the set of

explicitly

> +	commits to show may vary between refreshs.

refreshes

> +    set args $viewargs($view)
> +    if {$viewargscmd($view) ne "None"} {
> +	if {[catch {
> +	    set fd [open [concat | $viewargscmd($view)] r]
> +	} err]} {
> +	    puts stderr "Error executing --argscmd command: $err"
> +	    exit 1
> +	}
> +	set args [concat $args [read $fd 500000]]

I don't think you necessarily want to limit the number of characters
read to 500000, do you?

What this will do is interpret the output of the program according to
Tcl list syntax.  I think it would be better to use [split $str "\n"]
to split the program's output at the newlines.  Also, you could
combine the open, read and close into a single exec call.  Thirdly,
use error_popup rather than just writing to stderr.

I wonder if you should be invoking a shell to interpret the command.
As you have it at the moment, the string that the user puts after
--argscmd= is treated as a Tcl list, whereas the string they put into
the entry field when creating a new view is split with shellsplit,
which implements shell-style quoting.  I think we should at least be
consistent here, and possibly just leave it as a string and pass it to
sh -c.

> +set revtreeargscmd None

Why the string "None" rather than the empty string?  Is this a
python-ism that has crept in?

>  foreach arg $argv {
> -    switch -- $arg {
> -	"" { }
> -	"-d" { set datemode 1 }
> -	"--merge" {
> +    switch -regexp -- $arg {

Hmmm, it'd be simpler to use switch -glob here, I think.

> +	"^$" { }
> +	"^-d$" { set datemode 1 }
> +	"^--merge$" {
>  	    set mergeonly 1
>  	    lappend revtreeargs $arg
>  	}
> -	"--" {
> +	"^--$" {
>  	    set cmdline_files [lrange $argv [expr {$i + 1}] end]
>  	    break
>  	}
> +	"^--argscmd=" {
> +	    regexp {^--argscmd=(.*)} $arg match revtreeargscmd

set revtreeargscmd [string range $arg 10 end]

Paul.

  reply	other threads:[~2007-11-17 11:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-02 22:24 [PATCH v3] Add to gitk an --argscmd flag to get the list of refs to draw at refresh time Yann Dirson
2007-11-17 11:44 ` Paul Mackerras [this message]
2007-11-17 19:56   ` Yann Dirson
  -- strict thread matches above, loose matches on Subject: below --
2007-07-29 12:17 Yann Dirson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18238.54272.198637.788805@cargo.ozlabs.ibm.com \
    --to=paulus@samba.org \
    --cc=git@vger.kernel.org \
    --cc=ydirson@altern.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).