git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Shallow clones vs blame/log

From
Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Date
Mar 2, 2011, 19:51 UTC
Message-ID
<AANLkTim87tZTN4FGLgwCHdAJH4dum4wBXqA=GcQm-uJ=@mail.gmail.com>
Hi,

I'd like to confirm: when doing shallow clone with --depth=n, and then using blame, git does know only about n last revisions. For each change that happened before shows "^commit" where "commit" is n+1 commit ?

I wonder if this can be more clear. I was bitten by this today. I was using blame on a file and it showed a commit and author for a line. But the line was not changed in that commit. Took me a while to understand that it's caused by shallow copy...

I could be blamed for not reading git-blame man, but luckily ^commit is not described there ;)

Also, git-log puts all not cloned commits into last not cloned commit, and there's no information that it's a "fake" commit.

Example:
/tmp$ mkdir r && cd r && git init && echo a > a && git add a && git
commit -a -m first && echo b > b && git add b && git commit -a -m
second && echo aa >> a && git commit -a -m third && echo bb >> b &&
git commit -a -m fourth  && cd ..
warning: templates not found /home/piotr/share/git-core/templates
Initialized empty Git repository in /tmp/r/.git/
[master (root-commit) 890ec47] first
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a
[master f969fda] second
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 b
[master 20c3c2c] third
 1 files changed, 1 insertions(+), 0 deletions(-)
[master 9dcd745] fourth
 1 files changed, 1 insertions(+), 0 deletions(-)
/tmp$ DIR=clone1;  git clone --depth 1 file:///tmp/r $DIR && cd $DIR
&& git log --stat --oneline
Cloning into clone1...
warning: templates not found /home/piotr/share/git-core/templates
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (4/4), done.
Receiving objects: 100% (7/7), 515 bytes, done.
remote: Total 7 (delta 0), reused 0 (delta 0)
9dcd745 fourth
 b |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
20c3c2c third
 a |    2 ++
 b |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

/tmp/clone1$ git blame a ^20c3c2c (Piotr Krukowiecki 2011-03-02 20:42:53 +0100 1) a ^20c3c2c (Piotr Krukowiecki 2011-03-02 20:42:53 +0100 2) aa

/tmp/clone1$ git blame b ^20c3c2c (Piotr Krukowiecki 2011-03-02 20:42:53 +0100 1) b 9dcd7453 (Piotr Krukowiecki 2011-03-02 20:42:53 +0100 2) bb

Next: Jeff King
Message 1 of 2 in “Shallow clones vs blame/log”
  1. Piotr KrukowieckiMar 2, 2011
  2. Jeff KingMar 2, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.