summaryrefslogtreecommitdiff
path: root/t/t1006-cat-file.sh
diff options
context:
space:
mode:
authorJohn Cai <johncai86@gmail.com>2022-02-18 18:23:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-02-18 19:21:46 (GMT)
commit4cf5d53b62a8e5fce64db97f830e00fa38bd0994 (patch)
tree08112e6cfc5692f24a3b7115c4eb3e456915f434 /t/t1006-cat-file.sh
parentac4e58cab9a946d4c45f1db5ee7c79b6fb14bd67 (diff)
downloadgit-4cf5d53b62a8e5fce64db97f830e00fa38bd0994.zip
git-4cf5d53b62a8e5fce64db97f830e00fa38bd0994.tar.gz
git-4cf5d53b62a8e5fce64db97f830e00fa38bd0994.tar.bz2
cat-file: add remove_timestamp helper
maybe_remove_timestamp() takes arguments, but it would be useful to have a function that reads from stdin and strips the timestamp. This would allow tests to pipe data into a function to remove timestamps, and wouldn't have to always assign a variable. This is especially helpful when the data is multiple lines. Keep maybe_remove_timestamp() the same, but add a remove_timestamp helper that reads from stdin. The tests in the next patch will make use of this. Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1006-cat-file.sh')
-rwxr-xr-xt/t1006-cat-file.sh15
1 files changed, 10 insertions, 5 deletions
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 145eee1..2d52851 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -105,13 +105,18 @@ strlen () {
}
maybe_remove_timestamp () {
- if test -z "$2"; then
- echo_without_newline "$1"
- else
- echo_without_newline "$(printf '%s\n' "$1" | sed -e 's/ [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$//')"
- fi
+ if test -z "$2"; then
+ echo_without_newline "$1"
+ else
+ echo_without_newline "$(printf '%s\n' "$1" | remove_timestamp)"
+ fi
}
+remove_timestamp () {
+ sed -e 's/ [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$//'
+}
+
+
run_tests () {
type=$1
sha1=$2