Skip to content

Add support for submodules in gitfs #120

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

Merged
merged 1 commit into from
Aug 13, 2025

Conversation

tianon
Copy link
Member

@tianon tianon commented Aug 12, 2025

For now, these emulate the support that git archive has for them (namely, that they present as empty directories, which are otherwise impossible to create/represent in Git).

@tianon tianon requested a review from yosifkit as a code owner August 12, 2025 20:28
@tianon
Copy link
Member Author

tianon commented Aug 12, 2025

Without this, trying to run sources.sh for my debuerreotype/debuerreotype image from the result of debuerreotype/debuerreotype#183 fails with:

template: --format:10:19: executing "--format" at <$.ArchGitChecksum>: error calling ArchGitChecksum: ".": Size("validate"): object not found

@tianon
Copy link
Member Author

tianon commented Aug 12, 2025

I applied this to my own builds and it worked successfully: tianon/bashbrew-tianon-meta@b491ee4#diff-b5258a02eeb8ebad56e128d41fdf1cc6b6bb9e5523199bcb868ee7076cbf2ea1

@tianon
Copy link
Member Author

tianon commented Aug 12, 2025

I did not verify that git archive produces the exact same reproducible output, however. I will do that.

For now, these emulate the support that `git archive` has for them (namely, that they present as empty directories, which are otherwise impossible to create/represent in Git).
@tianon
Copy link
Member Author

tianon commented Aug 12, 2025

I'm glad I explicitly tested it! It caught a bug. 😄

See tianon/bashbrew-tianon-meta@ce8717b#diff-b5258a02eeb8ebad56e128d41fdf1cc6b6bb9e5523199bcb868ee7076cbf2ea1 for where applying the latest fixed it.

`tar-scrubber.go`
package main

import (
	"archive/tar"
	"io"
	"os"
)

func main() {
	in := tar.NewReader(os.Stdin)

	out := tar.NewWriter(os.Stdout)
	defer out.Flush() // note: flush instead of close to avoid the empty block at EOF

	var zero tar.Header

	for {
		hdr, err := in.Next()
		if err == io.EOF {
			break
		}
		if err != nil {
			panic(err)
		}
		hdr.Uid = zero.Uid
		hdr.Gid = zero.Gid
		hdr.Uname = zero.Uname
		hdr.Gname = zero.Gname
		hdr.ModTime = zero.ModTime
		hdr.AccessTime = zero.AccessTime
		hdr.ChangeTime = zero.ChangeTime
		if err := out.WriteHeader(hdr); err != nil {
			panic(err)
		}
		if _, err := io.Copy(out, in); err != nil {
			panic(err)
		}
	}
}
$ git archive --format=tar d12af8e5556e39f82082b44628288e2eb27d4c34:./ | go run ./tar-scrubber.go | sha256sum
3af10ded9c88b401f84baf4c72ad4d4dc3a72f614c4704e863b1d79e49c88faa  -
    "reproducibleGitChecksum": "3af10ded9c88b401f84baf4c72ad4d4dc3a72f614c4704e863b1d79e49c88faa",

@tianon tianon merged commit 5e4f19f into docker-library:master Aug 13, 2025
7 checks passed
@tianon tianon deleted the gitfs-submodules branch August 13, 2025 16:35
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