You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Identical files stored in multiple locations in working tree won't be populated after fetch #514
I spotted this while working on the fetch extensions. The existing fetch uses a watch on the download queue (just OIDs) but then has to map that OID to a file path to smudge it. It does that via a single map from OID to file path.
However if at any time the same file content is present in more than one location in the working tree, after download only one of those files will be populated with the real content. Most likely this will affect codebases with template files and not be that common but it could lead to some head scratches.
I am fixing this while working on #490 - logged here separately in case anyone ever encounters it.
Changing it to map[string][]*lfs.WrappedPointer as I refactor it, this is useful for implementing pull now fetch/checkout are in separate commands and may be useful elsewhere. Also putting some extra checks in checkout so it won't ever overwrite any user-modified data; only writes when file is missing or is a pointer with matching OID.
There's actually a deeper issue here in that the ScanRefs function doesn't support multiple copies of the same content in multiple paths, it will only ever return the first one.
This is because it calls revListShas, which uses git rev-list --objects, which will only ever return a blob sha once and only list the first file that refers to it.
For checkout, I need that to be different. To avoid unintended consequences I'll implement that in a new function called ScanTree to reflect that it scans on a tree-unique basis rather than blob-unique. Instead of using 3 commands like ScanRefs - git rev-list --objects, git cat-file --batch-check and git cat-file --batch, I will instead use git ls-tree -r -l (-l reports size, so same as --batch-check) then feed that into git cat-file --batch.
I'm not sure if this distinction may be useful elsewhere, I'll only use it for checkout to start with.
Activity
technoweenie commentedon Jul 23, 2015
Blah, that sucks. Are you changing that OID/path map to a
map[string][]string?sinbad commentedon Jul 23, 2015
Changing it to map[string][]*lfs.WrappedPointer as I refactor it, this is useful for implementing pull now fetch/checkout are in separate commands and may be useful elsewhere. Also putting some extra checks in checkout so it won't ever overwrite any user-modified data; only writes when file is missing or is a pointer with matching OID.
technoweenie commentedon Jul 23, 2015
Sounds good 🤘
sinbad commentedon Jul 27, 2015
There's actually a deeper issue here in that the ScanRefs function doesn't support multiple copies of the same content in multiple paths, it will only ever return the first one.
This is because it calls revListShas, which uses
git rev-list --objects, which will only ever return a blob sha once and only list the first file that refers to it.For checkout, I need that to be different. To avoid unintended consequences I'll implement that in a new function called ScanTree to reflect that it scans on a tree-unique basis rather than blob-unique. Instead of using 3 commands like ScanRefs -
git rev-list --objects,git cat-file --batch-checkandgit cat-file --batch, I will instead usegit ls-tree -r -l(-l reports size, so same as --batch-check) then feed that intogit cat-file --batch.I'm not sure if this distinction may be useful elsewhere, I'll only use it for checkout to start with.