git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: Alexander Gavrilov <angavrilov@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 5/7] gitk: Make cherry-pick call git-citool on conflicts.
Date: Thu, 9 Oct 2008 18:42:33 +1100	[thread overview]
Message-ID: <18669.46569.45285.170033@cargo.ozlabs.ibm.com> (raw)
In-Reply-To: <1223449540-20457-6-git-send-email-angavrilov@gmail.com>

Alexander Gavrilov writes:

> Now that git-gui has facilities to help users resolve
> conflicts, it makes sense to launch it from other gui
> tools when they happen.

Nice idea...

> +proc exec_citool {args {baseid {}}} {

I'm a little nervous about you having a parameter called "args", since
that specific name has a special meaning in Tcl; it's how Tcl handles
variable-length argument lists.

> +    global commitinfo env
> +
> +    if {[info exists env(GIT_AUTHOR_NAME)]} {
> +	set old_name $env(GIT_AUTHOR_NAME)
> +    }
> +    if {[info exists env(GIT_AUTHOR_EMAIL)]} {
> +	set old_email $env(GIT_AUTHOR_EMAIL)
> +    }
> +    if {[info exists env(GIT_AUTHOR_DATE)]} {
> +	set old_date $env(GIT_AUTHOR_DATE)
> +    }
> +
> +    if {$baseid ne {}} {
> +	if {![info exists commitinfo($baseid)]} {
> +	    getcommit $baseid
> +	}
> +	set author [lindex $commitinfo($baseid) 1]
> +	set date [lindex $commitinfo($baseid) 2]
> +	if {[regexp {^\s*(\S.*\S|\S)\s*<(.*)>\s*$} \
> +	            $author author name email]
> +	    && $date ne {}} {
> +	    set env(GIT_AUTHOR_NAME) $name
> +	    set env(GIT_AUTHOR_EMAIL) $email
> +	    set env(GIT_AUTHOR_DATE) $date
> +	}
> +    }
> +
> +    eval exec git citool $args &

If we can assume the existence of a shell (which we do elsewhere), we
can perhaps do this more simply by putting the environment variable
settings in the command before the command name.  It's a pity that git
citool won't take the author name/email/date as command-line arguments
or from a file, since it ends up being pretty verbose doing it the way
you have.

> @@ -7861,7 +7908,17 @@ proc cherrypick {} {
>      # no error occurs, and exec takes that as an indication of error...
>      if {[catch {exec sh -c "git cherry-pick -r $rowmenuid 2>&1"} err]} {
>  	notbusy cherrypick
> -	error_popup $err
> +	if {[regexp -line \
> +	    {Entry '(.*)' would be overwritten by merge} $err msg fname]} {
> +	    error_popup [mc "Cherry-pick failed: file '%s' had local modifications.
> +Your working directory is in an inconsistent state." $fname]

That message seems a bit too scary.  It's not inconsistent, it's just
got local modifications.  If I remember correctly, in this situation
git cherry-pick will back out all the changes it did and leave the
working directory as it was before.

> +	} elseif {[regexp -line {^CONFLICT \(.*\):} $err msg]} {
> +	    # Force citool to read MERGE_MSG
> +	    file delete [file join [gitdir] "GITGUI_MSG"]
> +	    exec_citool [list] $rowmenuid

[list] as an idiom for the empty list is a little unusual (here and
elsewhere in your patches); {} would be more usual.

Paul.

  parent reply	other threads:[~2008-10-09  7:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-08  7:05 [PATCH 0/7] gitk: UI enhancements Alexander Gavrilov
2008-10-08  7:05 ` [PATCH 1/7] gitk: Enhance UI popup and accelerator handling Alexander Gavrilov
2008-10-08  7:05   ` [PATCH 2/7] gitk: Allow forcing branch creation if it already exists Alexander Gavrilov
2008-10-08  7:05     ` [PATCH 3/7] gitk: Allow starting gui blame for a specific line Alexander Gavrilov
2008-10-08  7:05       ` [PATCH 4/7] gitk: Fix file list context menu for merge commits Alexander Gavrilov
2008-10-08  7:05         ` [PATCH 5/7] gitk: Make cherry-pick call git-citool on conflicts Alexander Gavrilov
2008-10-08  7:05           ` [PATCH 6/7] gitk: Implement a user-friendly Edit View dialog Alexander Gavrilov
2008-10-08  7:05             ` [PATCH 7/7] gitk: Explicitly position popup windows Alexander Gavrilov
2008-10-21 11:41               ` Paul Mackerras
2008-10-21 12:52                 ` Alexander Gavrilov
2008-10-09  7:42           ` Paul Mackerras [this message]
2008-10-09  8:24             ` [PATCH 5/7] gitk: Make cherry-pick call git-citool on conflicts Alexander Gavrilov
2008-10-09 10:57               ` Paul Mackerras
2008-10-21 11:39         ` [PATCH 4/7] gitk: Fix file list context menu for merge commits Paul Mackerras
2008-10-23 11:58       ` [PATCH 3/7] gitk: Allow starting gui blame for a specific line Paul Mackerras
2008-10-24  8:13         ` Alexander Gavrilov
2008-10-25 11:57           ` Paul Mackerras
2008-10-25 16:45             ` Alexander Gavrilov
2008-10-26  3:58               ` Paul Mackerras
2008-10-21 11:38     ` [PATCH 2/7] gitk: Allow forcing branch creation if it already exists Paul Mackerras
2008-10-09  0:27   ` [PATCH 1/7] gitk: Enhance UI popup and accelerator handling Paul Mackerras
2008-10-09  8:12     ` Alexander Gavrilov
2008-10-09 11:02       ` Paul Mackerras
2008-10-16 21:55   ` Paul Mackerras
2008-10-16 22:08     ` Alexander Gavrilov
2008-10-21 11:35   ` Paul Mackerras

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=18669.46569.45285.170033@cargo.ozlabs.ibm.com \
    --to=paulus@samba.org \
    --cc=angavrilov@gmail.com \
    --cc=git@vger.kernel.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).