Re: [PATCH 10/10] mergetool: use run_mergetool from git-mergetool-lib

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

 



David Aguilar, 01.04.2009:
> This refactors git-mergetool to use run_mergetool.
> 
> Signed-off-by: David Aguilar <davvid@xxxxxxxxx>
> ---
>  git-mergetool.sh |   96 +++--------------------------------------------------
>  1 files changed, 6 insertions(+), 90 deletions(-)
> 
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index 957993c..2c6b325 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -190,96 +190,12 @@ merge_file () {
>  	read ans
>      fi
>  
> -    case "$merge_tool" in
> -	kdiff3)
> -	    if base_present ; then
> -		("$merge_tool_path" --auto --L1 "$MERGED (Base)" --L2 "$MERGED (Local)" --L3 "$MERGED (Remote)" \
> -		    -o "$MERGED" "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
> -	    else
> -		("$merge_tool_path" --auto --L1 "$MERGED (Local)" --L2 "$MERGED (Remote)" \
> -		    -o "$MERGED" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
> -	    fi
> -	    status=$?
> -	    ;;
> -	tkdiff)
> -	    if base_present ; then
> -		"$merge_tool_path" -a "$BASE" -o "$MERGED" "$LOCAL" "$REMOTE"
> -	    else
> -		"$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
> -	    fi
> -	    status=$?
> -	    ;;
> -	meld)
> -	    touch "$BACKUP"
> -	    "$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
> -	    check_unchanged
> -	    ;;
> -	vimdiff)
> -	    touch "$BACKUP"
> -	    "$merge_tool_path" -c "wincmd l" "$LOCAL" "$MERGED" "$REMOTE"
> -	    check_unchanged
> -	    ;;
> -	gvimdiff)
> -	    touch "$BACKUP"
> -	    "$merge_tool_path" -c "wincmd l" -f "$LOCAL" "$MERGED" "$REMOTE"
> -	    check_unchanged
> -	    ;;
> -	xxdiff)
> -	    touch "$BACKUP"
> -	    if base_present ; then
> -		"$merge_tool_path" -X --show-merged-pane \
> -		    -R 'Accel.SaveAsMerged: "Ctrl-S"' \
> -		    -R 'Accel.Search: "Ctrl+F"' \
> -		    -R 'Accel.SearchForward: "Ctrl-G"' \
> -		    --merged-file "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
> -	    else
> -		"$merge_tool_path" -X --show-merged-pane \
> -		    -R 'Accel.SaveAsMerged: "Ctrl-S"' \
> -		    -R 'Accel.Search: "Ctrl+F"' \
> -		    -R 'Accel.SearchForward: "Ctrl-G"' \
> -		    --merged-file "$MERGED" "$LOCAL" "$REMOTE"
> -	    fi
> -	    check_unchanged
> -	    ;;
> -	opendiff)
> -	    touch "$BACKUP"
> -	    if base_present; then
> -		"$merge_tool_path" "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED" | cat
> -	    else
> -		"$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$MERGED" | cat
> -	    fi
> -	    check_unchanged
> -	    ;;
> -	ecmerge)
> -	    touch "$BACKUP"
> -	    if base_present; then
> -		"$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --default --mode=merge3 --to="$MERGED"
> -	    else
> -		"$merge_tool_path" "$LOCAL" "$REMOTE" --default --mode=merge2 --to="$MERGED"
> -	    fi
> -	    check_unchanged
> -	    ;;
> -	emerge)
> -	    if base_present ; then
> -		"$merge_tool_path" -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$MERGED")"
> -	    else
> -		"$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$MERGED")"
> -	    fi
> -	    status=$?
> -	    ;;
> -	*)
> -	    if test -n "$merge_tool_cmd"; then
> -		if test "$merge_tool_trust_exit_code" = "false"; then
> -		    touch "$BACKUP"
> -		    ( eval $merge_tool_cmd )
> -		    check_unchanged
> -		else
> -		    ( eval $merge_tool_cmd )
> -		    status=$?
> -		fi
> -	    fi
> -	    ;;
> -    esac
> +    present=false
> +    base_present &&
> +    present=true
> +
> +    run_mergetool "$merge_tool" "$present"
> +    status=$?

This last line has to be deleted, because the variable 'status' set in
run_mergetool would be overwritten then. In this case the merge will
succeed even if it didn't and the file will be staged.

>      if test "$status" -ne 0; then
>  	echo "merge of $MERGED failed" 1>&2
>  	mv -- "$BACKUP" "$MERGED"

--
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]

  Powered by Linux