Fix commit id reporting in the subject
authorSimon 'corecode' Schubert <corecode@fs.ei.tum.de>
Mon, 1 Dec 2008 16:00:24 +0000 (17:00 +0100)
committerSimon 'corecode' Schubert <corecode@fs.ei.tum.de>
Mon, 1 Dec 2008 16:00:24 +0000 (17:00 +0100)
Reported-by: matthias@
post-receive-email

index 6771877..f8e83d8 100755 (executable)
@@ -155,13 +155,9 @@ generate_email()
                exit 0
        fi
 
-       # Email parameters
        # The email subject will contain the best description of the ref
        # that we can build from the parameters
-       describe=$(git describe $rev 2>/dev/null)
-       if [ -z "$describe" ]; then
-               describe=$rev
-       fi
+       set_describe $rev
 
        # Call the correct body generation function
        fn_name=general
@@ -223,6 +219,14 @@ generate_email()
        esac
 }
 
+set_describe()
+{
+       describe=$(git describe $1 2>/dev/null)
+       if [ -z "$describe" ]; then
+               describe=$1
+       fi
+}
+
 generate_email_header()
 {
        # --- Email (all stdout will be the email)
@@ -243,7 +247,7 @@ generate_email_header()
 
        cat <<-EOF
        To: $recipients
-       Subject: ${emailprefix}$print_refname$short_refname${print_change_type}: $detail$describe
+       Subject: ${emailprefix}$print_refname$short_refname${print_change_type}: $describe
        X-Git-Refname: $refname
        X-Git-Reftype: $refname_type
        X-Git-Newrev: $newrev
@@ -313,8 +317,10 @@ skip_diff_tree_parent()
 
 set_update_branch_subject()
 {
-       detail="$(git diff-tree -r --name-only $oldrev${oldrev:+..}$newrev |
-                       skip_diff_tree_parent | tr '\n' ' ') "
+       set_describe $newrev
+
+       describe="$(git diff-tree -r --name-only $oldrev${oldrev:+..}$newrev |
+                       skip_diff_tree_parent | sed -e 's/^/    /') $describe"
        [ -n "$(git diff-tree -r --name-only --cc $oldrev${oldrev:+..}$newrev |
                skip_diff_tree_parent)" ]
 }