Skip to content

Commit

Permalink
GlobalBuildInfo support packed-refs with work-tree (elastic#50791)
Browse files Browse the repository at this point in the history
The packed-refs support was using the original .git path, changed to use
the real .git directory after reference from worktree has been followed.

Relates elastic#47464
  • Loading branch information
henningandersen authored and SivagurunathanV committed Jan 21, 2020
1 parent c7f6de9 commit f04f7aa
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ public static String gitRevision(File rootDir) {
Path refFile = gitDir.resolve(refName);
if (Files.exists(refFile)) {
revision = readFirstLine(refFile);
} else if (Files.exists(dotGit.resolve("packed-refs"))) {
} else if (Files.exists(gitDir.resolve("packed-refs"))) {
// Check packed references for commit ID
Pattern p = Pattern.compile("^([a-f0-9]{40}) " + refName + "$");
try (Stream<String> lines = Files.lines(dotGit.resolve("packed-refs"))) {
try (Stream<String> lines = Files.lines(gitDir.resolve("packed-refs"))) {
revision = lines.map(p::matcher)
.filter(Matcher::matches)
.map(m -> m.group(1))
Expand Down

0 comments on commit f04f7aa

Please sign in to comment.