From 6c52efcb43a49f74b9e1276772cd96b3d8e2b9d6 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:06:11 -0700 Subject: Keep the age hook quiet when it cannot write --- custom/hooks/post-receive.cgit-age | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'custom/hooks/post-receive.cgit-age') diff --git a/custom/hooks/post-receive.cgit-age b/custom/hooks/post-receive.cgit-age index a87e325..c2c4092 100755 --- a/custom/hooks/post-receive.cgit-age +++ b/custom/hooks/post-receive.cgit-age @@ -2,8 +2,10 @@ # Updates the age-file cgit reads for the idle column. The path below is the # default age-file, so a cgitrc that changes the setting needs the same change -# here. To install the hook, copy or link it to hooks/post-receive in each -# repository. +# here. A file the pusher cannot write stays as it was, and nothing here +# complains or exits nonzero, so the pusher is not shown an error over a stale +# idle column. To install the hook, copy or link it to hooks/post-receive in +# each repository. set -eu @@ -32,10 +34,10 @@ date="$(git for-each-ref --sort=-committerdate --count=1 \ # being handed an empty file. test -n "$date" || exit 0 -mkdir -p "$(dirname "$agefile")" +mkdir -p "$(dirname "$agefile")" 2>/dev/null || exit 0 # Write through a temporary file so a reader never sees a half written date. tmpfile="$agefile.$$" trap 'rm -f "$tmpfile"' EXIT -printf '%s\n' "$date" >"$tmpfile" -mv "$tmpfile" "$agefile" +{ printf '%s\n' "$date" >"$tmpfile"; } 2>/dev/null || exit 0 +mv "$tmpfile" "$agefile" 2>/dev/null || : -- cgit