From efd26ba38941c0f35ad52ff463cddeec47d9f635 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Trygve=20Laugst=C3=B8l?= Date: Sun, 10 Jul 2011 15:27:59 -0400 Subject: [PATCH] When calling stat, check for last modified time instead of last accessed. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Check for platform when calling sha1. regression/scaffold: Implement seq with sed for Darwin. regression/t-021.sh: Implement tac with sed for Darwin. regression/t-025.sh: Use touch -t instead of -d as Darwin's touch doesn't support -d. Signed-off-by: Trygve Laugstøl Signed-off-by: Josef 'Jeff' Sipek --- guilt | 4 ++-- regression/bin/dump_reg | 11 ++++++++++- regression/scaffold | 27 +++++++++++++++++++++++++++ regression/t-021.sh | 8 ++++++++ regression/t-025.sh | 2 +- 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/guilt b/guilt index d379716..4271035 100755 --- a/guilt +++ b/guilt @@ -783,7 +783,7 @@ guilt_hook() last_modified() { case $UNAME_S in - Darwin) stat -f "%a" "$1" ;; + Darwin) stat -f "%m" "$1" ;; Linux) stat -c "%Y" "$1" ;; *) echo "Unsupported operating system: $UNAME_S" ;; esac @@ -793,7 +793,7 @@ last_modified() format_last_modified() { case $UNAME_S in - Darwin) stat -f "%Sa" -t "%Y-%m-%d %H:%M:%S %z" "$1" ;; + Darwin) stat -f "%Sm" -t "%Y-%m-%d %H:%M:%S %z" "$1" ;; Linux) # must strip nano-second part otherwise git gets very # confused, and makes up strange timestamps from the past diff --git a/regression/bin/dump_reg b/regression/bin/dump_reg index 6297eee..0451b93 100755 --- a/regression/bin/dump_reg +++ b/regression/bin/dump_reg @@ -1,5 +1,14 @@ #!/bin/sh +UNAME_S=`uname -s` +sha1() { + case $UNAME_S in + Darwin) openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," ;; + Linux) sha1sum "$1" ;; + *) echo "Unsupported operating system: $UNAME_S" ;; + esac +} + if [ $# -ne 1 ]; then echo "ERROR" exit 1 @@ -8,7 +17,7 @@ fi if [ -d "$1" ]; then echo "d $1" elif [ -f "$1" ]; then - echo "f `sha1sum "$1"`" + echo "f `sha1 "$1"`" else echo "? $1" fi diff --git a/regression/scaffold b/regression/scaffold index b8addad..d2c5985 100644 --- a/regression/scaffold +++ b/regression/scaffold @@ -16,6 +16,8 @@ export GIT_AUTHOR_EMAIL="author@email" export GIT_COMMITTER_NAME="Commiter Name" export GIT_COMMITTER_EMAIL="commiter@email" +UNAME_S=`uname -s` + # usage: die function die { @@ -122,3 +124,28 @@ function setup_repo setup_guilt_repo } +function seq() { + if [ $UNAME_S = "Linux" ] + then + `which seq` "$@" + return $? + fi + declare incr n1 n2 num1 num2 + if [[ $# -eq 1 ]] + then + /usr/bin/jot $1 + elif [[ $# -eq 2 ]] + then + n1=$((${2} - ${1} + 1)) + n2=$1 + /usr/bin/jot $n1 $n2 + elif [[ $# -eq 3 ]] + then + num1=${1} + incr=${2} + num2=${3} + # /usr/bin/awk -v n1=${num1} -v n2=${num2} -v add=${incr} 'BEGIN{ for(i=n1; i<=n2; i+=add) print i;}' | /usr/bin/sed 's/.+e.+/0/' + /usr/bin/awk -v n1=${num1} -v n2=${num2} -v add=${incr} 'BEGIN{ for(i=n1; i<=n2; i+=add) print i;}' | /usr/bin/sed -E '/e/s/^.+e.+$/0/' + fi + return 0 +} diff --git a/regression/t-021.sh b/regression/t-021.sh index ddf65c8..c809a50 100755 --- a/regression/t-021.sh +++ b/regression/t-021.sh @@ -3,6 +3,14 @@ # Test the pop code # +function tac() { + case $UNAME_S in + Darwin) sed -e '1!G;h;$!d' ;; + Linux) `which tac` ;; + *) echo "Unsupported operating system: $UNAME_S" ;; + esac +} + source $REG_DIR/scaffold cmd setup_repo diff --git a/regression/t-025.sh b/regression/t-025.sh index 042bfe0..426a3cf 100755 --- a/regression/t-025.sh +++ b/regression/t-025.sh @@ -9,7 +9,7 @@ cmd setup_repo function fixup_time_info { - touch -d "$GIT_COMMITTER_DATE" ".git/patches/master/$1" + touch -a -m -t "$TOUCH_DATE" ".git/patches/master/$1" } for pname in file dir/file dir/subdir/file ; do -- 2.11.4.GIT