|
|
@ -13,17 +13,17 @@ |
|
|
|
* conditions are met: |
|
|
|
* conditions are met: |
|
|
|
* |
|
|
|
* |
|
|
|
* - Redistributions of source code must retain the above copyright |
|
|
|
* - Redistributions of source code must retain the above copyright |
|
|
|
* notice, this list of conditions and the following disclaimer. |
|
|
|
* notice, this list of conditions and the following disclaimer. |
|
|
|
* |
|
|
|
* |
|
|
|
* - Redistributions in binary form must reproduce the above |
|
|
|
* - Redistributions in binary form must reproduce the above |
|
|
|
* copyright notice, this list of conditions and the following |
|
|
|
* copyright notice, this list of conditions and the following |
|
|
|
* disclaimer in the documentation and/or other materials provided |
|
|
|
* disclaimer in the documentation and/or other materials provided |
|
|
|
* with the distribution. |
|
|
|
* with the distribution. |
|
|
|
* |
|
|
|
* |
|
|
|
* - Neither the name of the Eclipse Foundation, Inc. nor the |
|
|
|
* - Neither the name of the Eclipse Foundation, Inc. nor the |
|
|
|
* names of its contributors may be used to endorse or promote |
|
|
|
* names of its contributors may be used to endorse or promote |
|
|
|
* products derived from this software without specific prior |
|
|
|
* products derived from this software without specific prior |
|
|
|
* written permission. |
|
|
|
* written permission. |
|
|
|
* |
|
|
|
* |
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
|
@ -43,7 +43,9 @@ |
|
|
|
package org.eclipse.jgit.transport; |
|
|
|
package org.eclipse.jgit.transport; |
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
|
|
|
|
import static org.junit.Assert.fail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.eclipse.jgit.errors.PackProtocolException; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
|
@ -57,14 +59,34 @@ public class BaseReceivePackTest { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void parseCommand() { |
|
|
|
public void parseCommand() throws Exception { |
|
|
|
String input = "0000000000000000000000000000000000000000" |
|
|
|
String o = "0000000000000000000000000000000000000000"; |
|
|
|
+ " deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" |
|
|
|
String n = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; |
|
|
|
+ " refs/heads/master"; |
|
|
|
String r = "refs/heads/master"; |
|
|
|
ReceiveCommand cmd = BaseReceivePack.parseCommand(input); |
|
|
|
ReceiveCommand cmd = BaseReceivePack.parseCommand(o + " " + n + " " + r); |
|
|
|
assertEquals(ObjectId.zeroId(), cmd.getOldId()); |
|
|
|
assertEquals(ObjectId.zeroId(), cmd.getOldId()); |
|
|
|
assertEquals("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", |
|
|
|
assertEquals("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", |
|
|
|
cmd.getNewId().name()); |
|
|
|
cmd.getNewId().name()); |
|
|
|
assertEquals("refs/heads/master", cmd.getRefName()); |
|
|
|
assertEquals("refs/heads/master", cmd.getRefName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertParseCommandFails(null); |
|
|
|
|
|
|
|
assertParseCommandFails(""); |
|
|
|
|
|
|
|
assertParseCommandFails(o.substring(35) + " " + n.substring(35) |
|
|
|
|
|
|
|
+ " " + r + "\n"); |
|
|
|
|
|
|
|
assertParseCommandFails(o + " " + n + " " + r + "\n"); |
|
|
|
|
|
|
|
assertParseCommandFails(o + " " + n + " " + "refs^foo"); |
|
|
|
|
|
|
|
assertParseCommandFails(o + " " + n.substring(10) + " " + r); |
|
|
|
|
|
|
|
assertParseCommandFails(o.substring(10) + " " + n + " " + r); |
|
|
|
|
|
|
|
assertParseCommandFails("X" + o.substring(1) + " " + n + " " + r); |
|
|
|
|
|
|
|
assertParseCommandFails(o + " " + "X" + n.substring(1) + " " + r); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void assertParseCommandFails(String input) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
BaseReceivePack.parseCommand(input); |
|
|
|
|
|
|
|
fail(); |
|
|
|
|
|
|
|
} catch (PackProtocolException e) { |
|
|
|
|
|
|
|
// Expected.
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|