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.PlainCloneContext doesn't obey umask. #1371

Open
james-lawrence opened this issue Jan 7, 2025 · 4 comments · May be fixed by go-git/go-billy#104
Open

git.PlainCloneContext doesn't obey umask. #1371

james-lawrence opened this issue Jan 7, 2025 · 4 comments · May be fixed by go-git/go-billy#104
Labels
enhancement New feature or request help wanted Extra attention is needed no-autoclose Issues/PRs to be ignored by stale bot
Milestone

Comments

@james-lawrence
Copy link

calling the following with umask 0002 I expected the creation of a directory that matches gits behavior.

	_, err = git.PlainCloneContext(ctx, dir, false, &git.CloneOptions{
		URL:               uri,
		ReferenceName:     branchRefName,
		RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
		Auth:              auth,
		SingleBranch:      true,
	})

git command for comparison.

umask 0002
git clone [email protected]:egdaemon/eg.git gitcmd

results:

ls -lha clone/
total 16K
drwxrwxr-x  4 user user 4.0K Jan  7 13:49 .
drwxrwx--- 26 user user 4.0K Jan  7 13:49 ..
drwxrwxr-x 24 user user 4.0K Jan  7 13:48 gitcmd
drwxr-xr-x 24 user user 4.0K Jan  7 13:45 golanglib
@pjbgf pjbgf added enhancement New feature or request help wanted Extra attention is needed labels Jan 8, 2025
@pjbgf pjbgf added this to the v6.0.0 milestone Jan 8, 2025
@pjbgf pjbgf added the no-autoclose Issues/PRs to be ignored by stale bot label Jan 8, 2025
@BeChris
Copy link
Contributor

BeChris commented Jan 10, 2025

Hello @james-lawrence ,
Are the results from canonical git or Got-Git ?
Could you provide ls -lha clone/ for both "git clone" and call to "git.PlainCloneContext()" so that we can notice what is different between the two.

@james-lawrence
Copy link
Author

the results above are from canonical git (gitcmd) and go-git (golanglib). if you want the full tree i can try to get that this weekend im pretty packed atm.

@BeChris
Copy link
Contributor

BeChris commented Jan 12, 2025

Hello @james-lawrence , I think pull request go-git/go-billy#104 will align Go-Git with canonical Git regarding permissions on directories.
Unfortunately, there are also some differences regarding files.

Here's what I get for each clone after having called umask 0002:
With Go-Git:

-rw-r--r--  LICENSE
-rw-r--r--  README.md

With canonical Git:

-rw-rw-r--  LICENSE
-rw-rw-r--  README.md

I tried to fix it locally but then TestCheckoutBisect() Go-Git test no more passes due to Go-Git now wrongly identifying some files to have unexpected permissions.
So the story is not yet finished.

@james-lawrence
Copy link
Author

james-lawrence commented Jan 12, 2025

yeah, I suspect the abstraction of go-billy is part of the problem, golang should handle this type of thing natively. os.Mkdirs certainly does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed no-autoclose Issues/PRs to be ignored by stale bot
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants