* [JGIT PATCH] Split refspecs on the last : not the first
@ 2009-03-20 15:12 Shawn O. Pearce
0 siblings, 0 replies; only message in thread
From: Shawn O. Pearce @ 2009-03-20 15:12 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
Recent discussion about a potential ':%branchname' syntax for
remote branches led rise to the question on #git of whether or
not this could be used on the lhs of a push refspec, such as
"+:%master:master".
Testing shows git-core permits this, as it must be splitting the
refspec with strrchr(), splitting along the last : in the string.
Make JGit match the split semantics.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../spearce/jgit/transport/RefSpecTestCase.java | 12 ++++++++++++
.../src/org/spearce/jgit/transport/RefSpec.java | 2 +-
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/RefSpecTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/RefSpecTestCase.java
index 11e7cdb..2f7214c 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/RefSpecTestCase.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/RefSpecTestCase.java
@@ -63,6 +63,18 @@ public void testMasterMaster() {
assertFalse(rs.matchDestination(r));
}
+ public void testSplitLastColon() {
+ final String lhs = ":m:a:i:n:t";
+ final String rhs = "refs/heads/maint";
+ final RefSpec rs = new RefSpec(lhs + ":" + rhs);
+ assertFalse(rs.isForceUpdate());
+ assertFalse(rs.isWildcard());
+ assertEquals(lhs, rs.getSource());
+ assertEquals(rhs, rs.getDestination());
+ assertEquals(lhs + ":" + rhs, rs.toString());
+ assertEquals(rs, new RefSpec(rs.toString()));
+ }
+
public void testForceMasterMaster() {
final String sn = "refs/heads/master";
final RefSpec rs = new RefSpec("+" + sn + ":" + sn);
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java b/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java
index e75b272..273aacc 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java
@@ -115,7 +115,7 @@ public RefSpec(final String spec) {
s = s.substring(1);
}
- final int c = s.indexOf(':');
+ final int c = s.lastIndexOf(':');
if (c == 0) {
s = s.substring(1);
if (isWildcard(s))
--
1.6.2.1.352.gae594
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-03-20 15:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-20 15:12 [JGIT PATCH] Split refspecs on the last : not the first Shawn O. Pearce
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).