Re: re-running merge on a single file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 12, 2010 at 12:16 PM, Chris Packham <judge.packham@xxxxxxxxx> wrote:
> On Thu, Mar 11, 2010 at 10:56 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>> Johannes Sixt <j.sixt@xxxxxxxxxxxxx> writes:
>>
>>> Chris Packham schrieb:
>>>> $ git checkout --merge -- cpu/mpc83xx/start.S
>>>> $ git show :1:$(git rev-parse --show-prefix)cpu/mpc83xx/start.S
>>>> fatal: Path 'cpu/mpc83xx/start.S' is in the index, but not at stage 1.
>>>> Did you mean ':0:cpu/mpc83xx/start.S'?
>>>
>>> Both of these work only as long as the index still records the conflicted
>>> state. If you (or one of your tools) has git-added the file, or you have
>>> git-checked-out some version of the file, the conflict stages are lost,
>>> and you must reset --hard and redo the entire merge.
>>
>> If the merge textually autoresolves cleanly, you might not even have any
>> conflicted state to begin with.  In such a case you would need to grab
>>
>>        MERGE_HEAD:path-to-that-thing
>>        HEAD:path-to-that-thing
>>
>> yourself.
>>
>
> So if I understand correctly once I've committed the merge the various
> stages and MERGE_HEADs go away. I don't really want to re-do the whole
> merge which is probably the correct thing to do. I'm lazy and my
> projects rules allow broken commits so instead I can poke about with
> git show and various revisions.
>
> Here's a simple script that does just that. I've borrowed some command
> line options from git mergetool (Warning: gmail web interface). If
> anyone is interested in seeing a proper version of this I can clean it
> up submit it properly.
>
> ----8<----
>
> From c6ad177712422cbba641975d9e6a5fe85fc8f1fa Mon Sep 17 00:00:00 2001
> From: Chris Packham <judge.packham@xxxxxxxxx>
> Date: Fri, 12 Mar 2010 12:03:02 -0800
> Subject: [PATCH] Add git manual-merge command
>
> Can be used to manually merge files from the specified revisions.
> ---
>  git-manual-merge |   91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 91 insertions(+), 0 deletions(-)
>  create mode 100755 git-manual-merge
>
> diff --git a/git-manual-merge b/git-manual-merge
> new file mode 100755
> index 0000000..f37ba88
> --- /dev/null
> +++ b/git-manual-merge
> @@ -0,0 +1,91 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2010 Chris Packham
> +#
> +# Based on git-mergetool by Theodore Y. Ts'o
> +#
> +# This file is licensed under the GPL v2
> +#
> +
> +USAGE='<branch1> <branch2> <file> ...'
> +. git-sh-setup
> +. git-mergetool--lib
> +require_work_tree
> +
> +merge_one_file()
> +{
> +    local has_base=false
> +    git show $1:$4 > $4.$1 && has_base=true
> +    git show $2:$4 > $4.$2 || die
> +    git show $3:$4 > $4.$3 || die
> +
> +    if "$prompt" = true; then
> +       printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
> +       read ans
> +    fi
> +
> +    if "$has_base" = true; then
> +        $merge_tool $4.$1 $4.$2 $4.$1 -o $4

Oops, that should be

+        $merge_tool $4.$1 $4.$2 $4.$3 -o $4

> +    else
> +        $merge_tool $4.$2 $4.$1 -o $4
> +    fi
> +}
> +
> +prompt=$(git config --bool mergetool.prompt || echo true)
> +
> +while test $# != 0
> +do
> +    case "$1" in
> +        -t|--tool*)
> +            case "$#,$1" in
> +                *,*=*)
> +                    merge_tool=$(expr "z$1" : 'z-[^=]*=\(.*\)')
> +                    ;;
> +                1,*)
> +                    usage ;;
> +                *)
> +                    merge_tool="$2"
> +                    shift ;;
> +            esac
> +            ;;
> +        -y|--no-prompt)
> +            prompt=false
> +            ;;
> +        --prompt)
> +            prompt=true
> +            ;;
> +        --)
> +            shift
> +            break
> +            ;;
> +        -*)
> +            usage
> +            ;;
> +        *)
> +            break
> +            ;;
> +    esac
> +    shift
> +done
> +
> +echo "$merge_tool"
> +
> +if test $# -lt 3; then
> +    usage
> +fi
> +
> +branch1=$(git rev-parse --short  $1)
> +branch2=$(git rev-parse --short  $2)
> +_base=$(git merge-base $branch1 $branch2)
> +base=$(git rev-parse --short  $_base)
> +
> +if test -z "$merge_tool"; then
> +    merge_tool=$(get_merge_tool "$merge_tool") || exit
> +fi
> +
> +shift 2
> +
> +for x in $*; do
> +    merge_one_file $base $branch1 $branch2 $x
> +done
> +
> --
> 1.7.0.1
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]