Merge pull request #1566 from sschuberth/windows-sha256sum
Use "sha256sum" on Windows
This commit is contained in:
commit
bcc584c530
@ -22,7 +22,7 @@ begin_test "fsck default"
|
|||||||
aOid=$(git log --patch a.dat | grep "^+oid" | cut -d ":" -f 2)
|
aOid=$(git log --patch a.dat | grep "^+oid" | cut -d ":" -f 2)
|
||||||
aOid12=$(echo $aOid | cut -b 1-2)
|
aOid12=$(echo $aOid | cut -b 1-2)
|
||||||
aOid34=$(echo $aOid | cut -b 3-4)
|
aOid34=$(echo $aOid | cut -b 3-4)
|
||||||
if [ "$aOid" != "$(shasum -a 256 .git/lfs/objects/$aOid12/$aOid34/$aOid | cut -d " " -f 1)" ]; then
|
if [ "$aOid" != "$(calc_oid_file .git/lfs/objects/$aOid12/$aOid34/$aOid)" ]; then
|
||||||
echo "oid for a.dat does not match"
|
echo "oid for a.dat does not match"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -30,7 +30,7 @@ begin_test "fsck default"
|
|||||||
bOid=$(git log --patch b.dat | grep "^+oid" | cut -d ":" -f 2)
|
bOid=$(git log --patch b.dat | grep "^+oid" | cut -d ":" -f 2)
|
||||||
bOid12=$(echo $bOid | cut -b 1-2)
|
bOid12=$(echo $bOid | cut -b 1-2)
|
||||||
bOid34=$(echo $bOid | cut -b 3-4)
|
bOid34=$(echo $bOid | cut -b 3-4)
|
||||||
if [ "$bOid" != "$(shasum -a 256 .git/lfs/objects/$bOid12/$bOid34/$bOid | cut -d " " -f 1)" ]; then
|
if [ "$bOid" != "$(calc_oid_file .git/lfs/objects/$bOid12/$bOid34/$bOid)" ]; then
|
||||||
echo "oid for b.dat does not match"
|
echo "oid for b.dat does not match"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -48,7 +48,7 @@ begin_test "fsck default"
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$bOid" != "$(shasum -a 256 .git/lfs/objects/$bOid12/$bOid34/$bOid | cut -d " " -f 1)" ]; then
|
if [ "$bOid" != "$(calc_oid_file .git/lfs/objects/$bOid12/$bOid34/$bOid)" ]; then
|
||||||
echo "oid for b.dat does not match"
|
echo "oid for b.dat does not match"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -75,7 +75,7 @@ begin_test "fsck dry run"
|
|||||||
aOid=$(git log --patch a.dat | grep "^+oid" | cut -d ":" -f 2)
|
aOid=$(git log --patch a.dat | grep "^+oid" | cut -d ":" -f 2)
|
||||||
aOid12=$(echo $aOid | cut -b 1-2)
|
aOid12=$(echo $aOid | cut -b 1-2)
|
||||||
aOid34=$(echo $aOid | cut -b 3-4)
|
aOid34=$(echo $aOid | cut -b 3-4)
|
||||||
if [ "$aOid" != "$(shasum -a 256 .git/lfs/objects/$aOid12/$aOid34/$aOid | cut -d " " -f 1)" ]; then
|
if [ "$aOid" != "$(calc_oid_file .git/lfs/objects/$aOid12/$aOid34/$aOid)" ]; then
|
||||||
echo "oid for a.dat does not match"
|
echo "oid for a.dat does not match"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -83,7 +83,7 @@ begin_test "fsck dry run"
|
|||||||
bOid=$(git log --patch b.dat | grep "^+oid" | cut -d ":" -f 2)
|
bOid=$(git log --patch b.dat | grep "^+oid" | cut -d ":" -f 2)
|
||||||
bOid12=$(echo $bOid | cut -b 1-2)
|
bOid12=$(echo $bOid | cut -b 1-2)
|
||||||
bOid34=$(echo $bOid | cut -b 3-4)
|
bOid34=$(echo $bOid | cut -b 3-4)
|
||||||
if [ "$bOid" != "$(shasum -a 256 .git/lfs/objects/$bOid12/$bOid34/$bOid | cut -d " " -f 1)" ]; then
|
if [ "$bOid" != "$(calc_oid_file .git/lfs/objects/$bOid12/$bOid34/$bOid)" ]; then
|
||||||
echo "oid for b.dat does not match"
|
echo "oid for b.dat does not match"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -92,12 +92,12 @@ begin_test "fsck dry run"
|
|||||||
|
|
||||||
[ "Object a.dat ($aOid) is corrupt" = "$(git lfs fsck --dry-run)" ]
|
[ "Object a.dat ($aOid) is corrupt" = "$(git lfs fsck --dry-run)" ]
|
||||||
|
|
||||||
if [ "$aOid" = "$(shasum -a 256 .git/lfs/objects/$aOid12/$aOid34/$aOid | cut -d " " -f 1)" ]; then
|
if [ "$aOid" = "$(calc_oid_file .git/lfs/objects/$aOid12/$aOid34/$aOid)" ]; then
|
||||||
echo "oid for a.dat still matches match"
|
echo "oid for a.dat still matches match"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$bOid" != "$(shasum -a 256 .git/lfs/objects/$bOid12/$bOid34/$bOid | cut -d " " -f 1)" ]; then
|
if [ "$bOid" != "$(calc_oid_file .git/lfs/objects/$bOid12/$bOid34/$bOid)" ]; then
|
||||||
echo "oid for b.dat does not match"
|
echo "oid for b.dat does not match"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -6,9 +6,16 @@ set -e
|
|||||||
UNAME=$(uname -s)
|
UNAME=$(uname -s)
|
||||||
IS_WINDOWS=0
|
IS_WINDOWS=0
|
||||||
IS_MAC=0
|
IS_MAC=0
|
||||||
if [[ $UNAME == MINGW* || $UNAME == CYGWIN* ]]
|
SHASUM="shasum -a 256"
|
||||||
|
|
||||||
|
if [[ $UNAME == MINGW* || $UNAME == MSYS* || $UNAME == CYGWIN* ]]
|
||||||
then
|
then
|
||||||
IS_WINDOWS=1
|
IS_WINDOWS=1
|
||||||
|
|
||||||
|
# Windows might be MSYS2 which does not have the shasum Perl wrapper
|
||||||
|
# script by default, so use sha256sum directly. MacOS on the other hand
|
||||||
|
# does not have sha256sum, so still use shasum as the default.
|
||||||
|
SHASUM="sha256sum"
|
||||||
elif [[ $UNAME == *Darwin* ]]
|
elif [[ $UNAME == *Darwin* ]]
|
||||||
then
|
then
|
||||||
IS_MAC=1
|
IS_MAC=1
|
||||||
@ -16,9 +23,9 @@ fi
|
|||||||
|
|
||||||
resolve_symlink() {
|
resolve_symlink() {
|
||||||
local arg=$1
|
local arg=$1
|
||||||
if [ $IS_WINDOWS == "1" ]; then
|
if [ $IS_WINDOWS -eq 1 ]; then
|
||||||
printf '%s' "$arg"
|
printf '%s' "$arg"
|
||||||
elif [ $IS_MAC == "1" ]; then
|
elif [ $IS_MAC -eq 1 ]; then
|
||||||
# no readlink -f on Mac
|
# no readlink -f on Mac
|
||||||
local oldwd=$(pwd)
|
local oldwd=$(pwd)
|
||||||
local target=$arg
|
local target=$arg
|
||||||
@ -111,7 +118,7 @@ mkdir -p "$TMPDIR"
|
|||||||
mkdir -p "$TRASHDIR"
|
mkdir -p "$TRASHDIR"
|
||||||
|
|
||||||
|
|
||||||
if [ $IS_WINDOWS == "1" ]; then
|
if [ $IS_WINDOWS -eq 1 ]; then
|
||||||
# prevent Windows OpenSSH from opening GUI prompts
|
# prevent Windows OpenSSH from opening GUI prompts
|
||||||
SSH_ASKPASS=""
|
SSH_ASKPASS=""
|
||||||
fi
|
fi
|
||||||
|
@ -289,7 +289,7 @@ setup() {
|
|||||||
git version
|
git version
|
||||||
|
|
||||||
if [ -z "$SKIPCOMPILE" ]; then
|
if [ -z "$SKIPCOMPILE" ]; then
|
||||||
[ $IS_WINDOWS == "1" ] && EXT=".exe"
|
[ $IS_WINDOWS -eq 1 ] && EXT=".exe"
|
||||||
for go in test/cmd/*.go; do
|
for go in test/cmd/*.go; do
|
||||||
GO15VENDOREXPERIMENT=1 go build -o "$BINPATH/$(basename $go .go)$EXT" "$go"
|
GO15VENDOREXPERIMENT=1 go build -o "$BINPATH/$(basename $go .go)$EXT" "$go"
|
||||||
done
|
done
|
||||||
@ -427,8 +427,14 @@ comparison_to_operator() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Calculate the object ID from the string passed as the argument
|
||||||
calc_oid() {
|
calc_oid() {
|
||||||
printf "$1" | shasum -a 256 | cut -f 1 -d " "
|
printf "$1" | $SHASUM | cut -f 1 -d " "
|
||||||
|
}
|
||||||
|
|
||||||
|
# Calculate the object ID from the file passed as the argument
|
||||||
|
calc_oid_file() {
|
||||||
|
$SHASUM "$1" | cut -f 1 -d " "
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get a date string with an offset
|
# Get a date string with an offset
|
||||||
@ -473,7 +479,7 @@ get_date() {
|
|||||||
# Needed to match generic built paths in test scripts to native paths generated from Go
|
# Needed to match generic built paths in test scripts to native paths generated from Go
|
||||||
native_path() {
|
native_path() {
|
||||||
local arg=$1
|
local arg=$1
|
||||||
if [ $IS_WINDOWS == "1" ]; then
|
if [ $IS_WINDOWS -eq 1 ]; then
|
||||||
# Use params form to avoid interpreting any '\' characters
|
# Use params form to avoid interpreting any '\' characters
|
||||||
printf '%s' "$(cygpath -w $arg)"
|
printf '%s' "$(cygpath -w $arg)"
|
||||||
else
|
else
|
||||||
@ -484,7 +490,7 @@ native_path() {
|
|||||||
# escape any instance of '\' with '\\' on Windows
|
# escape any instance of '\' with '\\' on Windows
|
||||||
escape_path() {
|
escape_path() {
|
||||||
local unescaped="$1"
|
local unescaped="$1"
|
||||||
if [ $IS_WINDOWS == "1" ]; then
|
if [ $IS_WINDOWS -eq 1 ]; then
|
||||||
printf '%s' "${unescaped//\\/\\\\}"
|
printf '%s' "${unescaped//\\/\\\\}"
|
||||||
else
|
else
|
||||||
printf '%s' "$unescaped"
|
printf '%s' "$unescaped"
|
||||||
|
@ -80,7 +80,7 @@ begin_test () {
|
|||||||
|
|
||||||
# enabling GIT_TRACE can cause Windows git to stall, esp with fd 5
|
# enabling GIT_TRACE can cause Windows git to stall, esp with fd 5
|
||||||
# other fd numbers like 8/9 don't stall but still don't work, so disable
|
# other fd numbers like 8/9 don't stall but still don't work, so disable
|
||||||
if [ $IS_WINDOWS == "0" ]; then
|
if [ $IS_WINDOWS -eq 0 ]; then
|
||||||
exec 5>"$trace"
|
exec 5>"$trace"
|
||||||
export GIT_TRACE=5
|
export GIT_TRACE=5
|
||||||
fi
|
fi
|
||||||
@ -114,7 +114,7 @@ end_test () {
|
|||||||
echo "-- stderr --"
|
echo "-- stderr --"
|
||||||
grep -v -e '^\+ end_test' -e '^+ set +x' <"$TRASHDIR/err" |
|
grep -v -e '^\+ end_test' -e '^+ set +x' <"$TRASHDIR/err" |
|
||||||
sed 's/^/ /'
|
sed 's/^/ /'
|
||||||
if [ "$IS_WINDOWS" == "0" ]; then
|
if [ $IS_WINDOWS -eq 0 ]; then
|
||||||
echo "-- git trace --"
|
echo "-- git trace --"
|
||||||
sed 's/^/ /' <"$TRASHDIR/trace"
|
sed 's/^/ /' <"$TRASHDIR/trace"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user