Skip to content

Commit

Permalink
Merge pull request #74 from pauxus/reference-fix
Browse files Browse the repository at this point in the history
[JENKINS-21434] Git Client 1.5.0+ does not resolve reference
  • Loading branch information
ndeloof committed Jan 20, 2014
2 parents e6d5057 + 5b88253 commit 7b1a905
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
Expand Up @@ -311,13 +311,24 @@ public void execute() throws GitException, InterruptedException {
else if (!referencePath.isDirectory())
listener.error("Reference path is not a directory: " + reference);
else {
try {
File alternates = new File(workspace, ".git/objects/info/alternates");
PrintWriter w = new PrintWriter(alternates);
w.println(new File(referencePath, ".git/objects").getAbsolutePath());
w.close();
} catch (FileNotFoundException e) {
listener.error("Failed to setup reference");
// reference path can either be a normal or a base repository
File objectsPath = new File(referencePath, ".git/objects");
if (!objectsPath.isDirectory()) {
// reference path is bare repo
objectsPath = new File(referencePath, "objects");
}
if (!objectsPath.isDirectory())
listener.error("Reference path does not contain an objects directory (no git repo?): " + objectsPath);
else {
try {
File alternates = new File(workspace, ".git/objects/info/alternates");
PrintWriter w = new PrintWriter(alternates);
// git implementations on windows also use
w.println(objectsPath.getAbsolutePath().replace('\\', '/'));
w.close();
} catch (FileNotFoundException e) {
listener.error("Failed to setup reference");
}
}
}
}
Expand Down

0 comments on commit 7b1a905

Please sign in to comment.