Skip to content

Identical files stored in multiple locations in working tree won't be populated after fetch #514

Closed

Description

@sinbad

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.

Activity

  1. technoweenie commented on Jul 23, 2015

    @technoweenie
    Contributor

    Blah, that sucks. Are you changing that OID/path map to a map[string][]string?

  2. sinbad commented on Jul 23, 2015

    @sinbad
    ContributorAuthor

    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.

  3. technoweenie commented on Jul 23, 2015

    @technoweenie
    Contributor

    Sounds good 🤘

  4. sinbad commented on Jul 27, 2015

    @sinbad
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions