{"thread":{"id":"22948","subject":"Some information that git diff saves and that git status does not","startedAt":"2010-03-08T10:46:51Z","lastAt":"2010-03-09T08:20:29Z","messageCount":7,"participants":["Sergio","Junio C Hamano","Jens Lehmann","Dmitry Potapov","Sergio Callegari","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"136381","messageId":"loom.20100308T111146-322@post.gmane.org","threadId":"22948","inReplyTo":null,"subject":"Some information that git diff saves and that git status does not","fromName":"Sergio","fromEmail":"sergio.callegari@gmail.com","sentAt":"2010-03-08T10:46:51Z","receivedAt":"2010-03-08T10:46:51Z","isPatch":false,"sender":{"key":"sergio.callegari@gmail.com","avatar":"https://gravatar.com/avatar/c98f41317e0422c1e630385de0e3970227b8e5ad15f35ba8586066467cc833bc?d=mp&s=160"},"body":"Hi,\n\nI happen to work with a (possibly somehow unusual) configuration where 2 laptops\nare syncronized via unison (a widely used file syncronizer).\n\nThis means that git worktrees and repos are copied around as they are, rather\nthan transferred through git protocols.  The thing may appear weird, but it\nmakes sense, since the two laptops need to carry completely identical stuff all\nthe time (one, say \"A\", is a lightweight one good for travel, the other one, say\n\"B\" is a desktop replacement).\n\nIf I work on \"A\" in worktree \"WT\", when I then sync the two machines, WT and the\nassociated object store and git data remains unchanged in A and gets updated in\nB in such a way that git cannot know about it.\n\nAs a matter of fact, git copes with all this amazingly well, with the following\nquirk:\n\n1) The tree appears dirty on B, even if it was not on A before starting the\nsync. I guess this is because the index may contain data that does not make\ncomplete sense on B. As a consequence, gitk shows the tree as containing local\nchanges even if it does not.\n\n2) By running git status, you make git realize that in fact there are no local\nchanges in the tree.  After a git status, also gitk is happy.\n\n3) When you run git status, to find out that the local tree is in fact clean,\ngit status needs to do a significant amount of work.  If filters are defined,\ngit status runs all the filters on all the files that need to be filtered\n(revealed by GIT_TRACE). This can take a significant amount of time.\n\n4) Once git has done that, you would expect git status not to need doing the\nfilter job any longer.  However, if you run git status again and again, git\nagain and again spends a significant amount of time re-running all the filters.\n\n5) If rather than running git status, you run git diff, git runs the filters as\nfor git status, however some info now gets saved about this activity.  After a\ngit diff, git status becomes almost istantaneous, no filters are run any longer.\n\nIt would be nice if:\n\na) git status could save the same info that git diff saves, so after the first\ngit status which needs to take a long time, all the subsequent git status are\nfast. If I remember properly, this was indeed the behavior before the rewrite of\ngit status; and\n\nb) before saying that you have local changes, gitk could run git status to be\ntruly sure about that.\n\nWould a) and b) be easy and sensible changes? Or conversely, would they have\nnasty implications and side effects?\n\nSergio\n"},{"id":"136413","messageId":"7vpr3emr3s.fsf@alter.siamese.dyndns.org","threadId":"22948","inReplyTo":"loom.20100308T111146-322@post.gmane.org","subject":"Re: Some information that git diff saves and that git status does not","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-08T21:38:15Z","receivedAt":"2010-03-08T21:38:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I didn't fully read what you wrote but after you copy a repository from\none to another outside git (be it done with unison or rsync), you should\nrun \"update-index --refresh\".\n"},{"id":"136414","messageId":"4B957193.3080700@web.de","threadId":"22948","inReplyTo":"loom.20100308T111146-322@post.gmane.org","subject":"Re: Some information that git diff saves and that git status does not","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-03-08T21:52:19Z","receivedAt":"2010-03-08T21:52:19Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 08.03.2010 11:46, schrieb Sergio:\n> I happen to work with a (possibly somehow unusual) configuration where 2 laptops\n> are syncronized via unison (a widely used file syncronizer).\n\nDoing the same here between my desktop and my laptop, but i did enable\n\"times=true\" in the unsion config file. The reason for that was that i\nwanted to keep the creation time of my pictures (instead of replacing\nthem with the synchronization time) but it helps syncing git repos quite\nnicely too (But keep in mind that when you enable \"times=true\", you'll\nhave to sync all files once again next time because their time stamps\nseem to have changed).\n"},{"id":"136432","messageId":"4B95EC43.2040705@viscovery.net","threadId":"22948","inReplyTo":"7vpr3emr3s.fsf@alter.siamese.dyndns.org","subject":"Re: Some information that git diff saves and that git status does not","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-03-09T06:35:47Z","receivedAt":"2010-03-09T06:35:47Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Junio C Hamano schrieb:\n> I didn't fully read what you wrote but after you copy a repository from\n> one to another outside git (be it done with unison or rsync), you should\n> run \"update-index --refresh\".\n\nAnd the reason for this is that git also looks at the inode numbers, and I\nguess that unison does not go as far as to preserve them between machines...\n\n-- Hannes\n"},{"id":"136429","messageId":"7vmxyi0yqk.fsf@alter.siamese.dyndns.org","threadId":"22948","inReplyTo":"4B95EC43.2040705@viscovery.net","subject":"Re: Some information that git diff saves and that git status does not","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-09T06:56:35Z","receivedAt":"2010-03-09T06:56:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> Junio C Hamano schrieb:\n>> I didn't fully read what you wrote but after you copy a repository from\n>> one to another outside git (be it done with unison or rsync), you should\n>> run \"update-index --refresh\".\n>\n> And the reason for this is that git also looks at the inode numbers, and I\n> guess that unison does not go as far as to preserve them between machines...\n\nTrue; we used to (and you can still configure git to) check st_dev too but\nwe stopped to doing that by default as it is unstable even in a normal use\ncase (read: no \"cp\" involved) on some networked file systems.\n\nI wonder how stable inum is on inode-less filesystems (say FAT).  I guess\nit is not usually a problem because carrying repositories on USB keychains\nis typically done as a sneakernet and with bare repositories.\n"},{"id":"136428","messageId":"4B95F183.7000708@gmail.com","threadId":"22948","inReplyTo":"4B95EC43.2040705@viscovery.net","subject":"Re: Some information that git diff saves and that git status does not","fromName":"Sergio Callegari","fromEmail":"sergio.callegari@gmail.com","sentAt":"2010-03-09T06:58:11Z","receivedAt":"2010-03-09T06:58:11Z","isPatch":false,"sender":{"key":"sergio.callegari@gmail.com","avatar":"https://gravatar.com/avatar/c98f41317e0422c1e630385de0e3970227b8e5ad15f35ba8586066467cc833bc?d=mp&s=160"},"body":"Johannes Sixt wrote:\n> Junio C Hamano schrieb:\n>   \n>> I didn't fully read what you wrote but after you copy a repository from\n>> one to another outside git (be it done with unison or rsync), you should\n>> run \"update-index --refresh\".\n>>     \n>\n> And the reason for this is that git also looks at the inode numbers, and I\n> guess that unison does not go as far as to preserve them between machines...\n>\n> -- Hannes\n>\n>   \nThanks for all the info...  and sorry for the too verbose post at the \nbeginning.\n\nI actually did not know about the\n\nupdate-index --refresh\n\nbut now I have the relevant information its name sounds obvious.  And I \nsuspected something like inode data entering the game.\n\nAs a matter of fact, I was obtaining the same effect with git diff.\n\nWhat was appearing to me as a quirk is that:\n\n1) If you do not refresh the index, git works perfectly all the same.  \nFor instance, git status shows the right info. Only it is not that fast \nanymore, since everytime it needs to runs the filters on all the files.\n2) git status does not refresh the index, while other commands like git \ndiff do.\n\nI was wandering whether git status could refresh the index \nautomatically, at least about those files on which expensive actions, \nsuch as running filters had already been performed anyway.\n\nSergio\n\nSergio\n"},{"id":"136425","messageId":"20100309082029.GG31105@dpotapov.dyndns.org","threadId":"22948","inReplyTo":"4B95F183.7000708@gmail.com","subject":"Re: Some information that git diff saves and that git status does not","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2010-03-09T08:20:29Z","receivedAt":"2010-03-09T08:20:29Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Tue, Mar 09, 2010 at 07:58:11AM +0100, Sergio Callegari wrote:\n> \n> I actually did not know about the\n> \n> update-index --refresh\n\nThis is a plumbing commmand, which normally users should not use\ndirectly, but when you copy your repo by hands or do something like\nthat, you may need it (or use \"git diff\").\n\n> \n> but now I have the relevant information its name sounds obvious.\n> And I suspected something like inode data entering the game.\n> \n> As a matter of fact, I was obtaining the same effect with git diff.\n\nBecause \"git diff\" refreshes the cached stat information internally,\nin the same way as \"update-index --refresh\". Junio wrote about this\nrecently:\nhttp://article.gmane.org/gmane.comp.version-control.git/141708\n\n> \n> What was appearing to me as a quirk is that:\n> \n> 1) If you do not refresh the index, git works perfectly all the\n> same.  For instance, git status shows the right info. Only it is not\n> that fast anymore, since everytime it needs to runs the filters on\n> all the files.\n> 2) git status does not refresh the index, while other commands like\n> git diff do.\n\nHistorically, \"git status\" was just the dry-run mode of \"git commit\". I\ndo not think that \"git commit\" should refresh the index. But in Git 1.7,\n\"git status\" is no longer the dry-run mode of \"git commit\", so I see no\nreason why it does not refresh the cached stat info internally...\n\n\nDmitry\n"}]}