threads / discuss / 29479

How often does git calculate SHAs?

Subject: How often does git calculate SHAs?

## tl;dr

2 messages between Jan 30, 2012 and Jan 30, 2012.

replies: 1people: 2as markdown or json

Michael Cook· Jan 30, 2012, 14:25 UTC · lore
How often does git actually calculate a file's SHA?

`strace git status` shows that git stat'ed many files, but opened only a few. So I assume git has some heuristicsbased on the stat infofor when to recalculate the SHAs.

Any pointers to how I could have figured this out myself from looking at the source code would be appreciated. Google wasn't helpful.

Michael
-- 
Michael Cook, Raytheon BBN Technologies, www.bbn.com
Shawn Pearce· Jan 30, 2012, 14:59 UTC · re: Michael Cook · lore

Re: How often does git calculate SHAs?

On Mon, Jan 30, 2012 at 06:25, Michael Cook <mcook@bbn.com> wrote:
Show 8 quoted lines
> How often does git actually calculate a file's SHA?
>
> `strace git status` shows that git stat'ed many files, but opened only a
> few. So I assume git has some heuristicsbased on the stat infofor when to
> recalculate the SHAs.
>
> Any pointers to how I could have figured this out myself from looking at the
> source code would be appreciated. Google wasn't helpful.

During `git status` Git performs an lstat() of every file in the working tree. If the file matches stat structure data with the cache held in .git/index, Git assumes the file is unmodified.

Things Git are looking for is usually size, mtime, inode number, creation time, etc.

← back to recent threads