Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Support ignoring chmod changes on filesystems that do not support chmod (e.g. FAT) #378

Open
osklyar opened this issue May 5, 2017 · 7 comments

Comments

@osklyar
Copy link

osklyar commented May 5, 2017

There is a common Windows issue with Unix executables in it: cloning those in Windows leads to differences between the filesystem and the git index because Windows reports 10644 for Unix 10755 files. The standard git client permits ignoring such differences transparently via the following config option: git config core.fileMode false. A similar option is required for go-git otherwise it is very difficult to work with repositories containing Unix executables.

More info on the behaviour of the standard git client can be found here: http://stackoverflow.com/questions/1580596

A particular example of what happens on the go-git client is then found in the following earlier issue (which I will close in favour of this one for clarity): #373

Up to now I failed to find where the index tree is read from the cloned file. If you give me a couple of hints where to search I would be happy to work on a patch.

@smola
Copy link
Collaborator

smola commented May 8, 2017

The configuration option would need to be added to the config parsing:

Core struct {

Index is read in plumbing/format/index/decoder.go, but I don't think we should change the way index is decoded for this.

Maybe we could fix this by modifying Worktree.Add here, so that based on Config we can add some conditional behavior to ignore executable bit on file mode:

e.Mode, err = filemode.NewFromOSFileMode(info.Mode())

@tyru
Copy link

tyru commented Nov 11, 2017

Sorry if this is not right place to report this.
But maybe this problem is related to this issue.
so I want this feature very much!

Problem

I just want to do git pull.
but after I manually run git reset --hard HEAD~ in command-line,
Worktree.Pull() returns "worktree contains unstagged changes" error.

My environment is Windows Subsystem Linux (WSL).
But this is maybe common problem on Windows.

Here is steps to reproduce:

  1. cd {repo}
    • {repo} is under /mnt/c/...
    • In WSL, /mnt/c is C drive
    • If I run git diff HEAD in that repository, I get the following result:
$ git diff HEAD
diff --git a/README.md b/README.md
old mode 100644
new mode 100755

2. git reset --hard HEAD~
3. Compile this code and run ./git-pull {repo} (git-pull is compiled command of that code)

@thehowl
Copy link
Contributor

thehowl commented Sep 20, 2018

Hey, I was trying to work on this and managed to get it work for as far as staged files are concerned. However, when it comes to unstaged files, the Merkletrie package directly gets the file mode and compares it with the one in the index (this is not a problem with a staged file because we can change its git mode when it is added to the index).

I'm not super-knowledgeable on the codebase, so I would like to ask how do you think it's best to approach this? Passing down the config file to merkletrie doesn't sound like a good idea.

EDIT: I can also submit a WIP PR if you want.

@rojer
Copy link

rojer commented Sep 26, 2018

+1 on this, @thehowl please share your changes, it might work for me in the mean time...

@rojer
Copy link

rojer commented Sep 26, 2018

i should also add that despite what the title says, it doesn't just apply to FAT volumes, it doesn't work on NTFS either, which means pretty much everywhere.
fwiw, windows Git clones repos with filemode = false by default. go-git should do the same (once it's implemented, of course).

@thehowl
Copy link
Contributor

thehowl commented Sep 27, 2018

@rojer see #970

cesantabot pushed a commit to cesanta/mos-tool that referenced this issue Sep 27, 2018
On Windows, go-git has an issue with executable files - src-d/go-git#378
It is a pretty serious one for us because it leaves deps dirty and effectively never updated.

For now, we add a kludge that ignores files commonly marked as executable (and thus appearing dirty).

CL: mos: Prefer shell Git if available, fix cleanness check on Windows

PUBLISHED_FROM=e688dc21a216472b4a0743220bd4f4ebda05c51f
@hulucc
Copy link

hulucc commented Jan 4, 2020

Any update on this? really need this for windows.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants