]> source.dussan.org Git - jgit.git/commit
Treat CloneCommand.setRemote(null) as setRemote("origin") 77/49977/2
authorJonathan Nieder <jrn@google.com>
Wed, 10 Jun 2015 22:43:27 +0000 (15:43 -0700)
committerJonathan Nieder <jrn@google.com>
Thu, 11 Jun 2015 18:54:44 +0000 (11:54 -0700)
commitd2ade728a131995c97a65bcb7610b4675682826c
tree7446ab7c8dd32efcf6b3a208402afa33a977142c
parent24ab79ccaf5e3e8b3c2ef612afc398126b7c2d93
Treat CloneCommand.setRemote(null) as setRemote("origin")

A non-bare clone command with null remote produces a
NullPointerException when trying to produce a refspec to fetch against.

In a bare repository, a null remote name is accepted by mistake,
producing a configuration with items like 'remote.url' instead of
'remote.<remote>.url'.  This was never meant to work.

Instead, let's make setRemote(null) undo any previous setRemote calls
and re-set the remote name to DEFAULT_REMOTE, imitating C git clone's
--no-origin option.

While we're here, add some tests for setRemote working normally.

Change-Id: I76f502da5e677df501d3ef387e7f61f42a7ca238
Signed-off-by: Jonathan Nieder <jrn@google.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java