With git ls-tree
I can get hash of some content inside repository by its commit.
Like:
git ls-tree HEAD path1 --object-only
hash1
git ls-tree HEAD path2 --object-only
hash2
Is there a way to aggregate hash that would represent all those paths (path1, path2) as a single hash instead of multiple?
If path2
is inside path1
, then it nicely aggregates and I only need to specify path1
, but if path2
is a sibling, I don't see a way to aggregate it. I could create combination of a string like hash1-hash2
, but if there are many sibling paths, it would get pretty long fast.
Or maybe there is some other technique to get hash of multiples sibling paths in some aggregated hash?
Update
For example given this files/folders structure within git repo:
my-repo/
other/
src/
my-file1.txt
my-file2.txt
I want to have aggregated hash for src
and two extra files my-file1.txt
and my-file2.txt
. So if any of those change, I would get new hash. Now I can't use parent dir as hash because I don't want to include other
directory. Also git ls-tree
does not allow to use repo root dir as a path (in this case my-repo
).
I was able to workaround this by creating hard links to sibling files.
Like:
cd src
ln ../my-file1.txt my-file1.txt
ln ../my-file2.txt my-file2.txt
Its not ideal, but I had only few such files, so its not that big of a problem.
Also note, symbolic links won't work, because git ls-tree
ignores it as it sees changes on real files only.