# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr@gmail.com>
# Date 1625843976 -7200
#      Fri Jul 09 17:19:36 2021 +0200
# Node ID 0db597e185a18fda06f49a3cfc74ab105434e21c
# Parent  a4b2ba5b5f45987c5756a563cffa0ca56d8350d6
tests: add test for a simple git rebase

We do this in both regular mode and with a suffix; the results are
subtly different.

diff --git a/tests/test-branch-bookmark-suffix.t b/tests/test-branch-bookmark-suffix.t
--- a/tests/test-branch-bookmark-suffix.t
+++ b/tests/test-branch-bookmark-suffix.t
@@ -8,14 +8,13 @@
 
   $ git init -q --bare repo.git
 
-#if with-path
   $ hg clone repo.git hgrepo
   updating to branch default
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-#else
-  $ hg init hgrepo
+  $ cd hgrepo
+#if without-path
+  $ rm .hg/hgrc
 #endif
-  $ cd hgrepo
   $ hg branch -q branch1
   $ hg bookmark branch1_bookmark
   $ echo f1 > f1
@@ -212,4 +211,74 @@
      date:        Mon Jan 01 00:00:10 2007 +0000
      summary:     add f1
   
+
   $ cd ..
+
+Now try pulling a diverged bookmark:
+
+  $ rm -r hgrepo
+#if with-path
+  $ hg clone -U repo.git hgrepo
+  importing 5 git commits
+  new changesets 40a840c1f8ae:faf44fc3a4e8 (5 drafts)
+#else
+  $ hg init hgrepo
+  $ hg -R hgrepo pull repo.git
+  pulling from repo.git
+  importing 5 git commits
+  new changesets 40a840c1f8ae:faf44fc3a4e8 (5 drafts)
+  (run 'hg heads' to see heads, 'hg merge' to merge)
+#endif
+  $ cd gitrepo
+  $ git checkout -q branch1
+  $ fn_git_rebase branch3
+  $ git push -f
+  To $TESTTMP/repo.git
+   + d8aef79...ce1d1c5 branch1 -> branch1 (forced update)
+  $ cd ../hgrepo
+  $ hg pull ../repo.git
+  pulling from ../repo.git
+  importing 1 git commits
+  new changesets 895d0307f8b7 (1 drafts)
+  (run 'hg update' to get a working copy)
+  $ hg log --graph
+  o  changeset:   5:895d0307f8b7
+  |  bookmark:    branch1_bookmark
+  |  tag:         default/branch1 (with-path !)
+  |  tag:         tip
+  |  user:        test <test@example.org>
+  |  date:        Mon Jan 01 00:00:12 2007 +0000
+  |  summary:     append f1
+  |
+  o  changeset:   4:faf44fc3a4e8
+  |  bookmark:    branch3_bookmark
+  |  tag:         default/branch3 (with-path !)
+  |  user:        test <test@example.org>
+  |  date:        Mon Jan 01 00:00:14 2007 +0000
+  |  summary:     append f3
+  |
+  o  changeset:   3:ae8eb55f7090
+  |  bookmark:    branch2_bookmark
+  |  tag:         default/branch2 (with-path !)
+  |  user:        test <test@example.org>
+  |  date:        Mon Jan 01 00:00:13 2007 +0000
+  |  summary:     append f2
+  |
+  o  changeset:   2:600de9b6d498
+  |  branch:      branch2
+  |  parent:      0:40a840c1f8ae
+  |  user:        test
+  |  date:        Mon Jan 01 00:00:11 2007 +0000
+  |  summary:     add f2
+  |
+  | o  changeset:   1:8211cade99e4
+  |/   user:        test <test@example.org>
+  |    date:        Mon Jan 01 00:00:12 2007 +0000
+  |    summary:     append f1
+  |
+  o  changeset:   0:40a840c1f8ae
+     branch:      branch1
+     user:        test
+     date:        Mon Jan 01 00:00:10 2007 +0000
+     summary:     add f1
+  
diff --git a/tests/test-pull-after-rebase.t b/tests/test-pull-after-rebase.t
--- a/tests/test-pull-after-rebase.t
+++ b/tests/test-pull-after-rebase.t
@@ -101,3 +101,59 @@
   |/   add beta
   o    0:ff7a2f2d8d7099694ae1e8b03838d40575bebb63
      add alpha
+
+  $ cd ..
+
+Now try rebasing that branch, from the Git side of things
+
+  $ cd gitrepo
+  $ git checkout -q otherbranch
+  $ fn_git_rebase --onto branch otherbranch
+  $ git push -f
+  To $TESTTMP/repo.git
+   + c4cfa5e...e5023f9 otherbranch -> otherbranch (forced update)
+  $ cd ..
+
+  $ cd hgrepo
+  $ hg pull
+  pulling from $TESTTMP/repo.git
+  no changes found
+  $ hg state
+  *  otherbranch tip 4:f4bd265a9d39e5c4da2c0a752de5ea70335199c5
+  |  add gamma
+  | @  branch default/branch 3:52def9937d74e43b83dfded6ce0e5adf731b9d22
+  | |  add gamma
+  x |   default/otherbranch 2:205a004356ef32b8da782afb89d9179d12ca31e9
+  | |  add gamma
+  | o  master default/master 1:7fe02317c63d9ee324d4b5df7c9296085162da1b
+  |/   add beta
+  o    0:ff7a2f2d8d7099694ae1e8b03838d40575bebb63
+     add alpha
+
+  $ cd ..
+
+And finally, delete it:
+
+  $ cd gitrepo
+  $ git push origin :otherbranch
+  To $TESTTMP/repo.git
+   - [deleted]         otherbranch
+  $ cd ..
+
+And pull that:
+
+  $ cd hgrepo
+  $ hg pull
+  pulling from $TESTTMP/repo.git
+  no changes found
+  $ hg state
+  *  otherbranch tip 4:f4bd265a9d39e5c4da2c0a752de5ea70335199c5
+  |  add gamma
+  | @  branch default/branch 3:52def9937d74e43b83dfded6ce0e5adf731b9d22
+  | |  add gamma
+  x |    2:205a004356ef32b8da782afb89d9179d12ca31e9
+  | |  add gamma
+  | o  master default/master 1:7fe02317c63d9ee324d4b5df7c9296085162da1b
+  |/   add beta
+  o    0:ff7a2f2d8d7099694ae1e8b03838d40575bebb63
+     add alpha