Test rewind and rewind and continue even though we don't allow them.
authorStephen Haberman <stephen@exigencecorp.com>
Thu, 21 Aug 2008 05:18:32 +0000 (00:18 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Thu, 21 Aug 2008 05:18:32 +0000 (00:18 -0500)
The email script should have full coverage now--refactoring can commence.

tests/t2202-2.txt
tests/t2202-5.txt [new file with mode: 0644]
tests/t2202-6.txt [new file with mode: 0644]
tests/t2202-server-post-receive-email-branches.sh

index d556be0..e116118 100644 (file)
@@ -10,7 +10,7 @@ The branch, topic has been deleted
        was  $old_commit_hash
 
 -----------------------------------------------------------------------
-$old_commit_hash update branch with existing commits does not replay them on topic
+$old_commit_hash rewind and continue branch on topic
 -----------------------------------------------------------------------
 
 
diff --git a/tests/t2202-5.txt b/tests/t2202-5.txt
new file mode 100644 (file)
index 0000000..5aece3f
--- /dev/null
@@ -0,0 +1,39 @@
+From: author@payflex.com
+To: commits@list.com
+Subject: [cbas] topic branch updated. $new_commit_hash
+X-Git-Refname: refs/heads/topic
+X-Git-Reftype: branch
+X-Git-Oldrev: $old_commit_hash
+X-Git-Newrev: $new_commit_hash
+
+The branch, topic has been updated
+  discards  $old_commit_hash (commit)
+
+This update discarded existing revisions and left the branch pointing at
+a previous point in the repository history.
+
+ * -- * -- N ($new_commit_hash)
+            \
+             O -- O -- O ($old_commit_hash)
+
+The removed revisions are not necessarilly gone - if another reference
+still refers to them they will stay in the repository.
+
+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
+
+
+hooks/post-receive
+--
+cbas
diff --git a/tests/t2202-6.txt b/tests/t2202-6.txt
new file mode 100644 (file)
index 0000000..8b93e3b
--- /dev/null
@@ -0,0 +1,54 @@
+From: author@payflex.com
+To: commits@list.com
+Subject: [cbas] topic branch updated. $new_commit_hash
+X-Git-Refname: refs/heads/topic
+X-Git-Reftype: branch
+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)
+
+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
+situation occurs when you --force push a change and generate a repository
+containing something like this:
+
+ * -- * -- B -- O -- O -- O ($old_commit_hash)
+            \
+             N -- N -- N ($new_commit_hash)
+
+When this happens we assume that you've already had alert emails for all
+of the O revisions, and so we here report only the revisions in the N
+branch from the common base, B.
+
+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 <author@example.com>
+Date:   $new_commit_date
+
+    rewind and continue branch on topic
+
+-----------------------------------------------------------------------
+
+Summary of changes:
+ a |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/a b/a
+index 8516a40..a30ab5b 100644
+--- a/a
++++ b/a
+@@ -1 +1 @@
+-create branch 2
++rewind and continue branch
+
+
+hooks/post-receive
+--
+cbas
index b98c37e..f6239de 100644 (file)
@@ -69,6 +69,33 @@ test_expect_success 'update branch with existing commits does not replay them' '
        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) &&
+
+       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 &&
+       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) &&
+
+       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_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 &&
+       test_cmp 6.txt server/.git/refs.heads.topic.out
+'
+
 test_expect_success 'delete branch' '
        old_commit_hash=$(git rev-parse HEAD) &&
        git push origin :refs/heads/topic &&