From: Chris Packham <judge.packham@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Sixt <j.sixt@viscovery.net>,
Jakub Narebski <jnareb@gmail.com>, GIT <git@vger.kernel.org>
Subject: Re: re-running merge on a single file
Date: Fri, 12 Mar 2010 13:16:43 -0800 [thread overview]
Message-ID: <a038bef51003121316t19c7edbfyfa3673554d0d0203@mail.gmail.com> (raw)
In-Reply-To: <a038bef51003121216l5c0a4942qabc3d12741c9030e@mail.gmail.com>
On Fri, Mar 12, 2010 at 12:16 PM, Chris Packham <judge.packham@gmail.com> wrote:
> On Thu, Mar 11, 2010 at 10:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Johannes Sixt <j.sixt@viscovery.net> 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@gmail.com>
> 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
>
next prev parent reply other threads:[~2010-03-12 21:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-11 18:54 re-running merge on a single file Chris Packham
2010-03-11 19:09 ` Chris Packham
2010-03-11 20:29 ` Markus Heidelberg
2010-03-11 22:08 ` Chris Packham
2010-03-11 23:20 ` Jakub Narebski
[not found] ` <a038bef51003111631n38f7e50cp79d8335109f3ed0@mail.gmail.com>
2010-03-12 0:33 ` Chris Packham
2010-03-12 6:45 ` Johannes Sixt
2010-03-12 6:56 ` Junio C Hamano
2010-03-12 20:16 ` Chris Packham
2010-03-12 21:16 ` Chris Packham [this message]
2010-03-12 23:07 ` Junio C Hamano
2010-03-12 23:43 ` Chris Packham
2010-03-14 12:24 ` Kris Shannon
2010-03-12 9:00 ` Jakub Narebski
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=a038bef51003121316t19c7edbfyfa3673554d0d0203@mail.gmail.com \
--to=judge.packham@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.net \
--cc=jnareb@gmail.com \
/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).