Which git commands perform integrity checks?

前端 未结 2 427
盖世英雄少女心
盖世英雄少女心 2021-01-01 15:31

Trying to determine how quickly a user would be warned of corruption in the object database with git-1.7.4.1, I pulled a one-bit switcheroo:

$ git init repo
Initia         


        
2条回答
  •  不思量自难忘°
    2021-01-01 16:24

    Here's how I would go about finding this out, although I'm not going to go through each source file to work out the conditions under which the check is performed. :)

    Clone git's source code:

    git clone git://git.kernel.org/pub/scm/git/git.git
    

    Check out the version you care about:

    cd git
    git checkout v1.7.1
    

    Look for that error message:

    git grep 'sha1 mismatch'
    

    That leads you to object.c and the parse_object function. Now look for that function:

    git grep parse_object
    

    ... and go through the 38 files checking the conditions under which that function will be called.

提交回复
热议问题