git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Gavrilov <angavrilov@gmail.com>
To: git@vger.kernel.org
Cc: Paul Mackerras <paulus@samba.org>
Subject: [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts.
Date: Sun,  2 Nov 2008 21:59:47 +0300	[thread overview]
Message-ID: <1225652389-22082-5-git-send-email-angavrilov@gmail.com> (raw)
In-Reply-To: <1225652389-22082-4-git-send-email-angavrilov@gmail.com>

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

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
 gitk |   40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/gitk b/gitk
index f747c70..71f1b27 100755
--- a/gitk
+++ b/gitk
@@ -8110,6 +8110,32 @@ proc mkbrgo {top} {
     }
 }
 
+proc exec_citool {tool_args {baseid {}}} {
+    global commitinfo env
+
+    set save_env [array get env GIT_AUTHOR_*]
+
+    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 $tool_args &
+
+    array unset env GIT_AUTHOR_*
+    array set env $save_env
+}
+
 proc cherrypick {} {
     global rowmenuid curview
     global mainhead mainheadid
@@ -8128,7 +8154,19 @@ 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.
+
+Please commit, reset or stash your changes." $fname]
+	} elseif {[regexp -line {^CONFLICT \(.*\):} $err msg]} {
+	    # Force citool to read MERGE_MSG
+	    file delete [file join [gitdir] "GITGUI_MSG"]
+	    exec_citool {} $rowmenuid
+	} else {
+	    error_popup $err
+	}
 	return
     }
     set newhead [exec git rev-parse HEAD]
-- 
1.6.0.3.15.gb8d36

  reply	other threads:[~2008-11-02 19:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-02 18:59 [PATCH (GITK) v3 0/6] Enhance popup dialogs in gitk Alexander Gavrilov
2008-11-02 18:59 ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs Alexander Gavrilov
2008-11-02 18:59   ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Alexander Gavrilov
2008-11-02 18:59     ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Alexander Gavrilov
2008-11-02 18:59       ` Alexander Gavrilov [this message]
2008-11-02 18:59         ` [PATCH (GITK) v3 5/6] gitk: Implement a user-friendly Edit View dialog Alexander Gavrilov
2008-11-02 18:59           ` [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows Alexander Gavrilov
2008-11-07 11:57             ` Paul Mackerras
2008-11-07 14:39               ` Alex Riesen
2008-11-07 16:37                 ` Johannes Sixt
2008-11-09 10:26                   ` Alex Riesen
2008-11-09 11:12                 ` Paul Mackerras
2008-11-09 14:53               ` Alexander Gavrilov
2008-11-10 11:47                 ` Paul Mackerras
2008-11-10 12:15                   ` Alexander Gavrilov
2008-11-11 11:00               ` Alexander Gavrilov
2008-11-07 11:51         ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Paul Mackerras
2008-11-07 11:50       ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Paul Mackerras
2008-11-09 11:21         ` Alexander Gavrilov
2008-11-07 11:41     ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Paul Mackerras
2008-11-07 11:41   ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs 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=1225652389-22082-5-git-send-email-angavrilov@gmail.com \
    --to=angavrilov@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=paulus@samba.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).