Skip to content

Commit 977c36a

Browse files
committed
Revert config to previous value
1 parent 75e5007 commit 977c36a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/SetupMinecraftSources.kt

+15-3
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,26 @@ abstract class SetupMinecraftSources : JavaLauncherTask() {
217217
}
218218

219219
val upstream = Git.open(rootProjectDir.toFile())
220+
val upstreamConfig = upstream.repository.config
221+
val upstreamReachableSHA1 = upstreamConfig.getString("uploadpack", null, "allowreachablesha1inwant")
222+
val upstreamConfigContainsUploadPack = upstreamConfig.sections.contains("uploadpack")
220223
try {
221224
// Temporarily allow fetching reachable sha1 refs from the "upstream" paper repository.
222-
upstream.repository.config.setBoolean("uploadpack", null, "allowreachablesha1inwant", true);
223-
upstream.repository.config.save()
225+
upstreamConfig.setBoolean("uploadpack", null, "allowreachablesha1inwant", true)
226+
upstreamConfig.save()
224227
oldPaperGit.fetch().setDepth(1).setRemote("origin").setRefSpecs(oldPaperCommit.get()).call()
225228
oldPaperGit.reset().setMode(ResetCommand.ResetType.HARD).setRef(oldPaperCommit.get()).call()
226229
} finally {
227-
upstream.repository.config.unset("uploadpack", null, "allowreachablesha1inwant");
230+
if (upstreamReachableSHA1 == null) {
231+
if (upstreamConfigContainsUploadPack) {
232+
upstreamConfig.unset("uploadpack", null, "allowreachablesha1inwant")
233+
} else {
234+
upstreamConfig.unsetSection("uploadpack", null)
235+
}
236+
} else {
237+
upstreamConfig.setString("uploadpack", null, "allowreachablesha1inwant", upstreamReachableSHA1)
238+
}
239+
upstreamConfig.save()
228240
upstream.close()
229241
}
230242

0 commit comments

Comments
 (0)