# How often does git calculate SHAs?

2 messages from 2012-01-30 to 2012-01-30. Participants: Michael Cook, Shawn Pearce.
Thread: https://gitlist.dev/t/29479

## Michael Cook, 2012-01-30 14:25

Subject: How often does git calculate SHAs?
Message-ID: <4F26A864.1080702@bbn.com>
URL: https://gitlist.dev/e/4F26A864.1080702%40bbn.com

```
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, 2012-01-30 14:59

Subject: Re: How often does git calculate SHAs?
Message-ID: <CAJo=hJtEPTPTwdoFaoZH4OBpfnCR3VDUNGdNtCprmPf=13xrdQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAJo%3DhJtEPTPTwdoFaoZH4OBpfnCR3VDUNGdNtCprmPf%3D13xrdQ%40mail.gmail.com
In-Reply-To: <4F26A864.1080702@bbn.com>

```
On Mon, Jan 30, 2012 at 06:25, Michael Cook <mcook@bbn.com> wrote:
> 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.

```
