{"thread":{"id":"18434","subject":"[JGIT PATCH] Split refspecs on the last : not the first","startedAt":"2009-03-20T15:12:12Z","lastAt":"2009-03-20T15:12:12Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"108725","messageId":"1237561932-26482-1-git-send-email-spearce@spearce.org","threadId":"18434","inReplyTo":null,"subject":"[JGIT PATCH] Split refspecs on the last : not the first","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-20T15:12:12Z","receivedAt":"2009-03-20T15:12:12Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Recent discussion about a potential ':%branchname' syntax for\nremote branches led rise to the question on #git of whether or\nnot this could be used on the lhs of a push refspec, such as\n\"+:%master:master\".\n\nTesting shows git-core permits this, as it must be splitting the\nrefspec with strrchr(), splitting along the last : in the string.\nMake JGit match the split semantics.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../spearce/jgit/transport/RefSpecTestCase.java    |   12 ++++++++++++\n .../src/org/spearce/jgit/transport/RefSpec.java    |    2 +-\n 2 files changed, 13 insertions(+), 1 deletions(-)\n\ndiff --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\nindex 11e7cdb..2f7214c 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/RefSpecTestCase.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/RefSpecTestCase.java\n@@ -63,6 +63,18 @@ public void testMasterMaster() {\n \t\tassertFalse(rs.matchDestination(r));\n \t}\n \n+\tpublic void testSplitLastColon() {\n+\t\tfinal String lhs = \":m:a:i:n:t\";\n+\t\tfinal String rhs = \"refs/heads/maint\";\n+\t\tfinal RefSpec rs = new RefSpec(lhs + \":\" + rhs);\n+\t\tassertFalse(rs.isForceUpdate());\n+\t\tassertFalse(rs.isWildcard());\n+\t\tassertEquals(lhs, rs.getSource());\n+\t\tassertEquals(rhs, rs.getDestination());\n+\t\tassertEquals(lhs + \":\" + rhs, rs.toString());\n+\t\tassertEquals(rs, new RefSpec(rs.toString()));\n+\t}\n+\n \tpublic void testForceMasterMaster() {\n \t\tfinal String sn = \"refs/heads/master\";\n \t\tfinal RefSpec rs = new RefSpec(\"+\" + sn + \":\" + sn);\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java b/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java\nindex e75b272..273aacc 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java\n@@ -115,7 +115,7 @@ public RefSpec(final String spec) {\n \t\t\ts = s.substring(1);\n \t\t}\n \n-\t\tfinal int c = s.indexOf(':');\n+\t\tfinal int c = s.lastIndexOf(':');\n \t\tif (c == 0) {\n \t\t\ts = s.substring(1);\n \t\t\tif (isWildcard(s))\n-- \n1.6.2.1.352.gae594\n"}]}