edb6a57b7beb13c6e853fd40aa51a052937ca51a
   1#!/bin/sh
   2#
   3# Copyright (c) 2008 Charles Bailey
   4#
   5
   6test_description='git mergetool
   7
   8Testing basic merge tool invocation'
   9
  10. ./test-lib.sh
  11
  12test_expect_success 'setup' '
  13    echo master >file1 &&
  14    git add file1 &&
  15    git commit -m "added file1" &&
  16    git checkout -b branch1 master &&
  17    echo branch1 change >file1 &&
  18    echo branch1 newfile >file2 &&
  19    git add file1 file2 &&
  20    git commit -m "branch1 changes" &&
  21    git checkout -b branch2 master &&
  22    echo branch2 change >file1 &&
  23    echo branch2 newfile >file2 &&
  24    git add file1 file2 &&
  25    git commit -m "branch2 changes" &&
  26    git checkout master &&
  27    echo master updated >file1 &&
  28    echo master new >file2 &&
  29    git add file1 file2 &&
  30    git commit -m "master updates"
  31'
  32
  33test_expect_success 'custom mergetool' '
  34    git config merge.tool mytool &&
  35    git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
  36    git config mergetool.mytool.trustExitCode true &&
  37    git checkout branch1 &&
  38    test_must_fail git merge master >/dev/null 2>&1 &&
  39    ( yes "" | git mergetool file1>/dev/null 2>&1 ) &&
  40    ( yes "" | git mergetool file2>/dev/null 2>&1 ) &&
  41    test "$(cat file1)" = "master updated" &&
  42    test "$(cat file2)" = "master new" &&
  43    git commit -m "branch1 resolved with mergetool"
  44'
  45
  46test_expect_success 'mergetool crlf' '
  47    git config core.autocrlf true &&
  48    git reset --hard HEAD^
  49    test_must_fail git merge master >/dev/null 2>&1 &&
  50    ( yes "" | git mergetool file1>/dev/null 2>&1 ) &&
  51    ( yes "" | git mergetool file2>/dev/null 2>&1 ) &&
  52    test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
  53    test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
  54    git commit -m "branch1 resolved with mergetool - autocrlf"
  55'
  56
  57test_done