From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH] Add a testcase for the safety of pull-policy='pull'.
Date: Sun, 25 Feb 2007 23:11:33 +0100 [thread overview]
Message-ID: <20070225220853.31361.7201.stgit@gandelf.nowhere.earth> (raw)
This testcase demonstrates a long-standing problem with the handling
of conflicts on a rewinding branch, when "stg pull" calls git-pull.
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
This is precisely the problem that made me believe using "git-pull"
was a wrong idea to start with. Since it seems there are uses for the
"git-pull" mode, this particular issue has to be addressed - I'm
however not sure how.
t/t2101-pull-policy-pull.sh | 60 ++++++++++++++++++++++++++++++++++
t/t2102-pull-policy-rebase.sh | 72 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 132 insertions(+), 0 deletions(-)
diff --git a/t/t2101-pull-policy-pull.sh b/t/t2101-pull-policy-pull.sh
new file mode 100755
index 0000000..368d7d4
--- /dev/null
+++ b/t/t2101-pull-policy-pull.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Yann Dirson
+#
+
+test_description='Excercise pull-policy "fetch-rebase".'
+
+. ./test-lib.sh
+
+# don't need this repo, but better not drop it, see t1100
+#rm -rf .git
+
+# Need a repo to clone
+test_create_repo upstream
+
+test_expect_success \
+ 'Setup upstream repo, clone it, and add patches to the clone' \
+ '
+ (cd upstream && stg init) &&
+ stg clone upstream clone &&
+ (cd clone &&
+ git repo-config branch.master.stgit.pull-policy pull &&
+ git repo-config --list &&
+ stg new c1 -m c1 &&
+ echo a > file && stg add file && stg refresh
+ )
+ '
+
+test_expect_success \
+ 'Add non-rewinding commit upstream and pull it from clone' \
+ '
+ (cd upstream && stg new u1 -m u1 &&
+ echo a > file2 && stg add file2 && stg refresh) &&
+ (cd clone && stg pull) &&
+ test -e clone/file2
+ '
+
+# note: with pre-1.5 Git the clone is not automatically recorded
+# as rewinding, and thus heads/origin is not moved, but the stack
+# is still correctly rebased
+
+test_expect_failure \
+ 'Rewind/rewrite upstream commit and pull it from clone, without --merged' \
+ '
+ (cd upstream && echo b >> file2 && stg refresh) &&
+ (cd clone && stg pull)
+ '
+
+test_expect_success \
+ 'Undo the conflicted pull' \
+ '(cd clone && stg push --undo)'
+
+test_expect_success \
+ 'Pull the rewinded commit, with --merged' \
+ '
+ (cd clone && stg pull --merged) &&
+ test `wc -l <clone/file2` = 2
+ '
+
+test_done
diff --git a/t/t2102-pull-policy-rebase.sh b/t/t2102-pull-policy-rebase.sh
new file mode 100755
index 0000000..e1398a3
--- /dev/null
+++ b/t/t2102-pull-policy-rebase.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Yann Dirson
+#
+
+test_description='Excercise pull-policy "fetch-rebase".'
+
+. ./test-lib.sh
+
+# don't need this repo, but better not drop it, see t1100
+#rm -rf .git
+
+# Need a repo to clone
+test_create_repo upstream
+
+test_expect_success \
+ 'Setup upstream repo, clone it, and add patches to the clone' \
+ '
+ (cd upstream && stg init) &&
+ stg clone upstream clone &&
+ (cd clone &&
+ git repo-config branch.master.stgit.pull-policy fetch-rebase &&
+ git repo-config --list &&
+ stg new c1 -m c1 &&
+ echo a > file && stg add file && stg refresh
+ )
+ '
+
+test_expect_success \
+ 'Add non-rewinding commit upstream and pull it from clone' \
+ '
+ (cd upstream && stg new u1 -m u1 &&
+ echo a > file2 && stg add file2 && stg refresh) &&
+ (cd clone && stg pull) &&
+ test -e clone/file2
+ '
+
+# note: with pre-1.5 Git the clone is not automatically recorded
+# as rewinding, and thus heads/origin is not moved, but the stack
+# is still correctly rebased
+test_expect_success \
+ 'Rewind/rewrite upstream commit and pull it from clone' \
+ '
+ (cd upstream && echo b >> file2 && stg refresh) &&
+ (cd clone && stg pull) &&
+ test `wc -l <clone/file2` = 2
+ '
+
+# this one ensures the guard against commits does not unduly trigger
+test_expect_success \
+ 'Rewind/rewrite upstream commit and fetch it from clone before pulling' \
+ '
+ (cd upstream && echo c >> file2 && stg refresh) &&
+ (cd clone && git fetch && stg pull) &&
+ test `wc -l <clone/file2` = 3
+ '
+
+# this one exercises the guard against commits
+# (use a new file to avoid mistaking a conflict for a success)
+test_expect_success \
+ 'New upstream commit and commit a patch in clone' \
+ '
+ (cd upstream && stg new u2 -m u2 &&
+ echo a > file3 && stg add file3 && stg refresh) &&
+ (cd clone && stg commit && stg new c2 -m c2 &&
+ echo a >> file && stg refresh)
+ '
+test_expect_failure \
+ 'Try to and commit a patch in clone' \
+ '(cd clone && stg pull)'
+
+test_done
next reply other threads:[~2007-02-25 22:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-25 22:11 Yann Dirson [this message]
2007-02-27 14:25 ` [PATCH] Add a testcase for the safety of pull-policy='pull' Catalin Marinas
2007-02-27 21:09 ` Yann Dirson
2007-02-27 23:38 ` Catalin Marinas
2007-02-28 21:48 ` Yann Dirson
2007-03-01 20:10 ` Yann Dirson
2007-03-06 22:37 ` Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070225220853.31361.7201.stgit@gandelf.nowhere.earth \
--to=ydirson@altern.org \
--cc=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).