{"thread":{"id":"3862","subject":"[PATCH 2/4] Add list of bugs to TODO","startedAt":"2006-04-13T21:38:19Z","lastAt":"2006-04-13T21:44:31Z","messageCount":5,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"18622","messageId":"20060413213819.8806.53300.stgit@gandelf.nowhere.earth","threadId":"3862","inReplyTo":null,"subject":"[PATCH 0/4] Add a testsuite to stgit (take 2)","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-04-13T21:38:19Z","receivedAt":"2006-04-13T21:38:19Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"This is an update of the previous patch series, including minor improvements\nto the way the test engine is adapted to stgit, as well as a new testsuite\ndemonstrating robustness issues on series creation, and proposed fixes for all\nthose bugs.  And hopefully more standard patches.\n\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"18623","messageId":"20060413214424.8806.84103.stgit@gandelf.nowhere.earth","threadId":"3862","inReplyTo":"20060413213819.8806.53300.stgit@gandelf.nowhere.earth","subject":"[PATCH 1/4] Add a testsuite framework copied from git-core","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-04-13T21:44:24Z","receivedAt":"2006-04-13T21:44:24Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"From: Yann Dirson <ydirson@altern.org>\n\nSee git's t/README for details on how to use this framework.\n\nThere is no integration yet in the toplevel Makefile, I'll let\npython masters take care of this.  Use \"make -C t\" to run the\ntests for now.\n\nA patch-naming policy should be defined for stgit, since the\ngit one does not apply.\n---\n\n TODO             |    2 -\n t/Makefile       |   25 ++++++\n t/t0000-dummy.sh |   19 +++++\n t/test-lib.sh    |  208 ++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 253 insertions(+), 1 deletions(-)\n\ndiff --git a/TODO b/TODO\nindex e5affe0..d97ffd1 100644\n--- a/TODO\n+++ b/TODO\n@@ -6,7 +6,7 @@ The TODO list until 1.0:\n - debian package support\n - man page\n - code execution allowed from templates\n-- regression tests\n+- more regression tests\n - release 1.0\n \n \ndiff --git a/t/Makefile b/t/Makefile\nnew file mode 100644\nindex 0000000..d5d7b6f\n--- /dev/null\n+++ b/t/Makefile\n@@ -0,0 +1,25 @@\n+# Run tests\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+#GIT_TEST_OPTS=--verbose --debug\n+SHELL_PATH ?= $(SHELL)\n+TAR ?= $(TAR)\n+\n+# Shell quote;\n+SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n+\n+T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)\n+\n+all: $(T) clean\n+\n+$(T):\n+\t@echo \"*** $@ ***\"; '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)\n+\n+clean:\n+\trm -fr trash\n+\n+.PHONY: $(T) clean\n+.NOPARALLEL:\n+\ndiff --git a/t/t0000-dummy.sh b/t/t0000-dummy.sh\nnew file mode 100755\nindex 0000000..8dc25d3\n--- /dev/null\n+++ b/t/t0000-dummy.sh\n@@ -0,0 +1,19 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Yann Dirson\n+#\n+\n+test_description='Dummy test.\n+\n+Only to test the testing environment.\n+'\n+\n+. ./test-lib.sh\n+\n+test_stg_init\n+\n+test_expect_success \\\n+    'check stgit can be run' \\\n+    'stg version'\n+\n+test_done\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nnew file mode 100755\nindex 0000000..2580bcc\n--- /dev/null\n+++ b/t/test-lib.sh\n@@ -0,0 +1,208 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+# Copyright (c) 2006 Yann Dirson\n+#\n+\n+# For repeatability, reset the environment to known value.\n+LANG=C\n+LC_ALL=C\n+PAGER=cat\n+TZ=UTC\n+export LANG LC_ALL PAGER TZ\n+unset AUTHOR_DATE\n+unset AUTHOR_EMAIL\n+unset AUTHOR_NAME\n+unset COMMIT_AUTHOR_EMAIL\n+unset COMMIT_AUTHOR_NAME\n+unset GIT_ALTERNATE_OBJECT_DIRECTORIES\n+unset GIT_AUTHOR_DATE\n+GIT_AUTHOR_EMAIL=author@example.com\n+GIT_AUTHOR_NAME='A U Thor'\n+unset GIT_COMMITTER_DATE\n+GIT_COMMITTER_EMAIL=committer@example.com\n+GIT_COMMITTER_NAME='C O Mitter'\n+unset GIT_DIFF_OPTS\n+unset GIT_DIR\n+unset GIT_EXTERNAL_DIFF\n+unset GIT_INDEX_FILE\n+unset GIT_OBJECT_DIRECTORY\n+unset SHA1_FILE_DIRECTORIES\n+unset SHA1_FILE_DIRECTORY\n+export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME\n+export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME\n+\n+# Each test should start with something like this, after copyright notices:\n+#\n+# test_description='Description of this test...\n+# This test checks if command xyzzy does the right thing...\n+# '\n+# . ./test-lib.sh\n+\n+error () {\n+\techo \"* error: $*\"\n+\ttrap - exit\n+\texit 1\n+}\n+\n+say () {\n+\techo \"* $*\"\n+}\n+\n+test \"${test_description}\" != \"\" ||\n+error \"Test script did not set test_description.\"\n+\n+while test \"$#\" -ne 0\n+do\n+\tcase \"$1\" in\n+\t-d|--d|--de|--deb|--debu|--debug)\n+\t\tdebug=t; shift ;;\n+\t-i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)\n+\t\timmediate=t; shift ;;\n+\t-h|--h|--he|--hel|--help)\n+\t\techo \"$test_description\"\n+\t\texit 0 ;;\n+\t-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)\n+\t\tverbose=t; shift ;;\n+\t*)\n+\t\tbreak ;;\n+\tesac\n+done\n+\n+exec 5>&1\n+if test \"$verbose\" = \"t\"\n+then\n+\texec 4>&2 3>&1\n+else\n+\texec 4>/dev/null 3>/dev/null\n+fi\n+\n+test_failure=0\n+test_count=0\n+\n+trap 'echo >&5 \"FATAL: Unexpected exit with code $?\"; exit 1' exit\n+\n+\n+# You are not expected to call test_ok_ and test_failure_ directly, use\n+# the text_expect_* functions instead.\n+\n+test_ok_ () {\n+\ttest_count=$(expr \"$test_count\" + 1)\n+\tsay \"  ok $test_count: $@\"\n+}\n+\n+test_failure_ () {\n+\ttest_count=$(expr \"$test_count\" + 1)\n+\ttest_failure=$(expr \"$test_failure\" + 1);\n+\tsay \"FAIL $test_count: $1\"\n+\tshift\n+\techo \"$@\" | sed -e 's/^/\t/'\n+\ttest \"$immediate\" = \"\" || { trap - exit; exit 1; }\n+}\n+\n+\n+test_debug () {\n+\ttest \"$debug\" = \"\" || eval \"$1\"\n+}\n+\n+test_run_ () {\n+\teval >&3 2>&4 \"$1\"\n+\teval_ret=\"$?\"\n+\treturn 0\n+}\n+\n+test_expect_failure () {\n+\ttest \"$#\" = 2 ||\n+\terror \"bug in the test script: not 2 parameters to test-expect-failure\"\n+\tsay >&3 \"expecting failure: $2\"\n+\ttest_run_ \"$2\"\n+\tif [ \"$?\" = 0 -a \"$eval_ret\" != 0 ]\n+\tthen\n+\t\ttest_ok_ \"$1\"\n+\telse\n+\t\ttest_failure_ \"$@\"\n+\tfi\n+}\n+\n+test_expect_success () {\n+\ttest \"$#\" = 2 ||\n+\terror \"bug in the test script: not 2 parameters to test-expect-success\"\n+\tsay >&3 \"expecting success: $2\"\n+\ttest_run_ \"$2\"\n+\tif [ \"$?\" = 0 -a \"$eval_ret\" = 0 ]\n+\tthen\n+\t\ttest_ok_ \"$1\"\n+\telse\n+\t\ttest_failure_ \"$@\"\n+\tfi\n+}\n+\n+test_expect_code () {\n+\ttest \"$#\" = 3 ||\n+\terror \"bug in the test script: not 3 parameters to test-expect-code\"\n+\tsay >&3 \"expecting exit code $1: $3\"\n+\ttest_run_ \"$3\"\n+\tif [ \"$?\" = 0 -a \"$eval_ret\" = \"$1\" ]\n+\tthen\n+\t\ttest_ok_ \"$2\"\n+\telse\n+\t\ttest_failure_ \"$@\"\n+\tfi\n+}\n+\n+# Most tests can use the created repository, but some amy need to create more.\n+# Usage: test_create_repo <directory>\n+test_create_repo () {\n+\ttest \"$#\" = 1 ||\n+\terror \"bug in the test script: not 1 parameter to test-create-repo\"\n+\towd=`pwd`\n+\trepo=\"$1\"\n+\tmkdir \"$repo\"\n+\tcd \"$repo\" || error \"Cannot setup test environment\"\n+\tgit-init-db 2>/dev/null ||\n+\terror \"cannot run git-init-db -- have you installed git-core?\"\n+\tmv .git/hooks .git/hooks-disabled\n+\tcd \"$owd\"\n+}\n+\n+test_stg_init () {\n+\techo \"empty start\" |\n+\tgit-commit-tree `git-write-tree` >.git/refs/heads/master 2>/dev/null ||\n+\terror \"cannot run git-commit -- is your git-core funtionning?\"\n+\tstg init ||\n+\terror \"cannot run stg init -- have you built things yet?\"\n+}\n+\n+test_done () {\n+\ttrap - exit\n+\tcase \"$test_failure\" in\n+\t0)\n+\t\t# We could:\n+\t\t# cd .. && rm -fr trash\n+\t\t# but that means we forbid any tests that use their own\n+\t\t# subdirectory from calling test_done without coming back\n+\t\t# to where they started from.\n+\t\t# The Makefile provided will clean this test area so\n+\t\t# we will leave things as they are.\n+\n+\t\tsay \"passed all $test_count test(s)\"\n+\t\texit 0 ;;\n+\n+\t*)\n+\t\tsay \"failed $test_failure among $test_count test(s)\"\n+\t\texit 1 ;;\n+\n+\tesac\n+}\n+\n+# Test the binaries we have just built.  The tests are kept in\n+# t/ subdirectory and are run in trash subdirectory.\n+PATH=$(pwd)/..:$PATH\n+export PATH\n+\n+\n+# Test repository\n+test=trash\n+rm -fr \"$test\"\n+test_create_repo $test\n+cd \"$test\"\n"},{"id":"18621","messageId":"20060413214426.8806.820.stgit@gandelf.nowhere.earth","threadId":"3862","inReplyTo":"20060413213819.8806.53300.stgit@gandelf.nowhere.earth","subject":"[PATCH 2/4] Add list of bugs to TODO","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-04-13T21:44:26Z","receivedAt":"2006-04-13T21:44:26Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"From: Yann Dirson <ydirson@altern.org>\n\nSince there is no formal place to register bugs, other than the git ml,\nI have added a couple of them, even mentionned on the ml, but which are\nstill around.\n---\n\n TODO |    9 +++++++++\n 1 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/TODO b/TODO\nindex d97ffd1..7dd099c 100644\n--- a/TODO\n+++ b/TODO\n@@ -17,3 +17,12 @@ The future, when time allows or if someo\n   synchronising with other patches (diff format or in other\n   repositories)\n - write bash-completion script for the StGIT commands\n+- support for branches with / in names\n+  (ml: \"Handle branch names with slashes\")\n+- \"pull\" argument should default to a sane value, \"origin\" is wrong in\n+  many cases\n+\n+Bugs:\n+\n+- the following commands break in subdirs:\n+  - refresh (ml: \"Running StGIT in subdirectories\")\n"},{"id":"18624","messageId":"20060413214428.8806.38365.stgit@gandelf.nowhere.earth","threadId":"3862","inReplyTo":"20060413213819.8806.53300.stgit@gandelf.nowhere.earth","subject":"[PATCH 3/4] Correctly handle refs/patches on series rename","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-04-13T21:44:28Z","receivedAt":"2006-04-13T21:44:28Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"From: Yann Dirson <ydirson@altern.org>\n\nWhen renaming a series, the refs/patches dir was not moved, and\nby chance a new one was created by the repository-upgrade code, but\nthat left the old one behind as cruft.\n\nAlso added a regression test to assert that nothing by the old name\nis left behind.\n---\n\n stgit/stack.py           |    2 ++\n t/t1001-branch-rename.sh |   33 +++++++++++++++++++++++++++++++++\n 2 files changed, 35 insertions(+), 0 deletions(-)\n\ndiff --git a/stgit/stack.py b/stgit/stack.py\nindex f4d7490..92407e7 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -497,6 +497,8 @@ class Series:\n             os.rename(self.__series_dir, to_stack.__series_dir)\n         if os.path.exists(self.__base_file):\n             os.rename(self.__base_file, to_stack.__base_file)\n+        if os.path.exists(self.__refs_dir):\n+            os.rename(self.__refs_dir, to_stack.__refs_dir)\n \n         self.__init__(to_name)\n \ndiff --git a/t/t1001-branch-rename.sh b/t/t1001-branch-rename.sh\nnew file mode 100755\nindex 0000000..65a5280\n--- /dev/null\n+++ b/t/t1001-branch-rename.sh\n@@ -0,0 +1,33 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Yann Dirson\n+#\n+\n+test_description='Branch operations.\n+\n+Exercises the \"stg branch\" commands.\n+'\n+\n+. ./test-lib.sh\n+\n+test_stg_init\n+\n+test_expect_success \\\n+    'Create an stgit branch from scratch' \\\n+    'stg branch -c foo &&\n+     stg new p1 -m \"p1\"\n+'\n+\n+test_expect_failure \\\n+    'Rename the current stgit branch' \\\n+    'stg branch -r foo bar\n+'\n+\n+test_expect_success \\\n+    'Rename an stgit branch' \\\n+    'stg branch -c buz &&\n+     stg branch -r foo bar &&\n+     test -z `find .git -name foo | tee /dev/stderr`\n+'\n+\n+test_done\n"},{"id":"18625","messageId":"20060413214431.8806.4177.stgit@gandelf.nowhere.earth","threadId":"3862","inReplyTo":"20060413213819.8806.53300.stgit@gandelf.nowhere.earth","subject":"[PATCH 4/4] Add a couple of safety checks to series creation","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-04-13T21:44:31Z","receivedAt":"2006-04-13T21:44:31Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"From: Yann Dirson <ydirson@altern.org>\n\nCheck first whether the operation can complete, instead of\nbombing out halfway.\n---\n\n stgit/commands/branch.py |    5 +++\n stgit/stack.py           |    7 ++++-\n t/t1000-branch-create.sh |   66 ++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 76 insertions(+), 2 deletions(-)\n\ndiff --git a/stgit/commands/branch.py b/stgit/commands/branch.py\nindex c4b5945..c95e529 100644\n--- a/stgit/commands/branch.py\n+++ b/stgit/commands/branch.py\n@@ -122,12 +122,15 @@ def func(parser, options, args):\n         check_conflicts()\n         check_head_top_equal()\n \n+        if git.branch_exists(args[0]):\n+            raise CmdException, 'Branch \"%s\" already exists' % args[0]\n+        \n         tree_id = None\n         if len(args) == 2:\n             tree_id = git_id(args[1])\n \n-        git.create_branch(args[0], tree_id)\n         stack.Series(args[0]).init()\n+        git.create_branch(args[0], tree_id)\n \n         print 'Branch \"%s\" created.' % args[0]\n         return\ndiff --git a/stgit/stack.py b/stgit/stack.py\nindex 92407e7..236e67f 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -431,8 +431,13 @@ class Series:\n         \"\"\"\n         bases_dir = os.path.join(self.__base_dir, 'refs', 'bases')\n \n-        if self.is_initialised():\n+        if os.path.exists(self.__patch_dir):\n             raise StackException, self.__patch_dir + ' already exists'\n+        if os.path.exists(self.__refs_dir):\n+            raise StackException, self.__refs_dir + ' already exists'\n+        if os.path.exists(self.__base_file):\n+            raise StackException, self.__base_file + ' already exists'\n+\n         os.makedirs(self.__patch_dir)\n \n         if not os.path.isdir(bases_dir):\ndiff --git a/t/t1000-branch-create.sh b/t/t1000-branch-create.sh\nnew file mode 100755\nindex 0000000..bee0b1c\n--- /dev/null\n+++ b/t/t1000-branch-create.sh\n@@ -0,0 +1,66 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Yann Dirson\n+#\n+\n+test_description='Branch operations.\n+\n+Exercises the \"stg branch\" commands.\n+'\n+\n+. ./test-lib.sh\n+\n+test_stg_init\n+\n+test_expect_failure \\\n+    'Try to create an stgit branch with a spurious refs/patches/ entry' \\\n+    'find .git -name foo | xargs rm -rf &&\n+     touch .git/refs/patches/foo &&\n+     stg branch -c foo\n+'\n+\n+test_expect_success \\\n+    'Check no part of the branch was created' \\\n+    'test \"`find .git -name foo | tee /dev/stderr`\" = \".git/refs/patches/foo\"\n+'\n+\n+\n+test_expect_failure \\\n+    'Try to create an stgit branch with a spurious patches/ entry' \\\n+    'find .git -name foo | xargs rm -rf &&\n+     touch .git/patches/foo &&\n+     stg branch -c foo\n+'\n+\n+test_expect_success \\\n+    'Check no part of the branch was created' \\\n+    'test \"`find .git -name foo | tee /dev/stderr`\" = \".git/patches/foo\"\n+'\n+\n+\n+test_expect_failure \\\n+    'Try to create an stgit branch with a spurious refs/bases/ entry' \\\n+    'find .git -name foo | xargs rm -rf &&\n+     touch .git/refs/bases/foo &&\n+     stg branch -c foo\n+'\n+\n+test_expect_success \\\n+    'Check no part of the branch was created' \\\n+    'test \"`find .git -name foo | tee /dev/stderr`\" = \".git/refs/bases/foo\"\n+'\n+\n+\n+# test_expect_failure \\\n+#     'Try to create an stgit branch with a spurious refs/heads/ entry' \\\n+#     'find .git -name foo | xargs rm -rf &&\n+#      touch .git/refs/heads/foo &&\n+#      stg branch -c foo\n+# '\n+\n+# test_expect_success \\\n+#     'Check no part of the branch was created' \\\n+#     'test \"`find .git -name foo | tee /dev/stderr`\" = \".git/refs/heads/foo\"\n+# '\n+\n+test_done\n"}]}