{"thread":{"id":"26639","subject":"Shallow clones vs blame/log","startedAt":"2011-03-02T19:51:27Z","lastAt":"2011-03-02T21:58:08Z","messageCount":2,"participants":["Piotr Krukowiecki","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"162663","messageId":"AANLkTim87tZTN4FGLgwCHdAJH4dum4wBXqA=GcQm-uJ=@mail.gmail.com","threadId":"26639","inReplyTo":null,"subject":"Shallow clones vs blame/log","fromName":"Piotr Krukowiecki","fromEmail":"piotr.krukowiecki@gmail.com","sentAt":"2011-03-02T19:51:27Z","receivedAt":"2011-03-02T19:51:27Z","isPatch":false,"sender":{"key":"piotr.krukowiecki@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3259959?v=4"},"body":"Hi,\n\nI'd like to confirm: when doing shallow clone with --depth=n, and then\nusing blame,\ngit does know only about n last revisions. For each change that happened before\nshows \"^commit\" where \"commit\" is n+1 commit ?\n\nI wonder if this can be more clear. I was bitten by this today. I was\nusing blame\non a file and it showed a commit and author for a line. But the line\nwas not changed\nin that commit. Took me a while to understand that it's caused by\nshallow copy...\n\nI could be blamed for not reading git-blame man, but luckily ^commit is not\ndescribed there ;)\n\nAlso, git-log puts all not cloned commits into last not cloned commit,\nand there's no\ninformation that it's a \"fake\" commit.\n\n\nExample:\n\n/tmp$ mkdir r && cd r && git init && echo a > a && git add a && git\ncommit -a -m first && echo b > b && git add b && git commit -a -m\nsecond && echo aa >> a && git commit -a -m third && echo bb >> b &&\ngit commit -a -m fourth  && cd ..\nwarning: templates not found /home/piotr/share/git-core/templates\nInitialized empty Git repository in /tmp/r/.git/\n[master (root-commit) 890ec47] first\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 a\n[master f969fda] second\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 b\n[master 20c3c2c] third\n 1 files changed, 1 insertions(+), 0 deletions(-)\n[master 9dcd745] fourth\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\n/tmp$ DIR=clone1;  git clone --depth 1 file:///tmp/r $DIR && cd $DIR\n&& git log --stat --oneline\nCloning into clone1...\nwarning: templates not found /home/piotr/share/git-core/templates\nremote: Counting objects: 7, done.\nremote: Compressing objects: 100% (4/4), done.\nReceiving objects: 100% (7/7), 515 bytes, done.\nremote: Total 7 (delta 0), reused 0 (delta 0)\n9dcd745 fourth\n b |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n20c3c2c third\n a |    2 ++\n b |    1 +\n 2 files changed, 3 insertions(+), 0 deletions(-)\n\n/tmp/clone1$ git blame a\n^20c3c2c (Piotr Krukowiecki 2011-03-02 20:42:53 +0100 1) a\n^20c3c2c (Piotr Krukowiecki 2011-03-02 20:42:53 +0100 2) aa\n\n/tmp/clone1$ git blame b\n^20c3c2c (Piotr Krukowiecki 2011-03-02 20:42:53 +0100 1) b\n9dcd7453 (Piotr Krukowiecki 2011-03-02 20:42:53 +0100 2) bb\n"},{"id":"162683","messageId":"20110302215808.GI20400@sigill.intra.peff.net","threadId":"26639","inReplyTo":"AANLkTim87tZTN4FGLgwCHdAJH4dum4wBXqA=GcQm-uJ=@mail.gmail.com","subject":"Re: Shallow clones vs blame/log","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-03-02T21:58:08Z","receivedAt":"2011-03-02T21:58:08Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 02, 2011 at 08:51:27PM +0100, Piotr Krukowiecki wrote:\n\n> I'd like to confirm: when doing shallow clone with --depth=n, and then\n> using blame, git does know only about n last revisions. For each\n> change that happened before shows \"^commit\" where \"commit\" is n+1\n> commit ?\n> \n> I wonder if this can be more clear. I was bitten by this today. I was\n> using blame on a file and it showed a commit and author for a line.\n> But the line was not changed in that commit. Took me a while to\n> understand that it's caused by shallow copy...\n\nIt's not just shallow copy, but any time you have limited the traversal.\nSo you could do \"git blame v1.5.0..v1.6.0 wt-status.c\", and lines that\ncome from v1.5.0 or before are attributed to v1.5.0 with the carat.\n\nThe magic name for this is \"boundary commits\". See the \"-b\" option for\nan alternative way of viewing them.\n\n> I could be blamed for not reading git-blame man, but luckily ^commit is not\n> described there ;)\n\nYes, we seem not to describe the regular output in very much detail at\nall (nor mention the \"^\" syntax in the description of porcelain output),\nwhich we probably should.\n\nWe do mention in the \"specifying ranges\" section that unchanged lines\nwill be blamed to the boundary commit. Part of the problem is that you\ndidn't realize you had a range because you were using a shallow clone.\nBut I wonder if that information would be more appropriate when\nintroducing shallow clones in git-clone(1).\n\n> Also, git-log puts all not cloned commits into last not cloned commit,\n> and there's no information that it's a \"fake\" commit.\n\nSame issue. The bottom end of a shallow clone has no parents, and log's\ndiffs show root commits as giant creation events.\n\nMaybe it would be nice if the log output somehow noted that it was not a\nreal root commit, but rather the endpoint of a shallow clone, regardless\nof whether there is a diff being shown. Because it is also potentially\nconfusing to do \"git log\", scroll to the bottom, and think that is the\nvery first commit, when it's not (and you could deepen your repository\nif you wanted).\n\nI think all of this is due to the fact that shallow clones were tacked\non after the fact, and are not all that commonly used.\n\nPatches welcome (for docs or for log), of course.\n\n-Peff\n"}]}