From 00e6b066e5dc5f57e12a3c8dc241c34c5a060c9c Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 2 Jul 2010 12:44:22 +0200 Subject: [PATCH] truncate only hashes, other ids need to remain intact --- scripts/post-receive-email-with-diffs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/post-receive-email-with-diffs b/scripts/post-receive-email-with-diffs index 52cbced..66a7bd2 100755 --- a/scripts/post-receive-email-with-diffs +++ b/scripts/post-receive-email-with-diffs @@ -175,6 +175,14 @@ generate_email() generate_email_footer } +# generate a pattern for testing if a string is a hash +hpat="";__=1; while [ $__ -le 40 ] ; do hpat=${hpat}'[0-9a-f]';__=$(($__+1)); done +function is_hash () { + local hash + hash=$1; shift + case $hash in $hpat) return 0;; *) return 1;; esac +} + generate_email_header() { # --- Email (all stdout will be the email) @@ -186,7 +194,7 @@ generate_email_header() details="$refname_type, $short_refname," fi local shortrev - shortrev=$(echo $describe | cut -b1-8) + is_hash $describe && shortrev="$(cut -b1-8 <<< $describe).." || shortrev=$describe # Generate header cat <<-EOF To: $recipients -- 2.47.0