From: Charles O'Farrell <charleso@charleso.org>
To: git@vger.kernel.org
Subject: [JGIT PATCH 1/4] Ensured that RefUpdate cannot delete current branch
Date: Sat, 23 Aug 2008 08:45:44 +1000 [thread overview]
Message-ID: <1219445147-6801-2-git-send-email-charleso@charleso.org> (raw)
In-Reply-To: <1219445147-6801-1-git-send-email-charleso@charleso.org>
If attempted it will return a REJECTED_CURRENT_BRANCH Result.
Signed-off-by: Charles O'Farrell <charleso@charleso.org>
---
.../src/org/spearce/jgit/lib/RefUpdate.java | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
index ca77b75..aa2cecb 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
@@ -110,6 +110,13 @@
REJECTED,
/**
+ * Rejected because trying to delete the current branch.
+ * <p>
+ * Has no meaning for update.
+ */
+ REJECTED_CURRENT_BRANCH,
+
+ /**
* The ref was probably not updated because of I/O error.
* <p>
* Unexpected I/O error occurred when writing new ref. Such error may
@@ -323,6 +330,9 @@ public Result update(final RevWalk walk) throws IOException {
* @throws IOException
*/
public Result delete() throws IOException {
+ if (name.substring(Constants.R_HEADS.length()).equals(
+ db.getRepository().getBranch()))
+ return Result.REJECTED_CURRENT_BRANCH;
try {
return updateImpl(new RevWalk(db.getRepository()),
new DeleteStore());
--
1.6.0.49.gea35
next prev parent reply other threads:[~2008-08-22 22:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-22 22:45 [JGIT PATCH 0/4] Branch deletion testing and bug fixes Charles O'Farrell
2008-08-22 22:45 ` Charles O'Farrell [this message]
2008-08-22 22:45 ` [JGIT PATCH 2/4] Fixed bug where RefUpdate didn't delete identical HEAD branch Charles O'Farrell
2008-08-22 22:45 ` [JGIT PATCH 3/4] Added test for RefUpdate branch deletion Charles O'Farrell
2008-08-22 22:45 ` [JGIT PATCH 4/4] Added extra javadoc for delete to significant RefUpdate results Charles O'Farrell
2008-08-22 23:26 ` [JGIT PATCH 3/4] Added test for RefUpdate branch deletion Shawn O. Pearce
2008-08-22 23:28 ` Robin Rosenberg
2008-08-22 23:31 ` Shawn O. Pearce
2008-08-22 23:22 ` [JGIT PATCH 1/4] Ensured that RefUpdate cannot delete current branch Shawn O. Pearce
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=1219445147-6801-2-git-send-email-charleso@charleso.org \
--to=charleso@charleso.org \
--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).