Simplify by replacing echo_kill with a pipefail function
This commit is contained in:
parent
1c26102791
commit
41d8f0d953
1 changed files with 11 additions and 12 deletions
|
@ -60,7 +60,6 @@ xecho_n() { xecho "$@" | tr -d \\n ; } # kill newlines
|
||||||
echo_git() { xecho "$@" ; } # Code clarity
|
echo_git() { xecho "$@" ; } # Code clarity
|
||||||
echo_info() { xecho "gcrypt:" "$@" >&2; }
|
echo_info() { xecho "gcrypt:" "$@" >&2; }
|
||||||
echo_die() { echo_info "$@" ; exit 1; }
|
echo_die() { echo_info "$@" ; exit 1; }
|
||||||
echo_kill() { echo_info "$@" ; kill $$; exit 1; }
|
|
||||||
|
|
||||||
isnull() { case "$1" in "") return 0;; *) return 1;; esac; }
|
isnull() { case "$1" in "") return 0;; *) return 1;; esac; }
|
||||||
isnonnull() { ! isnull "$1"; }
|
isnonnull() { ! isnull "$1"; }
|
||||||
|
@ -68,6 +67,12 @@ iseq() { case "$1" in "$2") return 0;; *) return 1;; esac; }
|
||||||
isnoteq() { ! iseq "$1" "$2"; }
|
isnoteq() { ! iseq "$1" "$2"; }
|
||||||
negate() { ! "$@"; }
|
negate() { ! "$@"; }
|
||||||
|
|
||||||
|
# Execute $@ or die
|
||||||
|
pipefail()
|
||||||
|
{
|
||||||
|
"$@" || { echo_info "'$1' failed!"; kill $$; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
isurl() { isnull "${2%%$1://*}"; }
|
isurl() { isnull "${2%%$1://*}"; }
|
||||||
islocalrepo() { isnull "${1##/*}" && [ ! -e "$1/HEAD" ]; }
|
islocalrepo() { isnull "${1##/*}" && [ ! -e "$1/HEAD" ]; }
|
||||||
|
|
||||||
|
@ -628,8 +633,7 @@ EOF
|
||||||
|
|
||||||
xfeed "$r_del_list" get_pack_files "$Tempdir/pack/"
|
xfeed "$r_del_list" get_pack_files "$Tempdir/pack/"
|
||||||
|
|
||||||
(set +f; git verify-pack -v "$Tempdir"/pack/*.idx ||
|
(set +f; pipefail git verify-pack -v "$Tempdir"/pack/*.idx) |
|
||||||
echo_kill "git verify-pack failed!") |
|
|
||||||
grep -E '^[0-9a-f]{40}' | cut -f 1 -d ' '
|
grep -E '^[0-9a-f]{40}' | cut -f 1 -d ' '
|
||||||
|
|
||||||
Packlist=$r_keep_packlist
|
Packlist=$r_keep_packlist
|
||||||
|
@ -736,15 +740,10 @@ EOF
|
||||||
if [ -s "$tmp_objlist" ]
|
if [ -s "$tmp_objlist" ]
|
||||||
then
|
then
|
||||||
key_=$(genkey "$Packkey_bytes")
|
key_=$(genkey "$Packkey_bytes")
|
||||||
pack_id=$(\
|
pack_id=$(export GIT_ALTERNATE_OBJECT_DIRECTORIES=$Tempdir;
|
||||||
{
|
pipefail git pack-objects --stdout < "$tmp_objlist" |
|
||||||
GIT_ALTERNATE_OBJECT_DIRECTORIES=$Tempdir \
|
pipefail ENCRYPT "$key_" |
|
||||||
git pack-objects --stdout < "$tmp_objlist" ||
|
tee "$tmp_encrypted" | gpg_hash "$Hashtype")
|
||||||
echo_kill "git pack-objects failed!"
|
|
||||||
} | {
|
|
||||||
ENCRYPT "$key_" ||
|
|
||||||
echo_kill "gpg -c failed!"
|
|
||||||
} | tee "$tmp_encrypted" | gpg_hash "$Hashtype")
|
|
||||||
|
|
||||||
append_to @Packlist "pack :${Hashtype}:$pack_id $key_"
|
append_to @Packlist "pack :${Hashtype}:$pack_id $key_"
|
||||||
if isnonnull "$r_pack_delete"
|
if isnonnull "$r_pack_delete"
|
||||||
|
|
Loading…
Reference in a new issue