Tree contains duplicate file entries

前端 未结 3 507
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 10:03

After some issues with our hosting, we decided to move our Git repository to GitHub. So I cloned the repository and tried pushing that to GitHub. However, I stumbled upon so

3条回答
  •  抹茶落季
    2020-12-03 10:23

    Note: Git 2.1 will add two option to git replace which can be useful when modifying a corrupted entry in a git repo:

    • commit 4e4b125 by Christian Couder (chriscool)

      --edit

    Edit an object's content interactively. The existing content for is pretty-printed into a temporary file, an editor is launched on the file, and the result is parsed to create a new object of the same type as .
    A replacement ref is then created to replace with the newly created object.
    See git-var for details about how the editor will be chosen.

    And commit 2deda62 by Jeff King (peff):

    replace: add a --raw mode for --edit

    One of the purposes of "git replace --edit" is to help a user repair objects which are malformed or corrupted.
    Usually we pretty-print trees with "ls-tree", which is much easier to work with than the raw binary data.

    However, some forms of corruption break the tree-walker, in which case our pretty-printing fails, rendering "--edit" useless for the user.

    This patch introduces a "--raw" option, which lets you edit the binary data in these instances.

    Knowing how Jeff is used to debug Git (like in this case), I am not too surprised to see this option.


    Note that before Git 2.27 (Q2 2020), "git fsck" ensured that the paths recorded in tree objects were sorted and without duplicates, but it failed to notice a case where a blob is followed by entries that sort before a tree with the same name.

    This has been corrected.

    See commit 9068cfb (10 May 2020) by René Scharfe (rscharfe).
    (Merged by Junio C Hamano -- gitster -- in commit 0498840, 14 May 2020)

    fsck: report non-consecutive duplicate names in trees

    Suggested-by: Brandon Williams
    Original-test-by: Brandon Williams
    Signed-off-by: René Scharfe
    Reviewed-by: Luke Diamand

    Tree entries are sorted in path order, meaning that directory names get a slash ('/') appended implicitly.

    Git fsck checks if trees contains consecutive duplicates, but due to that ordering there can be non-consecutive duplicates as well if one of them is a directory and the other one isn't.

    Such a tree cannot be fully checked out.

    Find these duplicates by recording candidate file names on a stack and check candidate directory names against that stack to find matches.

    提交回复
    热议问题