diff options
author | Han-Wen Nienhuys <hanwen@google.com> | 2019-11-19 19:55:06 -0800 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-11-26 01:57:19 +0100 |
commit | e0744891fe233f1b78b55ea14675d5766d3ac321 (patch) | |
tree | 0a740be210a2bed416b1b74a4c14a98f0d029b02 /org.eclipse.jgit | |
parent | a48b77d7826bbc939185ee021906d82b6f4cb93e (diff) | |
download | jgit-e0744891fe233f1b78b55ea14675d5766d3ac321.tar.gz jgit-e0744891fe233f1b78b55ea14675d5766d3ac321.zip |
FileRepository: cleanup refs outside refs/ on reftable conversion
Change-Id: Iab7d3a08906e826e26572f534512a09d3a5876b0
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java index cb00fc4ef5..2f6ef51133 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java @@ -46,6 +46,8 @@ package org.eclipse.jgit.internal.storage.file; +import static java.util.stream.Collectors.toList; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -740,6 +742,10 @@ public class FileRepository extends Repository { File packedRefs = new File(getDirectory(), Constants.PACKED_REFS); File logsDir = new File(getDirectory(), Constants.LOGS); + + List<String> additional = getRefDatabase().getAdditionalRefs().stream() + .map(Ref::getName).collect(toList()); + additional.add(Constants.HEAD); if (backup) { FileUtils.rename(refsFile, new File(getDirectory(), "refs.old")); if (packedRefs.exists()) { @@ -750,10 +756,17 @@ public class FileRepository extends Repository { FileUtils.rename(logsDir, new File(getDirectory(), Constants.LOGS + ".old")); } + for (String r : additional) { + FileUtils.rename(new File(getDirectory(), r), + new File(getDirectory(), r + ".old")); + } } else { packedRefs.delete(); // ignore return value. FileUtils.delete(logsDir, FileUtils.RECURSIVE); FileUtils.delete(refsFile, FileUtils.RECURSIVE); + for (String r : additional) { + new File(getDirectory(), r).delete(); + } } // Put new data. |