git/t/t6200-fmt-merge-msg.sh
Johannes Sixt 4114156ae9 Tests on Windows: $(pwd) must return Windows-style paths
Many tests pass $(pwd) in some form to git and later test that the output
of git contains the correct value of $(pwd). For example, the test of
'git remote show' sets up a remote that contains $(pwd) and then the
expected result must contain $(pwd).

Again, MSYS-bash's path mangling kicks in: Plain $(pwd) uses the MSYS style
absolute path /c/path/to/git. The test case would write this name into
the 'expect' file. But when git is invoked, MSYS-bash converts this name to
the Windows style path c:/path/to/git, and git would produce this form in
the result; the test would fail.

We fix this by passing -W to bash's pwd that produces the Windows-style
path.

There are a two cases that need an accompanying change:

- In t1504 the value of $(pwd) becomes part of a path list. In this case,
  the lone 'c' in something like /foo:c:/path/to/git:/bar inhibits
  MSYS-bashes path mangling; IOW in this case we want the /c/path/to/git
  form to allow path mangling. We use $PWD instead of $(pwd), which always
  has the latter form.

- In t6200, $(pwd) - the Windows style path - must be used to construct the
  expected result because that is the path form that git sees. (The change
  in the test itself is just for consistency: 'git fetch' always sees the
  Windows-style path, with or without the change.)

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2009-03-19 22:04:25 +01:00

212 lines
3.6 KiB
Bash
Executable File

#!/bin/sh
#
# Copyright (c) 2006, Junio C Hamano
#
test_description='fmt-merge-msg test'
. ./test-lib.sh
datestamp=1151939923
setdate () {
GIT_COMMITTER_DATE="$datestamp +0200"
GIT_AUTHOR_DATE="$datestamp +0200"
datestamp=`expr "$datestamp" + 1`
export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
}
test_expect_success setup '
echo one >one &&
git add one &&
setdate &&
git commit -m "Initial" &&
echo uno >one &&
echo dos >two &&
git add two &&
setdate &&
git commit -a -m "Second" &&
git checkout -b left &&
echo $datestamp >one &&
setdate &&
git commit -a -m "Common #1" &&
echo $datestamp >one &&
setdate &&
git commit -a -m "Common #2" &&
git branch right &&
echo $datestamp >two &&
setdate &&
git commit -a -m "Left #3" &&
echo $datestamp >two &&
setdate &&
git commit -a -m "Left #4" &&
echo $datestamp >two &&
setdate &&
git commit -a -m "Left #5" &&
git checkout right &&
echo $datestamp >three &&
git add three &&
setdate &&
git commit -a -m "Right #3" &&
echo $datestamp >three &&
setdate &&
git commit -a -m "Right #4" &&
echo $datestamp >three &&
setdate &&
git commit -a -m "Right #5" &&
git show-branch
'
cat >expected <<\EOF
Merge branch 'left'
EOF
test_expect_success 'merge-msg test #1' '
git checkout master &&
git fetch . left &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
test_cmp expected actual
'
cat >expected <<EOF
Merge branch 'left' of $(pwd)
EOF
test_expect_success 'merge-msg test #2' '
git checkout master &&
git fetch "$(pwd)" left &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
test_cmp expected actual
'
cat >expected <<\EOF
Merge branch 'left'
* left:
Left #5
Left #4
Left #3
Common #2
Common #1
EOF
test_expect_success 'merge-msg test #3-1' '
git config --unset-all merge.log
git config --unset-all merge.summary
git config merge.log true &&
git checkout master &&
setdate &&
git fetch . left &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
test_cmp expected actual
'
test_expect_success 'merge-msg test #3-2' '
git config --unset-all merge.log
git config --unset-all merge.summary
git config merge.summary true &&
git checkout master &&
setdate &&
git fetch . left &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
test_cmp expected actual
'
cat >expected <<\EOF
Merge branches 'left' and 'right'
* left:
Left #5
Left #4
Left #3
Common #2
Common #1
* right:
Right #5
Right #4
Right #3
Common #2
Common #1
EOF
test_expect_success 'merge-msg test #4-1' '
git config --unset-all merge.log
git config --unset-all merge.summary
git config merge.log true &&
git checkout master &&
setdate &&
git fetch . left right &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
test_cmp expected actual
'
test_expect_success 'merge-msg test #4-2' '
git config --unset-all merge.log
git config --unset-all merge.summary
git config merge.summary true &&
git checkout master &&
setdate &&
git fetch . left right &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
test_cmp expected actual
'
test_expect_success 'merge-msg test #5-1' '
git config --unset-all merge.log
git config --unset-all merge.summary
git config merge.log yes &&
git checkout master &&
setdate &&
git fetch . left right &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
test_cmp expected actual
'
test_expect_success 'merge-msg test #5-2' '
git config --unset-all merge.log
git config --unset-all merge.summary
git config merge.summary yes &&
git checkout master &&
setdate &&
git fetch . left right &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
test_cmp expected actual
'
test_done