From 31ce46f54f9f8a6ead0105db68646277944b940d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 7 Jul 2019 00:09:14 +0100 Subject: git-debpush: Defend against git-deborig #931509 Without this, when git-deborig fails and #931509 isn't fixed, git-debpush will silently exit with a nonzero exit status which is very unfriendly. With this change it does something like this: git-debpush: git-deborig failed; maybe try git-debpush --upstream=TAG fatal: Invalid object name 'refs/tags/couldn't find any of the following tags'. It then exits status 127. This is obviously daft, but making this any better is even more complex. When git-deborig is fixed it will do this: couldn't find any of the following tags: 1.0, v1.0, upstream/1.0 tell me a tag or branch head to make an orig.tar from: git deborig --just-print '--version=1.0-1' COMMITTISH git-debpush: git-deborig failed; maybe try git-debpush --upstream=TAG which is still not brilliant but I guess it will do. The downside, if it is one, is that we lose git-deborig's original exit status. Signed-off-by: Ian Jackson Acked-by: Sean Whitton --- git-debpush | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/git-debpush b/git-debpush index 5ffbd52..ae5f20f 100755 --- a/git-debpush +++ b/git-debpush @@ -216,8 +216,23 @@ esac upstream_info="" if $upstream; then if [ "x$upstream_tag" = x ]; then - upstream_tag=$(git deborig --just-print --version="$version" \ - | head -n1) + upstream_tag=$( + set +e + git deborig --just-print --version="$version" \ + | head -n1 + ps="${PIPESTATUS[*]}" + set -e + case "$ps" in + "0 0"|"141 0") ;; # ok or SIGPIPE + *" 0") + echo >&2 \ + "$us: git-deborig failed; maybe try $us --upstream=TAG" + exit 0 + ;; + *) exit 127; # presumably head will have complained + esac + ) + if [ "x$upstream_tag" = x ]; then exit 127; fi fi upstream_committish=$(git rev-parse "refs/tags/${upstream_tag}"^{}) upstream_info=" upstream-tag=$upstream_tag upstream=$upstream_committish" -- cgit v1.2.3