git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 5/7] gitk: Make cherry-pick call git-citool on conflicts.

From
Paul Mackerras <paulus@samba.org>
Date
Oct 9, 2008, 07:42 UTC
Message-ID
<18669.46569.45285.170033@cargo.ozlabs.ibm.com>
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.

Show 28 quoted lines
> +    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.

Show 9 quoted lines
> @@ -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.
Previous: Alexander GavrilovNext: Alexander Gavrilov
Message 11 of 26 in “gitk: UI enhancements”
  1. 0/7 gitk: UI enhancementsAlexander Gavrilov, Oct 8, 2008
  2. 1/7 gitk: Enhance UI popup and accelerator handling.Alexander Gavrilov, Oct 8, 2008
  3. 2/7 gitk: Allow forcing branch creation if it already exists.Alexander Gavrilov, Oct 8, 2008
  4. 3/7 gitk: Allow starting gui blame for a specific line.Alexander Gavrilov, Oct 8, 2008
  5. 4/7 gitk: Fix file list context menu for merge commits.Alexander Gavrilov, Oct 8, 2008
  6. 5/7 gitk: Make cherry-pick call git-citool on conflicts.Alexander Gavrilov, Oct 8, 2008
  7. 6/7 gitk: Implement a user-friendly Edit View dialog.Alexander Gavrilov, Oct 8, 2008
  8. 7/7 gitk: Explicitly position popup windows.Alexander Gavrilov, Oct 8, 2008
  9. Paul MackerrasOct 21, 2008
  10. Alexander GavrilovOct 21, 2008
  11. Paul MackerrasOct 9, 2008
  12. Alexander GavrilovOct 9, 2008
  13. Paul MackerrasOct 9, 2008
  14. Paul MackerrasOct 21, 2008
  15. Paul MackerrasOct 23, 2008
  16. Alexander GavrilovOct 24, 2008
  17. Paul MackerrasOct 25, 2008
  18. Alexander GavrilovOct 25, 2008
  19. Paul MackerrasOct 26, 2008
  20. Paul MackerrasOct 21, 2008
  21. Paul MackerrasOct 9, 2008
  22. Alexander GavrilovOct 9, 2008
  23. Paul MackerrasOct 9, 2008
  24. Paul MackerrasOct 16, 2008
  25. Alexander GavrilovOct 16, 2008
  26. Paul MackerrasOct 21, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.