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

Re: Unresolved issues #3

From
CMCatalin Marinas <catalin.marinas@arm.com>
Date
Aug 18, 2006, 08:54 UTC
Message-ID
<tnx1wre4e6s.fsf@arm.com>
In-Reply-To
<7vpseyelcw.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 9 quoted lines
> * Martin Langhoff proposed git-xxdiff as a helper after a failed
>   merge.
>
>   Message-ID: <11546492331601-git-send-email-martin@catalyst.net.nz>
>
>   I like the general idea of this a lot, but am having a bit of
>   trouble envisioning how we can integrate this while making
>   sure mergers other than xxdiff can be added easily without
>   disrupting the end user experience.

In StGIT I can configure the merge command and I currently use the attached script (I need to add it to the StGIT repository). It tries diff3 first and, if that fails, invokes emacs' merge (can use xxdiff as well). It also checks whether the file was modified in case I want to exit and solve the conflict later (maybe after getting conflict information for the other files).

-- 
Catalin



#!/usr/bin/env python
"""Run diff3 and an interactive tool if this fails.
"""

__copyright__ = """
Copyright (C) 2006, Catalin Marinas <catalin.marinas@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""

import sys, os

if len(sys.argv) != 5:
    print >> sys.stderr, 'Usage: %s ancestor branch1 branch2 output' \
          % sys.argv[0]
    sys.exit(1)

ancestor = sys.argv[1]
branch1  = sys.argv[2]
branch2  = sys.argv[3]
output   = sys.argv[4]

# default merger
if os.system('diff3 -L current -L ancestor -L patched -m -E '
             '"%s" "%s" "%s" > "%s"'
             % (branch1, ancestor, branch2, output)):
    # interactive merge
    if os.path.exists(output):
        mtime = os.path.getmtime(output)
    else:
        mtime = 0

    ret = os.system('emacs --eval \'(ediff-merge-files-with-ancestor '
                    '"%s" "%s" "%s" nil "%s")\''
                    % (branch1, branch2, ancestor, output))

    #ret = os.system(
    #    'xxdiff --title1 current --title2 ancestor --title3 patched '
    #    '--show-merged-pane -m -E -O -X -M "%s" "%s" "%s" "%s"'
    #    % (output, branch1, ancestor, branch2))

    # error in the interactive merger, just exit
    if ret:
        sys.exit(2)

    # check for file modification
    if not os.path.exists(output) or mtime == os.path.getmtime(output):
        sys.exit(3)

# everything's fine
sys.exit(0)
Previous: Jeff KingNext: Junio C Hamano
Message 11 of 30 in “Unresolved issues #3”
  1. Junio C HamanoAug 18, 2006
  2. A Large Angry SCMAug 18, 2006
  3. Nicolas PitreAug 18, 2006
  4. A Large Angry SCMAug 18, 2006
  5. Nicolas PitreAug 18, 2006
  6. A Large Angry SCMAug 19, 2006
  7. Nicolas PitreAug 20, 2006
  8. Junio C HamanoAug 20, 2006
  9. A Large Angry SCMAug 21, 2006
  10. Jeff KingAug 18, 2006
  11. Catalin MarinasAug 18, 2006
  12. Junio C HamanoAug 18, 2006
  13. Catalin MarinasAug 18, 2006
  14. Jakub NarebskiAug 18, 2006
  15. Aneesh Kumar K.VAug 18, 2006
  16. Jakub NarebskiAug 18, 2006
  17. Aneesh Kumar K.VAug 18, 2006
  18. Jakub NarebskiAug 18, 2006
  19. Jon LoeligerAug 18, 2006
  20. Junio C HamanoAug 20, 2006
  21. daemon: prepare for multiple services.Junio C Hamano, Aug 21, 2006
  22. daemon: add upload-tar service.Junio C Hamano, Aug 21, 2006
  23. Martin LanghoffAug 23, 2006
  24. Jakub NarebskiAug 25, 2006
  25. Unresolved issues #4Junio C Hamano, Oct 6, 2006
  26. Jakub NarebskiOct 6, 2006
  27. Shawn PearceOct 6, 2006
  28. Jon LoeligerOct 6, 2006
  29. Shawn PearceOct 6, 2006
  30. A Large Angry SCMOct 6, 2006

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.