From: Robin Rosenberg <robin.rosenberg.lists@dewire.com>
To: tomi.pakarinen@iki.fi
Cc: spearce@spearce.org, git@vger.kernel.org
Subject: [JGIT PATCH] Detect repository states according to post Git 1.5
Date: Tue, 21 Oct 2008 22:13:42 +0200 [thread overview]
Message-ID: <200810212213.42294.robin.rosenberg.lists@dewire.com> (raw)
In-Reply-To: <f299b4f30810211109q7f2919f2r1d5cd8faf0048154@mail.gmail.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
Seems we need this patch too in order to detect repository states. The new
resolution is more granular that before, though I suggest that one should
be restrictive when interpreting the state and not assume that these states
are the only ones. The methods on RepositoryState are the /only/ valid
ways of deciding what to, or not to, do. This implies we need to extend this
class somewhat, but I'm no hurry yet so we can think about what methods
we need.
.../src/org/spearce/jgit/lib/Repository.java | 17 +++++++++++++
.../src/org/spearce/jgit/lib/RepositoryState.java | 25 +++++++++++++++++++-
2 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index dfce1b8..26748e2 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -1017,14 +1017,31 @@ public GitIndex getIndex() throws IOException {
* @return an important state
*/
public RepositoryState getRepositoryState() {
+ // Pre Git-1.6 logic
if (new File(getWorkDir(), ".dotest").exists())
return RepositoryState.REBASING;
if (new File(gitDir,".dotest-merge").exists())
return RepositoryState.REBASING_INTERACTIVE;
+
+ // From 1.6 onwards
+ if (new File(getDirectory(),"rebase-apply/rebasing").exists())
+ return RepositoryState.REBASING_REBASING;
+ if (new File(getDirectory(),"rebase-apply/applying").exists())
+ return RepositoryState.APPLY;
+ if (new File(getDirectory(),"rebase-apply").exists())
+ return RepositoryState.REBASING;
+
+ if (new File(getDirectory(),"rebase-merge/interactive").exists())
+ return RepositoryState.REBASING_INTERACTIVE;
+ if (new File(getDirectory(),"rebase-merge").exists())
+ return RepositoryState.REBASING_MERGE;
+
+ // Both versions
if (new File(gitDir,"MERGE_HEAD").exists())
return RepositoryState.MERGING;
if (new File(gitDir,"BISECT_LOG").exists())
return RepositoryState.BISECTING;
+
return RepositoryState.SAFE;
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryState.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryState.java
index c32c381..a916924 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryState.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryState.java
@@ -40,6 +40,9 @@
/**
* Important state of the repository that affects what can and cannot bed
* done. This is things like unhandled conflicted merges and unfinished rebase.
+ *
+ * The granularity and set of states are somewhat arbitrary. The methods
+ * on the state are the only supported means of deciding what to do.
*/
public enum RepositoryState {
/**
@@ -62,7 +65,7 @@
},
/**
- * An unfinished rebase. Must resolve, skip or abort before normal work can take place
+ * An unfinished rebase or am. Must resolve, skip or abort before normal work can take place
*/
REBASING {
public boolean canCheckout() { return false; }
@@ -72,6 +75,26 @@
},
/**
+ * An unfinished rebase. Must resolve, skip or abort before normal work can take place
+ */
+ REBASING_REBASING {
+ public boolean canCheckout() { return false; }
+ public boolean canResetHead() { return false; }
+ public boolean canCommit() { return true; }
+ public String getDescription() { return "Rebase"; }
+ },
+
+ /**
+ * An unfinished apply. Must resolve, skip or abort before normal work can take place
+ */
+ APPLY {
+ public boolean canCheckout() { return false; }
+ public boolean canResetHead() { return false; }
+ public boolean canCommit() { return true; }
+ public String getDescription() { return "Apply mailbox"; }
+ },
+
+ /**
* An unfinished rebase with merge. Must resolve, skip or abort before normal work can take place
*/
REBASING_MERGE {
--
1.6.0.2.308.gef4a
prev parent reply other threads:[~2008-10-21 20:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-20 19:06 [EGIT PATCH] git property page for project properties Tomi Pakarinen
2008-10-21 5:37 ` Robin Rosenberg
2008-10-21 17:50 ` Robin Rosenberg
2008-10-21 18:09 ` Tomi Pakarinen
2008-10-21 19:13 ` Robin Rosenberg
2008-10-21 20:13 ` Robin Rosenberg [this message]
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=200810212213.42294.robin.rosenberg.lists@dewire.com \
--to=robin.rosenberg.lists@dewire.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
--cc=tomi.pakarinen@iki.fi \
/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).