Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kayoch1n
Copy link
Contributor

@kayoch1n kayoch1n commented Nov 3, 2025

This PR tries to implement the core.filemode related to the Windows issue 771. In this PR, the core.filemode option in config will be honored and only take effect during hash comparison. When an index entry is an
executable and core.filemode is false, a mode value of 0644 will be used for hashing purposes—while the actual mode value stored in the index remains unchanged.

It is true by default and hence the actual mode value will be used in hash.

AFAIK, C git will automatically set this option before init/clone, and git init results in a value of false by default on Windows. Unlike C git, there is no such auto detection in go-git by now. For windows users, if they want to use go-git to init or clone a repo on disk, they should explicitly set this config option and flush the config to disk.

    repository, err := git.PlainInit(repositoryPath, false)
	if err != nil {
		// error handling
	}
	cfg, err := repository.Config()
	if err != nil {
		// error handling
	}
	cfg.Core.FileMode = false
	err = repository.SetConfig(cfg)
	if err != nil {
		// error handling
	}

@kayoch1n kayoch1n changed the title git: worktree, implement core.filemode. Fixes #711 git: worktree, implement core.filemode. Fixes #771 Nov 9, 2025
@kayoch1n
Copy link
Contributor Author

kayoch1n commented Nov 9, 2025

Hi @pjbgf , would you mind taking a look at this PR when you have a moment?

Copy link
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kayoch1n thanks for proposing these changes. 🙇

@kayoch1n kayoch1n requested a review from pjbgf November 13, 2025 16:58
@kayoch1n kayoch1n changed the title git: worktree, implement core.filemode. Fixes #771 git: worktree, implement core.filemode. Related to #771 Nov 14, 2025
Copy link
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kayoch1n Thanks for working on this. 🙇

@pjbgf pjbgf merged commit 39ccc56 into go-git:main Nov 16, 2025
21 of 24 checks passed
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

Successfully merging this pull request may close these issues.

2 participants