From d4e42fd6d4133e584ff95edf8bfff683da61956e Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Thu, 18 Aug 2016 05:43:07 -0700 Subject: [PATCH] mail.sh: further restrict new branch change summary The recently added changes to improve the new branch change summary when the new branch is a fork of a pre-existing revision rely on the heuristic that the last shown revision by show_new_revisions will be the single leaf in the (possibly partial) graph shown by show_new_revisions. This may not always be the case. Therefore detect these other cases (where show_new_revisions showed a graph fragment with more than one leaf) and suppress the summary of changes for new branch notifications when this situation is detected to avoid showing an incorrect and misleading summary of changes. Signed-off-by: Kyle J. McKay --- taskd/mail.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/taskd/mail.sh b/taskd/mail.sh index 94fd273..82c9679 100755 --- a/taskd/mail.sh +++ b/taskd/mail.sh @@ -388,10 +388,12 @@ generate_create_branch_email() # If any revisions were shown by show_new_revisions then we show # a diffstat from the last shown revisions's parent (or the empty tree # if the last revision shown is a root revision) to the new revision - # provided the last shown revision is not a merge commit. + # provided the last shown revision is not a merge commit and there + # was at most a single boundary commit encountered by show_new_revisions. # This is to show the truth of what happened in this change. - if [ -n "$LAST_SHOWN_REVISION" ] && [ -n "$LAST_SHOWN_NPARENTS" ] && [ "$LAST_SHOWN_NPARENTS" -le 1 ]; then + if [ -n "$LAST_SHOWN_REVISION" ] && [ -n "$LAST_SHOWN_NPARENTS" ] && [ -n "$LAST_SHOWN_NBOUNDARY" ] && \ + [ "$LAST_SHOWN_NPARENTS" -le 1 ] && [ "$LAST_SHOWN_NBOUNDARY" -le 1 ]; then if [ "$LAST_SHOWN_NPARENTS" -eq 0 ]; then # Note that since Git 1.5.5 the empty tree object is ALWAYS available # whether or not it's actually present in the repository. @@ -807,6 +809,7 @@ generate_delete_general_email() # # On return LAST_SHOWN_REVISION will be set to non-empty if any revisions shown # and LAST_SHOWN_NPARENTS will be the number of parents it has (possibly 0) +# and LAST_SHOWN_NBOUNDARY will be the number of shown leaves (possibly 0) # show_new_revisions() { @@ -817,6 +820,7 @@ show_new_revisions() # command) LAST_SHOWN_REVISION= LAST_SHOWN_NPARENTS= + LAST_SHOWN_NBOUNDARY=0 # Revision range passed to rev-list differs for new vs. updated # branches. @@ -846,8 +850,12 @@ show_new_revisions() # then # git rev-list --pretty --stdin $revspec # else - while read onerev pcnt && [ -n "$onerev" ] && [ -n "$pcnt" ] + while read onerev mark pcnt && [ -n "$onerev" ] && [ -n "$mark" ] && [ -n "$pcnt" ] do + if [ "$mark" = "-" ]; then + LAST_SHOWN_NBOUNDARY=$(( $LAST_SHOWN_NBOUNDARY + 1 )) + continue + fi LAST_SHOWN_REVISION="$onerev" LAST_SHOWN_NPARENTS="$pcnt" if [ -n "$custom_showrev" ]; then @@ -879,8 +887,8 @@ show_new_revisions() $(eval "$othertips" | git cat-file --batch-check='^%(objectname)' | LC_ALL=C sed -e '/ missing$/d' | -git --no-pager log --stdin --no-color --format=tformat:"%H %p" $revspec | -LC_ALL=C awk '{print $1 " " NF-1}') +git --no-pager log --stdin --no-color --boundary --format=tformat:"%H %m %p" $revspec | +LC_ALL=C awk '{print $1 " " $2 " " NF-2}') EOT # fi } -- 2.11.4.GIT