Skip to content

Disable save of global git config #253

@MarkRx

Description

@MarkRx

Description

JGit attempts to automatically save the user's .gitconfig file but this is not always desirable. In our CI/CD environment we set .gitconfig as immutable (+i in linux) to prevent builds from changing settings that may effect other builds. JGit will log the following error when it attempts to save.

I would like to be able to disable saving so that we only read from the user config and potentially make in-memory only config changes but never modify the underlying user config file.

Cannot save config file 'FileBasedConfig[/home/jenkins/.gitconfig]'
java.io.IOException: Cannot commit write to /home/jenkins/.gitconfig
 	at org.eclipse.jgit.storage.file.FileBasedConfig.save(FileBasedConfig.java:258)
 	at org.eclipse.jgit.util.FS$FileStoreAttributes.saveToConfig(FS.java:584)
 	at org.eclipse.jgit.util.FS$FileStoreAttributes.lambda$0(FS.java:364)
 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
 	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
 	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
 	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Motivation

Preventing saving of the user .gitconfig when using jgit.

Alternatives considered

None. The stack is printed to the logs but ignored.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions