{"thread":{"id":"40712","subject":"Strange diff-index output","startedAt":"2015-11-02T23:59:37Z","lastAt":"2015-11-04T06:38:04Z","messageCount":4,"participants":["Ch'Gans","David Turner","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"272774","messageId":"CABxGUTj-5vdmyVGkKuoMdBAG2EAQvLJNYLLA++T2hNFvGRmb0w@mail.gmail.com","threadId":"40712","inReplyTo":null,"subject":"Strange diff-index output","fromName":"Ch'Gans","fromEmail":"chgans@gna.org","sentAt":"2015-11-02T23:59:37Z","receivedAt":"2015-11-02T23:59:37Z","isPatch":false,"sender":{"key":"chgans@gna.org","avatar":"https://gravatar.com/avatar/db840d8a74ec7920040131477f30bdcacf2febbcee04e6efd803880f2ec454c9?d=mp&s=160"},"body":"Hi there,\n\nWe're using a script to verify that what we are building is clean\nagainst our git repository, for this we're using \"git rev-parse\n--short HEAD\" to get the current hash and \"git diff-index --quiet\nHEAD\" to check for local modification.\nThis script works fine on developer's machines, but doesn't on our CI\nsystem (Atlassian Bamboo/Stash).\n\nHEAD points to refs/heads/FIX-XYZ and refs/heads/FIX-XYZ exists.\n\nOn our CI, the output of diff-index gives something like:\n:100644 100644 abcdef 000000 M file1\n\nOur problem is very likely related with how Bamboo works and/or how we\nuse it, but to investigate this issue further, I first would like to\nunderstand the meaning of the above output.\n\n>From the man page of diff-index:\n- 100644 is the mode of \"src\"\n- 100644 is the mode of dst\n- abcdef is the hash of src\n- 000000 is the hash of dst\n- M stands for \"Modified\"\n- file1 is the filename being considered.\n\n>From my understanding, src here means the file system and dst the git\nobject. So the above should mean \"file1\" is new and out of sync with\nthe index, which doesn't make sense since \"file1\" is definitely in the\nrepository. The weird stuff is that diff-index report the same problem\non every single file no just a few!\n\nNotes:\n - Something I've noticed with Bamboo is that the cloned repository\ndoesn't have any remotes. Although I'm not sure if it is relevant\nhere.\n - I have tried with \"shallow copy\" Bamboo option enabled or not and I\nget the same problems\n - I have tried \"git update-index\", but still get the same results\n - git log still gives me the full log history (but no remote heads)\n - git status reports nothing else than a couple of generated files\n - git status HEAD reports that the working directory is clean\n - git diff-index --cached reports nothing\n\nDoes any of you have ever come across this kind of problem? Could\nanyone shed some light on what's going on with our clone? Any\ndocumentation point out or hints appreciated.\n\nThanks,\nChris\n"},{"id":"272775","messageId":"1446510469.4131.35.camel@twopensource.com","threadId":"40712","inReplyTo":"CABxGUTj-5vdmyVGkKuoMdBAG2EAQvLJNYLLA++T2hNFvGRmb0w@mail.gmail.com","subject":"Re: Strange diff-index output","fromName":"David Turner","fromEmail":"dturner@twopensource.com","sentAt":"2015-11-03T00:27:49Z","receivedAt":"2015-11-03T00:27:49Z","isPatch":false,"sender":{"key":"novalis@novalis.org","avatar":"https://avatars.githubusercontent.com/u/77003?v=4"},"body":"On Tue, 2015-11-03 at 12:59 +1300, Ch'Gans wrote:\n> Hi there,\n> \n> We're using a script to verify that what we are building is clean\n> against our git repository, for this we're using \"git rev-parse\n> --short HEAD\" to get the current hash and \"git diff-index --quiet\n> HEAD\" to check for local modification.\n\nSee this note from the git diff-index man page:\n           Note\n           As with other commands of this type, git diff-index does not\n           actually look at the contents of the file at all. So maybe\n           kernel/sched.c hasn’t actually changed, and it’s just that\nyou\n           touched it. In either case, it’s a note that you need to git\n           update-index it to make the index be in sync.\n\nYou can either add an update-index to your script, or use git status\n--porcelain.\n"},{"id":"272776","messageId":"CABxGUTihNmHqp-RovCVreTRqoK_sj+KCjRQE_YOVZ8OQzOHHoA@mail.gmail.com","threadId":"40712","inReplyTo":"1446510469.4131.35.camel@twopensource.com","subject":"Re: Strange diff-index output","fromName":"Ch'Gans","fromEmail":"chgans@gna.org","sentAt":"2015-11-03T01:00:33Z","receivedAt":"2015-11-03T01:00:33Z","isPatch":false,"sender":{"key":"chgans@gna.org","avatar":"https://gravatar.com/avatar/db840d8a74ec7920040131477f30bdcacf2febbcee04e6efd803880f2ec454c9?d=mp&s=160"},"body":"On 3 November 2015 at 13:27, David Turner <dturner@twopensource.com> wrote:\n> On Tue, 2015-11-03 at 12:59 +1300, Ch'Gans wrote:\n>> Hi there,\n>>\n>> We're using a script to verify that what we are building is clean\n>> against our git repository, for this we're using \"git rev-parse\n>> --short HEAD\" to get the current hash and \"git diff-index --quiet\n>> HEAD\" to check for local modification.\n>\n> See this note from the git diff-index man page:\n>            Note\n>            As with other commands of this type, git diff-index does not\n>            actually look at the contents of the file at all. So maybe\n>            kernel/sched.c hasn’t actually changed, and it’s just that\n> you\n>            touched it. In either case, it’s a note that you need to git\n>            update-index it to make the index be in sync.\n>\n> You can either add an update-index to your script, or use git status\n> --porcelain.\n\nHi David,\n\nI first tried \"git update-index\" but it didn't work. However \"git\nupdate-index --refresh\" seems to fix our problem.\nI didn't get why \"--refresh\" is needed thought, I'm really not\nfamiliar with the caching aspect of git.\nAnyway, I think that this fix is what I need right now.\n\nThanks,\nChris\n\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"272887","messageId":"20151104063803.GA16605@sigill.intra.peff.net","threadId":"40712","inReplyTo":"CABxGUTihNmHqp-RovCVreTRqoK_sj+KCjRQE_YOVZ8OQzOHHoA@mail.gmail.com","subject":"Re: Strange diff-index output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-11-04T06:38:04Z","receivedAt":"2015-11-04T06:38:04Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Nov 03, 2015 at 02:00:33PM +1300, Ch'Gans wrote:\n\n> I first tried \"git update-index\" but it didn't work. However \"git\n> update-index --refresh\" seems to fix our problem.\n> I didn't get why \"--refresh\" is needed thought, I'm really not\n> familiar with the caching aspect of git.\n\nIt is because update-index is a general command for manipulating the\nindex. For example, you can add, delete, or change entries without\nregard to what is in the working tree.\n\nOne of the manipulations is \"refresh the index based on what is in the\nworking tree\", and that is spelled \"--refresh\". Most porcelain-level git\ncommands (like \"git diff\") will do this for you automatically and\ntransparently. But when using the scriptable plumbing (like diff-index),\ngit gives you more control. This lets you do things more efficiently\n(e.g,. you might refresh once and then issue several low-level\ncommands), at the cost of convenience.\n\nYou could also have used \"git diff-index --cached HEAD\", which instructs\ndiff-index not to look at the working tree at all (so you would compare\nwhatever is in the index, whether it is up to date with what is in the\nworking tree or not). Depending on what you are trying to achieve, that\nmight be fine (it's also more efficient in general, as it does not\nrequire an lstat() of every file in the working tree).\n\n-Peff\n"}]}