Skip to content

Commit 4cf5d53

Browse files
john-caigitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ac4e58c commit 4cf5d53

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

t/t1006-cat-file.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,18 @@ strlen () {
105105
}
106106

107107
maybe_remove_timestamp () {
108-
if test -z "$2"; then
109-
echo_without_newline "$1"
110-
else
111-
echo_without_newline "$(printf '%s\n' "$1" | sed -e 's/ [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$//')"
112-
fi
108+
if test -z "$2"; then
109+
echo_without_newline "$1"
110+
else
111+
echo_without_newline "$(printf '%s\n' "$1" | remove_timestamp)"
112+
fi
113113
}
114114

115+
remove_timestamp () {
116+
sed -e 's/ [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$//'
117+
}
118+
119+
115120
run_tests () {
116121
type=$1
117122
sha1=$2

0 commit comments

Comments
 (0)