git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fixes for recent stgit issues
@ 2007-03-11 21:44 Yann Dirson
  2007-03-11 21:44 ` [PATCH 1/2] Make 'stg cp' 2nd form safe Yann Dirson
  2007-03-11 21:44 ` [PATCH 2/2] Fixed t2102-pull-policy-rebase to really test 'rebase' policy Yann Dirson
  0 siblings, 2 replies; 3+ messages in thread
From: Yann Dirson @ 2007-03-11 21:44 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

The initial "stg cp" implementation was known to be inconsistent wrt
clobbering, this makes the unsafe case safe.  Also, a copy of the
policy=fetch-rebase testsuite crept as a fake policy=rebase one, so
here is a real one.

-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] Make 'stg cp' 2nd form safe.
  2007-03-11 21:44 [PATCH 0/2] Fixes for recent stgit issues Yann Dirson
@ 2007-03-11 21:44 ` Yann Dirson
  2007-03-11 21:44 ` [PATCH 2/2] Fixed t2102-pull-policy-rebase to really test 'rebase' policy Yann Dirson
  1 sibling, 0 replies; 3+ messages in thread
From: Yann Dirson @ 2007-03-11 21:44 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git




Signed-off-by: Yann Dirson <ydirson@altern.org>
---

 Documentation/stg-cp.txt |    9 +++++----
 stgit/git.py             |    9 +++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/Documentation/stg-cp.txt b/Documentation/stg-cp.txt
index f499309..723d811 100644
--- a/Documentation/stg-cp.txt
+++ b/Documentation/stg-cp.txt
@@ -35,10 +35,11 @@ file not known to Git will not be copied.
 CAVEATS
 -------
 
-The first form doesn't allow yet to overwrite an existing file
-(whether it could be recovered from Git or not), and the second form
-does not check before overwriting any file, possibly leading to loss
-of non-committed modifications.
+This command does not allow yet to overwrite an existing file (whether
+it could be recovered from Git or not).  Further more, when copying a
+directory, the second form does not allow to proceed if a directory by
+that name already exists inside the target, even when no file inside
+that directory would be overwritten.
 
 FUTURE OPTIONS
 --------------
diff --git a/stgit/git.py b/stgit/git.py
index 9129c92..f6d6b43 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -464,6 +464,15 @@ def copy(filespecs, target):
     if os.path.isdir(target):
         # target is a directory: copy each entry on the command line,
         # with the same name, into the target
+        target = target.rstrip('/')
+        
+        # first, check that none of the children of the target
+        # matching the command line aleady exist
+        for filespec in filespecs:
+            entry = target+ '/' + os.path.basename(filespec.rstrip('/'))
+            if os.path.exists(entry):
+                raise GitException, 'Target "%s" already exists' % entry
+        
         for filespec in filespecs:
             filespec = filespec.rstrip('/')
             basename = '/' + os.path.basename(filespec)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Fixed t2102-pull-policy-rebase to really test 'rebase' policy.
  2007-03-11 21:44 [PATCH 0/2] Fixes for recent stgit issues Yann Dirson
  2007-03-11 21:44 ` [PATCH 1/2] Make 'stg cp' 2nd form safe Yann Dirson
@ 2007-03-11 21:44 ` Yann Dirson
  1 sibling, 0 replies; 3+ messages in thread
From: Yann Dirson @ 2007-03-11 21:44 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git




Signed-off-by: Yann Dirson <ydirson@altern.org>
---

 t/t2102-pull-policy-rebase.sh |   79 ++++++++++++++++++-----------------------
 1 files changed, 35 insertions(+), 44 deletions(-)

diff --git a/t/t2102-pull-policy-rebase.sh b/t/t2102-pull-policy-rebase.sh
index e1398a3..41f8168 100755
--- a/t/t2102-pull-policy-rebase.sh
+++ b/t/t2102-pull-policy-rebase.sh
@@ -3,70 +3,61 @@
 # Copyright (c) 2007 Yann Dirson
 #
 
-test_description='Excercise pull-policy "fetch-rebase".'
+test_description='Excercise pull-policy "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' \
+    'Fork stack off parent branch, and add patches to the stack' \
     '
-    (cd upstream && stg new u1 -m u1 &&
-     echo a > file2 && stg add file2 && stg refresh) &&
-    (cd clone && stg pull) &&
-    test -e clone/file2
+    stg init &
+    git branch -m master parent &&
+    stg branch --create stack &&
+    git repo-config branch.stack.stgit.pull-policy rebase &&
+    git repo-config --list &&
+    stg new c1 -m c1 &&
+    echo a > file && stg add file && stg refresh
     '
 
-# 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' \
+    'Add non-rewinding commit in parent and pull the stack' \
     '
-    (cd upstream && echo b >> file2 && stg refresh) &&
-    (cd clone && stg pull) &&
-    test `wc -l <clone/file2` = 2
+    stg branch parent && stg new u1 -m u1 &&
+    echo b > file2 && stg add file2 && stg refresh &&
+    stg branch stack && stg pull &&
+    test -e file2
     '
 
-# 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' \
+    'Rewind/rewrite commit in parent and pull the stack' \
     '
-    (cd upstream && echo c >> file2 && stg refresh) &&
-    (cd clone && git fetch && stg pull) &&
-    test `wc -l <clone/file2` = 3
+    stg branch parent && echo b >> file2 && stg refresh &&
+    stg branch stack && stg pull &&
+    test `wc -l <file2` = 2
     '
 
 # 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' \
+    'New commit in parent and commit a patch in stack' \
     '
-    (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)
+    stg branch parent && stg new u2 -m u2 &&
+     echo c > file3 && stg add file3 && stg refresh &&
+    stg branch stack && 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)'
+    'Try to pull/rebase now that stack base has moved' \
+    'stg pull'
+
+test_expect_success \
+    'Force the pull/rebase, but do not push yet' \
+    'stg pull --force --nopush'
+test_expect_failure \
+    '...check we lost the committed patch' \
+    'test -e file'
+test_expect_failure \
+    '...and check we get a conflict while pushing' \
+    'stg push'
 
 test_done

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-11 21:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-11 21:44 [PATCH 0/2] Fixes for recent stgit issues Yann Dirson
2007-03-11 21:44 ` [PATCH 1/2] Make 'stg cp' 2nd form safe Yann Dirson
2007-03-11 21:44 ` [PATCH 2/2] Fixed t2102-pull-policy-rebase to really test 'rebase' policy Yann Dirson

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).