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>
This commit is contained in:
parent
ac4e58cab9
commit
4cf5d53b62
@ -108,10 +108,15 @@ maybe_remove_timestamp () {
|
|||||||
if test -z "$2"; then
|
if test -z "$2"; then
|
||||||
echo_without_newline "$1"
|
echo_without_newline "$1"
|
||||||
else
|
else
|
||||||
echo_without_newline "$(printf '%s\n' "$1" | sed -e 's/ [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$//')"
|
echo_without_newline "$(printf '%s\n' "$1" | remove_timestamp)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_timestamp () {
|
||||||
|
sed -e 's/ [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$//'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
run_tests () {
|
run_tests () {
|
||||||
type=$1
|
type=$1
|
||||||
sha1=$2
|
sha1=$2
|
||||||
|
Loading…
Reference in New Issue
Block a user