Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git config always changes the encoding of .git/config and ~/.gitconfig to value of _ENCODE_FILE_NEW #141

Open
Christopher-Chappell opened this issue Jan 13, 2025 · 2 comments

Comments

@Christopher-Chappell
Copy link

Introducing any git config commands into a Jenkins pipeline causes the next run that touches that repository to fail. Why? Because even if I chtag the config file to ISO8859-1, the moment git modifies it it goes back to IBM-1047.

Jenkins does not tolerate a git config file anywhere that is encoded IBM-1047. If it finds one, the pipeline fails with the following error:

Fetching changes from the remote Git repository
ERROR: Checkout failed
org.eclipse.jgit.errors.ConfigInvalidException: Invalid line in config file
	at PluginClassLoader for git-client//org.eclipse.jgit.lib.Config.fromTextRecurse(Config.java:1236)
	at PluginClassLoader for git-client//org.eclipse.jgit.lib.Config.fromText(Config.java:1164)
	at PluginClassLoader for git-client//org.eclipse.jgit.storage.file.FileBasedConfig.load(FileBasedConfig.java:164)
	at PluginClassLoader for git-client//org.eclipse.jgit.util.FileUtils.readWithRetries(FileUtils.java:733)
	at PluginClassLoader for git-client//org.eclipse.jgit.storage.file.FileBasedConfig.load(FileBasedConfig.java:128)

As you can imagine, I am interested in making sure that any git config files stay ISO8859-1.

@IgorTodorovskiIBM
Copy link
Collaborator

Is this only occurring within Jenkins or can you reproduce it manually with the same userid and environment variables?

What environment variables are being set currently?

It's very likely an environment variable setting as on my system it's still set as ISO8859-1:

[ITODORO@ZOSCAN2B ~/projects/protobuf_new]$ ls -lT ~/.gitconfig
t ISO8859-1   T=on  -rw-rw-r--   1 ITODORO  BASIC        570 Jan  8 06:47 /home/itodoro/.gitconfig
[ITODORO@ZOSCAN2B ~/projects/protobuf_new]$ git config  set --global core.filemode true
[ITODORO@ZOSCAN2B ~/projects/protobuf_new]$ ls -lT ~/.gitconfig
t ISO8859-1   T=on  -rw-rw-r--   1 ITODORO  BASIC        587 Jan 13 22:04 /home/itodoro/.gitconfig
[ITODORO@ZOSCAN2B ~/projects/protobuf_new]$ cat /home/itodoro/.gitconfig
[user]
        name = Igor Todorovski
  pager = less
        email = [email protected]
[core]
  editor = vim
        preloadIndex = false
        filemode = true

@Christopher-Chappell
Copy link
Author

Christopher-Chappell commented Jan 22, 2025

Looks like it's the _ENCODE_FILE_NEW variable:

chappc@/u/chappc/git/repo$ export _ENCODE_FILE_NEW=ISO8859-1
chappc@/u/chappc/git/repo$ git config core.editor nano
chappc@/u/chappc/git/repo$ ls -T .git
t ISO8859-1   T=on  FETCH_HEAD
t ISO8859-1   T=on  HEAD
t ISO8859-1   T=on  ORIG_HEAD
                    branches
t ISO8859-1   T=on  config
- untagged    T=off description
                    hooks
t ISO8859-1   T=on  index
                    info
                    logs
                    objects
t IBM-1047    T=on  packed-refs
                    refs
chappc@/u/chappc/git/repo$ export _ENCODE_FILE_NEW=IBM-1047 
chappc@/u/chappc/git/repo$ git config core.editor vim 
chappc@/u/chappc/git/repo$ ls -T .git
t ISO8859-1   T=on  FETCH_HEAD
t ISO8859-1   T=on  HEAD
t ISO8859-1   T=on  ORIG_HEAD
                    branches
t IBM-1047    T=on  config
- untagged    T=off description
                    hooks
t ISO8859-1   T=on  index
                    info
                    logs
                    objects
t IBM-1047    T=on  packed-refs
                    refs

@Christopher-Chappell Christopher-Chappell changed the title git config always changes the encoding of .git/config and ~/.gitconfig to IBM-1047 git config always changes the encoding of .git/config and ~/.gitconfig to value of _ENCODE_FILE_NEW Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants