From c3124d06fdf86e07d1e2357a010e2a621647af58 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Fri, 22 Aug 2008 07:28:06 -0500 Subject: [PATCH] Refactor to do diff per commit and only show conflicted changes in merges. --- server/functions | 77 +++++++ server/post-receive-email | 199 ++++-------------- tests/t2200-1.txt | 18 +- tests/t2200-server-post-receive-email.sh | 8 +- tests/t2201-1.txt | 8 +- tests/t2201-2.txt | 35 ++- tests/t2201-3.txt | 10 +- tests/t2201-4.txt | 2 +- tests/t2201-5.txt | 4 +- tests/t2201-6.txt | 2 +- tests/t2201-7.txt | 12 +- tests/t2201-8.txt | 2 +- tests/t2201-server-post-receive-email-tags.sh | 6 +- tests/t2202-1.txt | 31 ++- tests/t2202-3.txt | 5 +- tests/t2202-4.txt | 13 +- tests/t2202-5.txt | 10 +- tests/t2202-6.txt | 22 +- ...2202-server-post-receive-email-branches.sh | 17 +- tests/t2203-1.txt | 29 +-- tests/t2203-2.txt | 37 ++-- .../t2203-server-post-receive-email-stable.sh | 8 +- 22 files changed, 262 insertions(+), 293 deletions(-) diff --git a/server/functions b/server/functions index 28ad90f..5e4616a 100644 --- a/server/functions +++ b/server/functions @@ -8,6 +8,83 @@ # as it will replace only the first match, compared to the canonical "grep -v" # approach which will throw out multiple matches if the same commit is referred # to by multiple branches. +# +# Excellent, excellent docs from Andy Parkin's email script +# +################################################## +# +# Consider this: +# 1 --- 2 --- O --- X --- 3 --- 4 --- N +# +# O is $oldrev for $refname +# N is $newrev for $refname +# X is a revision pointed to by some other ref, for which we may +# assume that an email has already been generated. +# In this case we want to issue an email containing only revisions +# 3, 4, and N. Given (almost) by +# +# git rev-list N ^O --not --all +# +# The reason for the "almost", is that the "--not --all" will take +# precedence over the "N", and effectively will translate to +# +# git rev-list N ^O ^X ^N +# +# So, we need to build up the list more carefully. git rev-parse +# will generate a list of revs that may be fed into git rev-list. +# We can get it to make the "--not --all" part and then filter out +# the "^N" with: +# +# git rev-parse --not --all | grep -v N +# +# Then, using the --stdin switch to git rev-list we have effectively +# manufactured +# +# git rev-list N ^O ^X +# +# This leaves a problem when someone else updates the repository +# while this script is running. Their new value of the ref we're +# working on would be included in the "--not --all" output; and as +# our $newrev would be an ancestor of that commit, it would exclude +# all of our commits. What we really want is to exclude the current +# value of $refname from the --not list, rather than N itself. So: +# +# git rev-parse --not --all | grep -v $(git rev-parse $refname) +# +# Get's us to something pretty safe (apart from the small time +# between refname being read, and git rev-parse running - for that, +# I give up) +# +# +# Next problem, consider this: +# * --- B --- * --- O ($oldrev) +# \ +# * --- X --- * --- N ($newrev) +# +# That is to say, there is no guarantee that oldrev is a strict +# subset of newrev (it would have required a --force, but that's +# allowed). So, we can't simply say rev-list $oldrev..$newrev. +# Instead we find the common base of the two revs and list from +# there. +# +# As above, we need to take into account the presence of X; if +# another branch is already in the repository and points at some of +# the revisions that we are about to output - we don't want them. +# The solution is as before: git rev-parse output filtered. +# +# Finally, tags: 1 --- 2 --- O --- T --- 3 --- 4 --- N +# +# Tags pushed into the repository generate nice shortlog emails that +# summarise the commits between them and the previous tag. However, +# those emails don't include the full commit messages that we output +# for a branch update. Therefore we still want to output revisions +# that have been output on a tag email. +# +# Luckily, git rev-parse includes just the tool. Instead of using +# "--all" we use "--branches"; this has the added benefit that +# "remotes/" will be ignored as well. +# +################################################## function set_new_commits() { nl=$'\n' diff --git a/server/post-receive-email b/server/post-receive-email index 1e08c8a..7bc974e 100755 --- a/server/post-receive-email +++ b/server/post-receive-email @@ -160,26 +160,25 @@ generate_email_header() generate_create_branch_email() { # This is a new branch and so oldrev is not valid - echo " at $newrev ($newrev_type)" - echo "" - - echo $LOGBEGIN - # This shows all log entries that are not already covered by - # another ref - i.e. commits that are now accessible from this - # ref that were previously not accessible - # (see generate_update_branch_email for the explanation of this - # command) + git rev-list --pretty=format:" at %h %s" --no-walk "$newrev" | grep -vP "^commit" set_new_commits - echo "$new_commits" | git rev-list --pretty --reverse --stdin - echo $LOGEND echo "" - echo "Summary of changes:" + echo $LOGBEGIN + echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do + echo "" + git rev-list --no-walk --pretty "$commit" + git diff-tree --cc "$commit" + echo "" + echo $LOGEND + done oldest_new=$(echo "$new_commits" | git rev-list --stdin | tail -n 1) if [ "$oldest_new" != "" ] ; then - git diff-tree --stat -p $oldest_new^..$newrev + echo "" + echo "Summary of changes:" + git diff-tree --stat $oldest_new^..$newrev fi } @@ -188,121 +187,20 @@ generate_create_branch_email() # generate_update_branch_email() { - # Consider this: - # 1 --- 2 --- O --- X --- 3 --- 4 --- N - # - # O is $oldrev for $refname - # N is $newrev for $refname - # X is a revision pointed to by some other ref, for which we may - # assume that an email has already been generated. - # In this case we want to issue an email containing only revisions - # 3, 4, and N. Given (almost) by - # - # git rev-list N ^O --not --all - # - # The reason for the "almost", is that the "--not --all" will take - # precedence over the "N", and effectively will translate to - # - # git rev-list N ^O ^X ^N - # - # So, we need to build up the list more carefully. git rev-parse - # will generate a list of revs that may be fed into git rev-list. - # We can get it to make the "--not --all" part and then filter out - # the "^N" with: - # - # git rev-parse --not --all | grep -v N - # - # Then, using the --stdin switch to git rev-list we have effectively - # manufactured - # - # git rev-list N ^O ^X - # - # This leaves a problem when someone else updates the repository - # while this script is running. Their new value of the ref we're - # working on would be included in the "--not --all" output; and as - # our $newrev would be an ancestor of that commit, it would exclude - # all of our commits. What we really want is to exclude the current - # value of $refname from the --not list, rather than N itself. So: - # - # git rev-parse --not --all | grep -v $(git rev-parse $refname) - # - # Get's us to something pretty safe (apart from the small time - # between refname being read, and git rev-parse running - for that, - # I give up) - # - # - # Next problem, consider this: - # * --- B --- * --- O ($oldrev) - # \ - # * --- X --- * --- N ($newrev) - # - # That is to say, there is no guarantee that oldrev is a strict - # subset of newrev (it would have required a --force, but that's - # allowed). So, we can't simply say rev-list $oldrev..$newrev. - # Instead we find the common base of the two revs and list from - # there. - # - # As above, we need to take into account the presence of X; if - # another branch is already in the repository and points at some of - # the revisions that we are about to output - we don't want them. - # The solution is as before: git rev-parse output filtered. - # - # Finally, tags: 1 --- 2 --- O --- T --- 3 --- 4 --- N - # - # Tags pushed into the repository generate nice shortlog emails that - # summarise the commits between them and the previous tag. However, - # those emails don't include the full commit messages that we output - # for a branch update. Therefore we still want to output revisions - # that have been output on a tag email. - # - # Luckily, git rev-parse includes just the tool. Instead of using - # "--all" we use "--branches"; this has the added benefit that - # "remotes/" will be ignored as well. - - # List all of the revisions that were removed by this update, in a - # fast forward update, this list will be empty, because rev-list O - # ^N is empty. For a non fast forward, O ^N is the list of removed - # revisions - fast_forward="" - rev="" - for rev in $(git rev-list $newrev..$oldrev) - do - revtype=$(git cat-file -t "$rev") - echo " discards $rev ($revtype)" - done - if [ -z "$rev" ]; then - fast_forward=1 - fi + # List all of the revisions that were removed by this update (hopefully empty) + git rev-list --first-parent --pretty=format:" discards %h %s" $newrev..$oldrev | grep -vP "^commit" - # List all the revisions from baserev to newrev in a kind of - # "table-of-contents"; note this list can include revisions that - # have already had notification emails and is present to show the - # full detail of the change from rolling back the old revision to - # the base revision and then forward to the new revision - # Changed: added --first-parent to not go down merge commits - for rev in $(git rev-list --first-parent $oldrev..$newrev) - do - revtype=$(git cat-file -t "$rev") - echo " via $rev ($revtype)" - done + # List all of the revisions that were added by this update + git rev-list --first-parent --pretty=format:" via %h %s" $oldrev..$newrev | grep -vP "^commit" - if [ "$fast_forward" ]; then - echo " from $oldrev ($oldrev_type)" + removed=$(git rev-list $newrev..$oldrev) + if [ "$removed" == "" ] ; then + git rev-list --no-walk --pretty=format:" from %h %s" $oldrev | grep -vP "^commit" else - # 1. Existing revisions were removed. In this case newrev - # is a subset of oldrev - this is the reverse of a - # fast-forward, a rewind - # 2. New revisions were added on top of an old revision, - # this is a rewind and addition. - - # (1) certainly happened, (2) possibly. When (2) hasn't - # happened, we set a flag to indicate that no log printout - # is required. - + # Must be rewind, could be rewind+addition echo "" - # Find the common ancestor of the old and new revisions and - # compare it with newrev + # Find the common ancestor of the old and new revisions and compare it with newrev baserev=$(git merge-base $oldrev $newrev) rewind_only="" if [ "$baserev" = "$newrev" ]; then @@ -338,31 +236,29 @@ generate_update_branch_email() echo "not appeared on any other notification email; so we list those" echo "revisions in full, below." + set_new_commits + echo "" echo $LOGBEGIN - - set_new_commits - echo "$new_commits" | git rev-list --reverse --pretty --stdin + echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do + echo "" + git rev-list --no-walk --pretty "$commit" + git diff-tree --cc "$commit" + echo "" + echo $LOGEND + done # XXX: Need a way of detecting whether git rev-list actually # outputted anything, so that we can issue a "no new # revisions added by this update" message - - echo $LOGEND else echo "No new revisions were added by this update." fi - # The diffstat is shown from the old revision to the new revision. - # This is to show the truth of what happened in this change. - # There's no point showing the stat from the base to the new - # revision because the base is effectively a random revision at this - # point - the user will be interested in what this revision changed - # - including the undoing of previous revisions in the case of - # non-fast forward updates. + # Show the diffstat which is what really happened (new commits/whatever aside) echo "" echo "Summary of changes:" - git diff-tree --stat -p --find-copies-harder $oldrev..$newrev + git diff-tree --stat --find-copies-harder $oldrev..$newrev } # @@ -384,7 +280,7 @@ generate_delete_branch_email() # generate_create_atag_email() { - echo " at $newrev ($newrev_type)" + echo " at $newrev ($newrev_type)" generate_atag_email } @@ -394,8 +290,8 @@ generate_create_atag_email() # generate_update_atag_email() { - echo " to $newrev ($newrev_type)" - echo " from $oldrev (which is now obsolete)" + echo " to $newrev ($newrev_type)" + echo " from $oldrev (which is now obsolete)" generate_atag_email } @@ -413,25 +309,22 @@ generate_atag_email() tagged=%(taggerdate)' $refname ) - echo " tagging $tagobject ($tagtype)" + echo " tagging $tagobject ($tagtype)" case "$tagtype" in commit) - # If the tagged object is a commit, then we assume this is a - # release, and so we calculate which tag this tag is - # replacing + # release, and so we calculate which tag this tag is replacing prevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null) - if [ -n "$prevtag" ]; then - echo " replaces $prevtag" + echo " replaces $prevtag" fi ;; *) - echo " length $(git cat-file -s $tagobject) bytes" + echo " length $(git cat-file -s $tagobject) bytes" ;; esac - echo " tagged by $tagger" - echo " on $tagged" + echo " tagged by $tagger" + echo " on $tagged" echo "" echo $LOGBEGIN @@ -468,7 +361,7 @@ generate_atag_email() # generate_delete_atag_email() { - echo " was $oldrev" + echo " was $oldrev ($oldrev_type)" echo "" echo $LOGEND git show -s --pretty=oneline $oldrev @@ -483,7 +376,7 @@ generate_delete_atag_email() # generate_create_ltag_email() { - echo " at $newrev ($newrev_type)" + echo " at $newrev ($newrev_type)" generate_ltag_email } @@ -493,8 +386,8 @@ generate_create_ltag_email() # generate_update_ltag_email() { - echo " to $newrev ($newrev_type)" - echo " from $oldrev" + echo " to $newrev ($newrev_type)" + echo " from $oldrev ($oldrev_type)" generate_ltag_email } @@ -531,7 +424,7 @@ generate_ltag_email() # generate_delete_ltag_email() { - echo " was $oldrev" + echo " was $oldrev ($oldrev_type)" echo "" echo $LOGEND git show -s --pretty=oneline $oldrev diff --git a/tests/t2200-1.txt b/tests/t2200-1.txt index 6a2e503..cd80be7 100644 --- a/tests/t2200-1.txt +++ b/tests/t2200-1.txt @@ -7,26 +7,22 @@ X-Git-Oldrev: $old_commit_hash X-Git-Newrev: $new_commit_hash The branch, master has been updated - via $new_commit_hash (commit) - from $old_commit_hash (commit) + via $new_commit_abbrev simple commit + from $old_commit_abbrev setup Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- + commit $new_commit_hash Author: A U Thor Date: $new_commit_date simple commit ------------------------------------------------------------------------ - -Summary of changes: - a | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) - +$new_commit_hash diff --git a/a b/a index 146f275..b38f23c 100644 --- a/a @@ -34,3 +30,9 @@ index 146f275..b38f23c 100644 @@ -1 +1 @@ -setup +simple commit + +----------------------------------------------------------------------- + +Summary of changes: + a | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tests/t2200-server-post-receive-email.sh b/tests/t2200-server-post-receive-email.sh index 3cda758..3b42aff 100644 --- a/tests/t2200-server-post-receive-email.sh +++ b/tests/t2200-server-post-receive-email.sh @@ -24,13 +24,17 @@ test_expect_success 'setup' ' install_post_receive_hook 'post-receive-email' test_expect_success 'simple commit' ' + old_commit_hash=$(git rev-parse HEAD) && + old_commit_abbrev=$(git rev-parse --short HEAD) && + echo $test_name >a && git commit -a -m "$test_name" && git push && - old_commit_hash=$(git rev-parse HEAD^) && new_commit_hash=$(git rev-parse HEAD) && new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) && - interpolate ../t2200-1.txt 1.txt old_commit_hash new_commit_hash new_commit_date && + new_commit_abbrev=$(git rev-parse --short HEAD) && + + interpolate ../t2200-1.txt 1.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_date new_commit_abbrev && test_cmp 1.txt server/.git/refs.heads.master.out ' diff --git a/tests/t2201-1.txt b/tests/t2201-1.txt index 9c92c37..d19fb71 100644 --- a/tests/t2201-1.txt +++ b/tests/t2201-1.txt @@ -7,10 +7,10 @@ X-Git-Oldrev: 0000000000000000000000000000000000000000 X-Git-Newrev: $tag_hash The annotated tag, 1.0 has been created - at $tag_hash (tag) - tagging $new_commit_hash (commit) - tagged by C O Mitter - on $tag_date + at $tag_hash (tag) + tagging $new_commit_hash (commit) + tagged by C O Mitter + on $tag_date - Log ----------------------------------------------------------------- 1.0 diff --git a/tests/t2201-2.txt b/tests/t2201-2.txt index 6e8a611..c00a443 100644 --- a/tests/t2201-2.txt +++ b/tests/t2201-2.txt @@ -7,37 +7,50 @@ X-Git-Oldrev: $old_commit_hash X-Git-Newrev: $new_commit_hash The branch, master has been updated - via $new_commit_hash (commit) - via $prior_commit_hash (commit) - from $old_commit_hash (commit) + via $new_commit_abbrev commit on annotated tagged branch 2 + via $prior_commit_abbrev commit on annotated tagged branch + from $old_commit_abbrev setup Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- + commit $prior_commit_hash Author: A U Thor Date: $prior_commit_date commit on annotated tagged branch +$prior_commit_hash +diff --git a/a b/a +index 146f275..815c4fa 100644 +--- a/a ++++ b/a +@@ -1 +1 @@ +-setup ++commit on annotated tagged branch + +----------------------------------------------------------------------- + commit $new_commit_hash Author: A U Thor Date: $new_commit_date commit on annotated tagged branch 2 ------------------------------------------------------------------------ - -Summary of changes: - a | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) - +$new_commit_hash diff --git a/a b/a -index 146f275..7d07572 100644 +index 815c4fa..7d07572 100644 --- a/a +++ b/a @@ -1 +1 @@ --setup +-commit on annotated tagged branch +commit on annotated tagged branch 2 + +----------------------------------------------------------------------- + +Summary of changes: + a | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tests/t2201-3.txt b/tests/t2201-3.txt index 71de2a7..3646a09 100644 --- a/tests/t2201-3.txt +++ b/tests/t2201-3.txt @@ -7,11 +7,11 @@ X-Git-Oldrev: 0000000000000000000000000000000000000000 X-Git-Newrev: $tag_hash The annotated tag, 2.0 has been created - at $tag_hash (tag) - tagging $new_commit_hash (commit) - replaces 1.0 - tagged by C O Mitter - on $tag_date + at $tag_hash (tag) + tagging $new_commit_hash (commit) + replaces 1.0 + tagged by C O Mitter + on $tag_date - Log ----------------------------------------------------------------- 2.0 diff --git a/tests/t2201-4.txt b/tests/t2201-4.txt index af4bc95..0cc9d47 100644 --- a/tests/t2201-4.txt +++ b/tests/t2201-4.txt @@ -7,7 +7,7 @@ X-Git-Oldrev: 0000000000000000000000000000000000000000 X-Git-Newrev: $new_commit_hash The tag, 2.1 has been created - at $new_commit_hash (commit) + at $new_commit_hash (commit) - Log ----------------------------------------------------------------- commit $new_commit_hash diff --git a/tests/t2201-5.txt b/tests/t2201-5.txt index bdc6c1c..70379a7 100644 --- a/tests/t2201-5.txt +++ b/tests/t2201-5.txt @@ -7,8 +7,8 @@ X-Git-Oldrev: $old_commit_hash X-Git-Newrev: $new_commit_hash The tag, 2.1 has been updated - to $new_commit_hash (commit) - from $old_commit_hash + to $new_commit_hash (commit) + from $old_commit_hash (commit) - Log ----------------------------------------------------------------- commit $new_commit_hash diff --git a/tests/t2201-6.txt b/tests/t2201-6.txt index 9bbbb78..a0f2f93 100644 --- a/tests/t2201-6.txt +++ b/tests/t2201-6.txt @@ -7,7 +7,7 @@ X-Git-Oldrev: $old_commit_hash X-Git-Newrev: 0000000000000000000000000000000000000000 The tag, 2.1 has been deleted - was $old_commit_hash + was $old_commit_hash (commit) ----------------------------------------------------------------------- $old_commit_hash force update lightweight tag diff --git a/tests/t2201-7.txt b/tests/t2201-7.txt index 4a45321..afcf165 100644 --- a/tests/t2201-7.txt +++ b/tests/t2201-7.txt @@ -7,12 +7,12 @@ X-Git-Oldrev: $old_tag_hash X-Git-Newrev: $new_tag_hash The annotated tag, 2.0 has been updated - to $new_tag_hash (tag) - from $old_tag_hash (which is now obsolete) - tagging $new_commit_hash (commit) - replaces 1.0 - tagged by C O Mitter - on $tag_date + to $new_tag_hash (tag) + from $old_tag_hash (which is now obsolete) + tagging $new_commit_hash (commit) + replaces 1.0 + tagged by C O Mitter + on $tag_date - Log ----------------------------------------------------------------- 2.0 diff --git a/tests/t2201-8.txt b/tests/t2201-8.txt index cf26a25..669dedd 100644 --- a/tests/t2201-8.txt +++ b/tests/t2201-8.txt @@ -7,7 +7,7 @@ X-Git-Oldrev: $old_tag_hash X-Git-Newrev: 0000000000000000000000000000000000000000 The annotated tag, 2.0 has been deleted - was $old_tag_hash + was $old_tag_hash (tag) ----------------------------------------------------------------------- tag 2.0 diff --git a/tests/t2201-server-post-receive-email-tags.sh b/tests/t2201-server-post-receive-email-tags.sh index 8195671..480f9cf 100644 --- a/tests/t2201-server-post-receive-email-tags.sh +++ b/tests/t2201-server-post-receive-email-tags.sh @@ -36,19 +36,23 @@ test_expect_success 'create annotated tag' ' test_expect_success 'commit on annotated tagged branch' ' old_commit_hash=$(git rev-parse HEAD) && + old_commit_abbrev=$(git rev-parse --short HEAD) && + echo "$test_name" >a && git commit -a -m "$test_name" && prior_commit_hash=$(git rev-parse HEAD) && prior_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) && + prior_commit_abbrev=$(git rev-parse --short HEAD) && echo "$test_name 2" >a && git commit -a -m "$test_name 2" && new_commit_hash=$(git rev-parse HEAD) && new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) && + new_commit_abbrev=$(git rev-parse --short HEAD) && git push && new_commit_abbrev=$(git rev-list -n 1 --pretty=format:%h HEAD | grep -v commit) && - interpolate ../t2201-2.txt 2.txt old_commit_hash new_commit_hash new_commit_date new_commit_abbrev prior_commit_hash prior_commit_date && + interpolate ../t2201-2.txt 2.txt old_commit_hash new_commit_hash new_commit_date new_commit_abbrev prior_commit_hash prior_commit_date old_commit_abbrev prior_commit_abbrev new_commit_abbrev && test_cmp 2.txt server/.git/refs.heads.master.out ' diff --git a/tests/t2202-1.txt b/tests/t2202-1.txt index 8a44ccc..3e5566c 100644 --- a/tests/t2202-1.txt +++ b/tests/t2202-1.txt @@ -7,31 +7,44 @@ X-Git-Oldrev: 0000000000000000000000000000000000000000 X-Git-Newrev: $new_commit_hash The branch, topic has been created - at $new_commit_hash (commit) + at $new_commit_abbrev create branch on topic 2 - Log ----------------------------------------------------------------- + commit $prior_commit_hash Author: A U Thor Date: $prior_commit_date create branch on topic +$prior_commit_hash +diff --git a/a b/a +index 146f275..55da47f 100644 +--- a/a ++++ b/a +@@ -1 +1 @@ +-setup ++create branch + +----------------------------------------------------------------------- + commit $new_commit_hash Author: A U Thor Date: $new_commit_date create branch on topic 2 ------------------------------------------------------------------------ - -Summary of changes: - a | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) - +$new_commit_hash diff --git a/a b/a -index 146f275..8516a40 100644 +index 55da47f..8516a40 100644 --- a/a +++ b/a @@ -1 +1 @@ --setup +-create branch +create branch 2 + +----------------------------------------------------------------------- + +Summary of changes: + a | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tests/t2202-3.txt b/tests/t2202-3.txt index e175c3f..a6d04c8 100644 --- a/tests/t2202-3.txt +++ b/tests/t2202-3.txt @@ -7,9 +7,6 @@ X-Git-Oldrev: 0000000000000000000000000000000000000000 X-Git-Newrev: $existing_commit_hash The branch, topic2 has been created - at $existing_commit_hash (commit) + at $existing_commit_abbrev create branch on topic 2 - Log ----------------------------------------------------------------- ------------------------------------------------------------------------ - -Summary of changes: diff --git a/tests/t2202-4.txt b/tests/t2202-4.txt index 5916d3b..ffab4be 100644 --- a/tests/t2202-4.txt +++ b/tests/t2202-4.txt @@ -7,24 +7,15 @@ X-Git-Oldrev: $old_commit_hash X-Git-Newrev: $existing_commit_hash The branch, topic has been updated - via $existing_commit_hash (commit) - from $old_commit_hash (commit) + via $existing_commit_abbrev update branch with existing commits does not replay them on topic + from $old_commit_abbrev create branch on topic 2 Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ------------------------------------------------------------------------ Summary of changes: a | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) - -diff --git a/a b/a -index 8516a40..5c0be09 100644 ---- a/a -+++ b/a -@@ -1 +1 @@ --create branch 2 -+update branch with existing commits does not replay them diff --git a/tests/t2202-5.txt b/tests/t2202-5.txt index 634a0ee..ca00200 100644 --- a/tests/t2202-5.txt +++ b/tests/t2202-5.txt @@ -7,7 +7,7 @@ X-Git-Oldrev: $old_commit_hash X-Git-Newrev: $new_commit_hash The branch, topic has been updated - discards $old_commit_hash (commit) + discards $old_commit_abbrev update branch with existing commits does not replay them on topic This update discarded existing revisions and left the branch pointing at a previous point in the repository history. @@ -24,11 +24,3 @@ No new revisions were added by this update. Summary of changes: a | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) - -diff --git a/a b/a -index 5c0be09..8516a40 100644 ---- a/a -+++ b/a -@@ -1 +1 @@ --update branch with existing commits does not replay them -+create branch 2 diff --git a/tests/t2202-6.txt b/tests/t2202-6.txt index eb0f086..218bcde 100644 --- a/tests/t2202-6.txt +++ b/tests/t2202-6.txt @@ -7,8 +7,8 @@ X-Git-Oldrev: $old_commit_hash X-Git-Newrev: $new_commit_hash The branch, topic has been updated - discards $old_commit_hash (commit) - via $new_commit_hash (commit) + discards $old_commit_abbrev create branch on topic 2 + via $new_commit_abbrev rewind and continue branch on topic This update added new revisions after undoing existing revisions. That is to say, the old revision is not a strict subset of the new revision. This @@ -28,22 +28,24 @@ not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- + commit $new_commit_hash Author: A U Thor Date: $new_commit_date rewind and continue branch on topic ------------------------------------------------------------------------ - -Summary of changes: - a | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) - +$new_commit_hash diff --git a/a b/a -index 8516a40..a30ab5b 100644 +index 55da47f..a30ab5b 100644 --- a/a +++ b/a @@ -1 +1 @@ --create branch 2 +-create branch +rewind and continue branch + +----------------------------------------------------------------------- + +Summary of changes: + a | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tests/t2202-server-post-receive-email-branches.sh b/tests/t2202-server-post-receive-email-branches.sh index f6239de..830a860 100644 --- a/tests/t2202-server-post-receive-email-branches.sh +++ b/tests/t2202-server-post-receive-email-branches.sh @@ -33,22 +33,24 @@ test_expect_success 'create branch' ' echo "$test_name 2" >a && git commit -a -m "$test_name on topic 2 " && new_commit_hash=$(git rev-parse HEAD) && + new_commit_abbrev=$(git rev-parse --short HEAD) && new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) && git push origin topic && - interpolate ../t2202-1.txt 1.txt new_commit_hash new_commit_date prior_commit_hash prior_commit_date && + interpolate ../t2202-1.txt 1.txt new_commit_hash new_commit_abbrev new_commit_date prior_commit_hash prior_commit_date && test_cmp 1.txt server/.git/refs.heads.topic.out ' test_expect_success 'create branch with existing commits does not replay them' ' git checkout -b topic2 topic && existing_commit_hash=$(git rev-parse HEAD) && + existing_commit_abbrev=$(git rev-parse --short HEAD) && existing_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) && git push origin topic2 && - interpolate ../t2202-3.txt 3.txt existing_commit_hash existing_commit_date && + interpolate ../t2202-3.txt 3.txt existing_commit_hash existing_commit_abbrev existing_commit_date && test_cmp 3.txt server/.git/refs.heads.topic2.out ' @@ -61,38 +63,43 @@ test_expect_success 'update branch with existing commits does not replay them' ' git checkout topic && old_commit_hash=$(git rev-parse HEAD) && + old_commit_abbrev=$(git rev-parse --short HEAD) && git merge topic2 && existing_commit_hash=$(git rev-parse HEAD) && + existing_commit_abbrev=$(git rev-parse --short HEAD) && git push && - interpolate ../t2202-4.txt 4.txt old_commit_hash existing_commit_hash && + interpolate ../t2202-4.txt 4.txt old_commit_hash old_commit_abbrev existing_commit_hash existing_commit_abbrev && test_cmp 4.txt server/.git/refs.heads.topic.out ' test_expect_success 'rewind branch' ' git checkout topic && old_commit_hash=$(git rev-parse HEAD) && + old_commit_abbrev=$(git rev-parse --short HEAD) && git reset --hard HEAD^ && git push --force && new_commit_hash=$(git rev-parse HEAD) && - interpolate ../t2202-5.txt 5.txt old_commit_hash new_commit_hash && + interpolate ../t2202-5.txt 5.txt old_commit_hash new_commit_hash old_commit_abbrev && test_cmp 5.txt server/.git/refs.heads.topic.out ' test_expect_success 'rewind and continue branch' ' git checkout topic && old_commit_hash=$(git rev-parse HEAD) && + old_commit_abbrev=$(git rev-parse --short HEAD) && git reset --hard HEAD^ && echo "$test_name" >a && git commit -a -m "$test_name on topic" && new_commit_hash=$(git rev-parse HEAD) && + new_commit_abbrev=$(git rev-parse --short HEAD) && new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) && git push --force && - interpolate ../t2202-6.txt 6.txt old_commit_hash new_commit_hash new_commit_date && + interpolate ../t2202-6.txt 6.txt old_commit_hash new_commit_hash new_commit_date new_commit_abbrev old_commit_abbrev && test_cmp 6.txt server/.git/refs.heads.topic.out ' diff --git a/tests/t2203-1.txt b/tests/t2203-1.txt index 1c96334..2279ac1 100644 --- a/tests/t2203-1.txt +++ b/tests/t2203-1.txt @@ -7,14 +7,15 @@ X-Git-Oldrev: $old_commit_hash X-Git-Newrev: $new_commit_hash The branch, topic1 has been updated - via $new_commit_hash (commit) - from $old_commit_hash (commit) + via $new_commit_abbrev Merge branch 'stable' into topic1 + from $old_commit_abbrev move topic1 Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- + commit $new_commit_hash Merge: $old_commit_hash $second_stable_hash Author: A U Thor @@ -22,6 +23,8 @@ Date: $new_commit_date Merge branch 'stable' into topic1 +$new_commit_hash + ----------------------------------------------------------------------- Summary of changes: @@ -29,25 +32,3 @@ Summary of changes: b | 2 +- c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/a b/a -index 146f275..1c043c5 100644 ---- a/a -+++ b/a -@@ -1 +1 @@ --setup -+merge in stable 2 -diff --git a/b b/b -index 146f275..1c043c5 100644 ---- a/b -+++ b/b -@@ -1 +1 @@ --setup -+merge in stable 2 -diff --git a/c b/c -index 146f275..1c043c5 100644 ---- a/c -+++ b/c -@@ -1 +1 @@ --setup -+merge in stable 2 diff --git a/tests/t2203-2.txt b/tests/t2203-2.txt index 5b0ad73..81f3c52 100644 --- a/tests/t2203-2.txt +++ b/tests/t2203-2.txt @@ -7,14 +7,15 @@ X-Git-Oldrev: $old_commit_hash X-Git-Newrev: $new_commit_hash The branch, topic1 has been updated - via $new_commit_hash (commit) - from $old_commit_hash (commit) + via $new_commit_abbrev Merge branch 'stable' into topic1 + from $old_commit_abbrev move topic1 Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- + commit $new_commit_hash Merge: $old_commit_hash $second_stable_hash Author: A U Thor @@ -25,6 +26,16 @@ Date: $new_commit_date Conflicts: a +$new_commit_hash +diff --cc a +index a67d715,96d4816..01a17ba +--- a/a ++++ b/a +@@@ -1,1 -1,1 +1,1 @@@ +- merge in stable with conflict on topic1 + -merge in stable with conflict 2 +++merge in stable with conflict 2 merged topic1 + ----------------------------------------------------------------------- Summary of changes: @@ -32,25 +43,3 @@ Summary of changes: b | 2 +- c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/a b/a -index a67d715..01a17ba 100644 ---- a/a -+++ b/a -@@ -1 +1 @@ --merge in stable with conflict on topic1 -+merge in stable with conflict 2 merged topic1 -diff --git a/b b/b -index 1c043c5..96d4816 100644 ---- a/b -+++ b/b -@@ -1 +1 @@ --merge in stable 2 -+merge in stable with conflict 2 -diff --git a/c b/c -index 1c043c5..96d4816 100644 ---- a/c -+++ b/c -@@ -1 +1 @@ --merge in stable 2 -+merge in stable with conflict 2 diff --git a/tests/t2203-server-post-receive-email-stable.sh b/tests/t2203-server-post-receive-email-stable.sh index af58820..f8fe3ed 100644 --- a/tests/t2203-server-post-receive-email-stable.sh +++ b/tests/t2203-server-post-receive-email-stable.sh @@ -35,6 +35,7 @@ test_expect_success 'merge in stable' ' git commit -a -m "move topic1" && git push origin topic1 && old_commit_hash=$(git rev-parse HEAD) && + old_commit_abbrev=$(git rev-parse --short HEAD) && # Move stable git checkout stable && @@ -58,8 +59,9 @@ test_expect_success 'merge in stable' ' new_commit_hash=$(git rev-parse HEAD) && new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) && + new_commit_abbrev=$(git rev-parse --short HEAD) && - interpolate ../t2203-1.txt 1.txt old_commit_hash new_commit_hash new_commit_date first_stable_hash second_stable_hash && + interpolate ../t2203-1.txt 1.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date first_stable_hash second_stable_hash && test_cmp 1.txt server/.git/refs.heads.topic1.out ' @@ -69,6 +71,7 @@ test_expect_success 'merge in stable with conflict' ' git commit -a -m "move topic1" && git push origin topic1 && old_commit_hash=$(git rev-parse HEAD) && + old_commit_abbrev=$(git rev-parse --short HEAD) && # Move stable git checkout stable && @@ -95,8 +98,9 @@ test_expect_success 'merge in stable with conflict' ' new_commit_hash=$(git rev-parse HEAD) && new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) && + new_commit_abbrev=$(git rev-parse --short HEAD) && - interpolate ../t2203-2.txt 2.txt old_commit_hash new_commit_hash new_commit_date first_stable_hash second_stable_hash && + interpolate ../t2203-2.txt 2.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date first_stable_hash second_stable_hash && test_cmp 2.txt server/.git/refs.heads.topic1.out ' -- 2.20.1