From 19fe7360d2b220d8116aa9be41c3b2f330c215e5 Mon Sep 17 00:00:00 2001 From: Karolin Varner Date: Wed, 24 May 2023 00:00:15 +0200 Subject: [PATCH] fix: Git directory detection should not print an error if we are not in a git repo --- rp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rp b/rp index 4f57ce2..bc166a4 100755 --- a/rp +++ b/rp @@ -44,9 +44,14 @@ dbg() { } -add_warning_tag() { +detect_git_dir() { # https://stackoverflow.com/questions/3618078/pipe-only-stderr-through-a-filter - ("$@" 3>&1 1>&2 2>&3 3>&- | sed 's@^@WARNING: @') 3>&1 1>&2 2>&3 3>&- + ( + git -C "${scriptdir}" rev-parse --show-toplevel 3>&1 1>&2 2>&3 3>&- \ + | sed ' + /not a git repository/d; + s/^/WARNING: /' + ) 3>&1 1>&2 2>&3 3>&- } # Cleanup subsystem (sigterm) @@ -320,7 +325,7 @@ main() { project_name="rosenpass" verbose=0 scriptdir="$(dirname "${script}")" - gitdir="$(add_warning_tag git -C "${scriptdir}" rev-parse --show-toplevel)" || true + gitdir="$(detect_git_dir)" || true nixdir="$(readlink -f result/bin/rp | grep -Pio '^/nix/store/[^/]+(?=/bin/[^/]+)')" || true binary="$(find_rosenpass_binary)"