* stg branch --delete doesn't work
@ 2007-09-21 4:40 Aneesh Kumar
2007-09-21 9:48 ` Karl Hasselström
0 siblings, 1 reply; 7+ messages in thread
From: Aneesh Kumar @ 2007-09-21 4:40 UTC (permalink / raw)
To: Git Mailing List, catalin.marinas
[review@linux-review-ext4]$ git checkout master
Switched to branch "master"
[master@linux-review-ext4]$ stg branch --delete --force review
Deleting branch "review" ...
fatal: Needed a single revision
stg branch: refs/heads/review does not exist
And it leaves in .git/config
[branch "test2.stgit"]
stackformatversion = 2
So a later stg init also fails.
-aneesh
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: stg branch --delete doesn't work
2007-09-21 4:40 stg branch --delete doesn't work Aneesh Kumar
@ 2007-09-21 9:48 ` Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 0/4] Fix "stg branch --delete" Karl Hasselström
0 siblings, 1 reply; 7+ messages in thread
From: Karl Hasselström @ 2007-09-21 9:48 UTC (permalink / raw)
To: Aneesh Kumar; +Cc: Git Mailing List, catalin.marinas
On 2007-09-21 10:10:45 +0530, Aneesh Kumar wrote:
> [review@linux-review-ext4]$ git checkout master
> Switched to branch "master"
> [master@linux-review-ext4]$ stg branch --delete --force review
> Deleting branch "review" ...
> fatal: Needed a single revision
> stg branch: refs/heads/review does not exist
>
> And it leaves in .git/config
> [branch "test2.stgit"]
> stackformatversion = 2
>
> So a later stg init also fails.
Ow! You'd think we'd have a test for that ...
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 7+ messages in thread
* [StGit PATCH 0/4] Fix "stg branch --delete"
2007-09-21 9:48 ` Karl Hasselström
@ 2007-09-22 8:46 ` Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 1/4] Don't special-case the "master" branch during branch delete Karl Hasselström
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Karl Hasselström @ 2007-09-22 8:46 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git, Aneesh Kumar
This fixes the two issues Aneesh reported (failed branch deletion,
leftover config stuff), and adds a test. The test is added after the
fixes this time, so the test suite passes at every step.
Also available from
git://repo.or.cz/stgit/kha.git safe
---
Karl Hasselström (4):
Add simple test for "stg branch --delete"
Properly remove all config for a deleted branch
Don't try to delete the branch twice
Don't special-case the "master" branch during branch delete
stgit/commands/branch.py | 10 +---------
stgit/config.py | 7 +++++++
stgit/stack.py | 9 ++-------
t/t1005-branch-delete.sh | 29 +++++++++++++++++++++++++++++
4 files changed, 39 insertions(+), 16 deletions(-)
create mode 100755 t/t1005-branch-delete.sh
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 7+ messages in thread
* [StGit PATCH 1/4] Don't special-case the "master" branch during branch delete
2007-09-22 8:46 ` [StGit PATCH 0/4] Fix "stg branch --delete" Karl Hasselström
@ 2007-09-22 8:46 ` Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 2/4] Don't try to delete the branch twice Karl Hasselström
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Karl Hasselström @ 2007-09-22 8:46 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git, Aneesh Kumar, Karl Hasselström
It's unintuitive, unsymmetric and doesn't work if there is no
"master". Instead, prohibit deletion of the current branch.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/commands/branch.py | 11 ++---------
1 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/stgit/commands/branch.py b/stgit/commands/branch.py
index 2d491d5..8c99936 100644
--- a/stgit/commands/branch.py
+++ b/stgit/commands/branch.py
@@ -96,17 +96,10 @@ def __delete_branch(doomed_name, force = False):
out.start('Deleting branch "%s"' % doomed_name)
if __is_current_branch(doomed_name):
- check_local_changes()
- check_conflicts()
- check_head_top_equal()
-
- if doomed_name != 'master':
- git.switch_branch('master')
+ raise CmdException('Cannot delete the current branch')
doomed.delete(force)
-
- if doomed_name != 'master':
- git.delete_branch(doomed_name)
+ git.delete_branch(doomed_name)
out.done()
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [StGit PATCH 2/4] Don't try to delete the branch twice
2007-09-22 8:46 ` [StGit PATCH 0/4] Fix "stg branch --delete" Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 1/4] Don't special-case the "master" branch during branch delete Karl Hasselström
@ 2007-09-22 8:46 ` Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 3/4] Properly remove all config for a deleted branch Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 4/4] Add simple test for "stg branch --delete" Karl Hasselström
3 siblings, 0 replies; 7+ messages in thread
From: Karl Hasselström @ 2007-09-22 8:46 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git, Aneesh Kumar, Karl Hasselström
We already delete it in Stack.delete(), so don't do it here too.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/commands/branch.py | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/stgit/commands/branch.py b/stgit/commands/branch.py
index 8c99936..c16fc69 100644
--- a/stgit/commands/branch.py
+++ b/stgit/commands/branch.py
@@ -99,7 +99,6 @@ def __delete_branch(doomed_name, force = False):
raise CmdException('Cannot delete the current branch')
doomed.delete(force)
- git.delete_branch(doomed_name)
out.done()
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [StGit PATCH 3/4] Properly remove all config for a deleted branch
2007-09-22 8:46 ` [StGit PATCH 0/4] Fix "stg branch --delete" Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 1/4] Don't special-case the "master" branch during branch delete Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 2/4] Don't try to delete the branch twice Karl Hasselström
@ 2007-09-22 8:46 ` Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 4/4] Add simple test for "stg branch --delete" Karl Hasselström
3 siblings, 0 replies; 7+ messages in thread
From: Karl Hasselström @ 2007-09-22 8:46 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git, Aneesh Kumar, Karl Hasselström
This uses "git-config --remove-section", which was first released in
git 1.5.1-rc1. I'm not sure if this is later than what we used to
depend on; we already use "git-config --rename-section", but that's
been in since git 1.5.0-rc0.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/config.py | 7 +++++++
stgit/stack.py | 9 ++-------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/stgit/config.py b/stgit/config.py
index 799e1d7..51818bd 100644
--- a/stgit/config.py
+++ b/stgit/config.py
@@ -76,6 +76,13 @@ class GitConfig:
).returns([0, 1]).run()
self.__cache.clear()
+ def remove_section(self, name):
+ """Remove a section in the config file. Silently do nothing if
+ the section doesn't exist."""
+ Run('git-repo-config', '--remove-section', name
+ ).returns([0, 1]).discard_stderr().discard_output()
+ self.__cache.clear()
+
def set(self, name, value):
Run('git-repo-config', name, value).run()
self.__cache[name] = value
diff --git a/stgit/stack.py b/stgit/stack.py
index d6f6a6e..adfff25 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -744,13 +744,8 @@ class Series(PatchSet):
except GitException:
out.warn('Could not delete branch "%s"' % self.get_name())
- # Cleanup parent informations
- # FIXME: should one day make use of git-config --section-remove,
- # scheduled for 1.5.1
- config.unset('branch.%s.remote' % self.get_name())
- config.unset('branch.%s.merge' % self.get_name())
- config.unset('branch.%s.stgit.parentbranch' % self.get_name())
- config.unset(self.format_version_key())
+ config.remove_section('branch.%s' % self.get_name())
+ config.remove_section('branch.%s.stgit' % self.get_name())
def refresh_patch(self, files = None, message = None, edit = False,
show_patch = False,
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [StGit PATCH 4/4] Add simple test for "stg branch --delete"
2007-09-22 8:46 ` [StGit PATCH 0/4] Fix "stg branch --delete" Karl Hasselström
` (2 preceding siblings ...)
2007-09-22 8:46 ` [StGit PATCH 3/4] Properly remove all config for a deleted branch Karl Hasselström
@ 2007-09-22 8:46 ` Karl Hasselström
3 siblings, 0 replies; 7+ messages in thread
From: Karl Hasselström @ 2007-09-22 8:46 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git, Aneesh Kumar, Karl Hasselström
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
t/t1005-branch-delete.sh | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
create mode 100755 t/t1005-branch-delete.sh
diff --git a/t/t1005-branch-delete.sh b/t/t1005-branch-delete.sh
new file mode 100755
index 0000000..7a0872e
--- /dev/null
+++ b/t/t1005-branch-delete.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+test_description='Attempt to delete branches'
+
+. ./test-lib.sh
+
+stg init
+
+test_expect_success 'Create a branch (and switch to it)' '
+ stg branch --create foo
+ '
+
+test_expect_success 'Delete a branch' '
+ stg branch --delete master
+ '
+
+test_expect_success 'Make sure the branch ref was deleted' '
+ [ -z "$(git show-ref | grep master | tee /dev/stderr)" ]
+ '
+
+test_expect_success 'Make sure the branch config was deleted' '
+ [ -z "$(git config -l | grep branch\\.master | tee /dev/stderr)" ]
+ '
+
+test_expect_success 'Make sure the branch files were deleted' '
+ [ -z "$(find .git -type f | grep master | tee /dev/stderr)" ]
+ '
+
+test_done
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-09-22 8:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-21 4:40 stg branch --delete doesn't work Aneesh Kumar
2007-09-21 9:48 ` Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 0/4] Fix "stg branch --delete" Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 1/4] Don't special-case the "master" branch during branch delete Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 2/4] Don't try to delete the branch twice Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 3/4] Properly remove all config for a deleted branch Karl Hasselström
2007-09-22 8:46 ` [StGit PATCH 4/4] Add simple test for "stg branch --delete" Karl Hasselström
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).