mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
![Jeff King](/assets/img/avatar_default.png)
We try to avoid using the "-q" or "-e" options, as they are
largely useless, as explained in aadbe44f
.
There is one exception for "-e" here, which is in t7701 used
to produce an "or" of patterns. This can be rewritten as an
egrep pattern.
This patch also removes use of "grep -F" in favor of the
more widely available "fgrep".
[sp: Tested on AIX 5.3 by Mike Ralphson,
Tested on MinGW by Johannes Sixt]
Signed-off-by: Jeff King <peff@peff.net>
Tested-by: Mike Ralphson <mike@abacus.co.uk>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
104 lines
1.9 KiB
Bash
Executable file
104 lines
1.9 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='.git file
|
|
|
|
Verify that plumbing commands work when .git is a file
|
|
'
|
|
. ./test-lib.sh
|
|
|
|
objpath() {
|
|
echo "$1" | sed -e 's|\(..\)|\1/|'
|
|
}
|
|
|
|
objck() {
|
|
p=$(objpath "$1")
|
|
if test ! -f "$REAL/objects/$p"
|
|
then
|
|
echo "Object not found: $REAL/objects/$p"
|
|
false
|
|
fi
|
|
}
|
|
|
|
|
|
test_expect_success 'initial setup' '
|
|
REAL="$(pwd)/.real" &&
|
|
mv .git "$REAL"
|
|
'
|
|
|
|
test_expect_success 'bad setup: invalid .git file format' '
|
|
echo "gitdir $REAL" >.git &&
|
|
if git rev-parse 2>.err
|
|
then
|
|
echo "git rev-parse accepted an invalid .git file"
|
|
false
|
|
fi &&
|
|
if ! grep "Invalid gitfile format" .err
|
|
then
|
|
echo "git rev-parse returned wrong error"
|
|
false
|
|
fi
|
|
'
|
|
|
|
test_expect_success 'bad setup: invalid .git file path' '
|
|
echo "gitdir: $REAL.not" >.git &&
|
|
if git rev-parse 2>.err
|
|
then
|
|
echo "git rev-parse accepted an invalid .git file path"
|
|
false
|
|
fi &&
|
|
if ! grep "Not a git repository" .err
|
|
then
|
|
echo "git rev-parse returned wrong error"
|
|
false
|
|
fi
|
|
'
|
|
|
|
test_expect_success 'final setup + check rev-parse --git-dir' '
|
|
echo "gitdir: $REAL" >.git &&
|
|
test "$REAL" = "$(git rev-parse --git-dir)"
|
|
'
|
|
|
|
test_expect_success 'check hash-object' '
|
|
echo "foo" >bar &&
|
|
SHA=$(cat bar | git hash-object -w --stdin) &&
|
|
objck $SHA
|
|
'
|
|
|
|
test_expect_success 'check cat-file' '
|
|
git cat-file blob $SHA >actual &&
|
|
test_cmp bar actual
|
|
'
|
|
|
|
test_expect_success 'check update-index' '
|
|
if test -f "$REAL/index"
|
|
then
|
|
echo "Hmm, $REAL/index exists?"
|
|
false
|
|
fi &&
|
|
rm -f "$REAL/objects/$(objpath $SHA)" &&
|
|
git update-index --add bar &&
|
|
if ! test -f "$REAL/index"
|
|
then
|
|
echo "$REAL/index not found"
|
|
false
|
|
fi &&
|
|
objck $SHA
|
|
'
|
|
|
|
test_expect_success 'check write-tree' '
|
|
SHA=$(git write-tree) &&
|
|
objck $SHA
|
|
'
|
|
|
|
test_expect_success 'check commit-tree' '
|
|
SHA=$(echo "commit bar" | git commit-tree $SHA) &&
|
|
objck $SHA
|
|
'
|
|
|
|
test_expect_success 'check rev-list' '
|
|
echo $SHA >"$REAL/HEAD" &&
|
|
test "$SHA" = "$(git rev-list HEAD)"
|
|
'
|
|
|
|
test_done
|