From: Catalin Marinas Date: Fri, 2 Nov 2007 21:25:58 +0000 (+0000) Subject: Allow "branch --create" to be given a tag id X-Git-Tag: v0.14~36 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/42cd003ef2a190ec7f32068676d831ef6478c39f Allow "branch --create" to be given a tag id In the past, this used to lead to a broken branch which could be difficult to even delete. This patch allows the branch to be created properly and be more tolerant to branch deletion. Signed-off-by: Catalin Marinas --- diff --git a/stgit/commands/branch.py b/stgit/commands/branch.py index cbb97f6..a18ef2a 100644 --- a/stgit/commands/branch.py +++ b/stgit/commands/branch.py @@ -141,7 +141,7 @@ def func(parser, options, args): # exception in branch = rev_parse() leaves branchpoint unbound branchpoint = None - tree_id = branchpoint or git_id(crt_series, args[1]) + tree_id = git_id(crt_series, branchpoint or args[1]) if parentbranch: out.info('Recording "%s" as parent branch' % parentbranch) diff --git a/stgit/stack.py b/stgit/stack.py index ad1ed2b..f72f83b 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -166,10 +166,17 @@ class Patch(StgitObject): self.create_empty_field('top') def delete(self): - for f in os.listdir(self._dir()): - os.remove(os.path.join(self._dir(), f)) - os.rmdir(self._dir()) - git.delete_ref(self.__top_ref) + if os.path.isdir(self._dir()): + for f in os.listdir(self._dir()): + os.remove(os.path.join(self._dir(), f)) + os.rmdir(self._dir()) + else: + out.warn('Patch directory "%s" does not exist' % self._dir()) + try: + # the reference might not exist if the repository was corrupted + git.delete_ref(self.__top_ref) + except git.GitException, e: + out.warn(str(e)) if git.ref_exists(self.__log_ref): git.delete_ref(self.__log_ref)