{"thread":{"id":"36424","subject":"gitignore vs. exclude vs assume-unchanged?","startedAt":"2014-04-16T16:33:33Z","lastAt":"2014-04-26T12:26:12Z","messageCount":10,"participants":["alex@bellandwhistle.net","Junio C Hamano","Jonathan Nieder","Andrew Ardill","luc.linux@mailoo.org","Zé"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"238950","messageId":"b3f480af1c362c615ad9ce85296e2be2@bellandwhistle.net","threadId":"36424","inReplyTo":null,"subject":"gitignore vs. exclude vs assume-unchanged?","fromName":"","fromEmail":"alex@bellandwhistle.net","sentAt":"2014-04-16T16:33:33Z","receivedAt":"2014-04-16T16:33:33Z","isPatch":false,"sender":{"key":"alex@bellandwhistle.net","avatar":null},"body":"Any clarification on the differences much appreciated:\n\nhttp://stackoverflow.com/questions/23097368/git-ignore-vs-exclude-vs-assume-unchanged/23097509\n"},{"id":"238968","messageId":"xmqqy4z5go1y.fsf@gitster.dls.corp.google.com","threadId":"36424","inReplyTo":"b3f480af1c362c615ad9ce85296e2be2@bellandwhistle.net","subject":"Re: gitignore vs. exclude vs assume-unchanged?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-04-16T17:51:53Z","receivedAt":"2014-04-16T17:51:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"alex@bellandwhistle.net writes:\n\n> Any clarification on the differences much appreciated:\n>\n> http://stackoverflow.com/questions/23097368/git-ignore-vs-exclude-vs-assume-unchanged/23097509\n\nPlease don't force people to refer to external site.\n\nThe .gitignore and .git/info/exclude are the two UIs to invoke the\nsame mechanism.  In-tree .gitignore are to be shared among project\nmembers (i.e. everybody working on the project should consider the\npaths that match the ignore pattern in there as cruft).  On the\nother hand, .git/info/exclude is meant for personal ignore patterns\n(i.e. you, while working on the project, consider them as cruft).\n\nAssume-unchanged should not be abused for an ignore mechanism.  It\nis \"I know my filesystem operations are slow.  I'll promise Git that\nI won't change these paths by making them with that bit---that way,\nGit does not have to check if I changed things in there every time I\nask for 'git status' output\".  It does not mean anything other than\nthat.  Especially, it is *not* a promise by Git that Git will always\nconsider these paths are unmodified---if Git can determine a path\nthat is marked as assume-unchanged has changed without incurring\nextra lstat(2) cost, it reserves the right to report that the path\n*has been* modified (as a result, \"git commit -a\" is free to commit\nthat change).\n"},{"id":"238990","messageId":"dee7ee673c8c4d81fb5aaecea25e9709@bellandwhistle.net","threadId":"36424","inReplyTo":"xmqqy4z5go1y.fsf@gitster.dls.corp.google.com","subject":"Re: gitignore vs. exclude vs assume-unchanged?","fromName":"","fromEmail":"alex@bellandwhistle.net","sentAt":"2014-04-16T23:07:57Z","receivedAt":"2014-04-16T23:07:57Z","isPatch":false,"sender":{"key":"alex@bellandwhistle.net","avatar":null},"body":"On 2014-04-16 10:51, Junio C Hamano wrote:\n> alex@bellandwhistle.net writes:\n> \n>> Any clarification on the differences much appreciated:\n>> \n>> http://stackoverflow.com/questions/23097368/git-ignore-vs-exclude-vs-assume-unchanged/23097509\n> \n> Please don't force people to refer to external site.\n> \n> The .gitignore and .git/info/exclude are the two UIs to invoke the\n> same mechanism.  In-tree .gitignore are to be shared among project\n> members (i.e. everybody working on the project should consider the\n> paths that match the ignore pattern in there as cruft).  On the\n> other hand, .git/info/exclude is meant for personal ignore patterns\n> (i.e. you, while working on the project, consider them as cruft).\n> \n> Assume-unchanged should not be abused for an ignore mechanism.  It\n> is \"I know my filesystem operations are slow.  I'll promise Git that\n> I won't change these paths by making them with that bit---that way,\n> Git does not have to check if I changed things in there every time I\n> ask for 'git status' output\".  It does not mean anything other than\n> that.  Especially, it is *not* a promise by Git that Git will always\n> consider these paths are unmodified---if Git can determine a path\n> that is marked as assume-unchanged has changed without incurring\n> extra lstat(2) cost, it reserves the right to report that the path\n> *has been* modified (as a result, \"git commit -a\" is free to commit\n> that change).\n\nThanks June. Great to hear this authoritatively.\n\nIMHO your very helpful explanation about typical use cases, the purpose \nof 'exclude, and assume-unchanged not being a \"promise\" is missing from \nthe docs, or at least not obviously present:\n\nhttp://git-scm.com/docs\n\nIn particular, 'exclude' is spottily documented. I realize the docs are \nstructured strictly as an API reference, but it would be great to see a \ncomparison of ignore techniques spelled out. FWIW I asked several people \nI think of as experts and none of them felt sure of their answer. :)\n\nthanks again.\n"},{"id":"238992","messageId":"20140416234555.GA4309@google.com","threadId":"36424","inReplyTo":"dee7ee673c8c4d81fb5aaecea25e9709@bellandwhistle.net","subject":"Re: gitignore vs. exclude vs assume-unchanged?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2014-04-16T23:45:55Z","receivedAt":"2014-04-16T23:45:55Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nalex@bellandwhistle.net wrote:\n\n> In particular, 'exclude' is spottily documented.\n\nWhere did you expect to read about it?  I see some mention of\n.git/info/exclude in the gitignore(5) page, but I wouldn't be\nsurprised if there's room for improvement there (improvements\nwelcome).\n\n>                                                  I realize the docs\n> are structured strictly as an API reference,\n\nNo, the docs are meant to be helpful, not just to confirm what people\nalready know. ;-)\n\nThanks,\nJonathan\n"},{"id":"239059","messageId":"4dd8389939fbf3dc77b58adcca7b17c1@bellandwhistle.net","threadId":"36424","inReplyTo":"20140416234555.GA4309@google.com","subject":"Re: gitignore vs. exclude vs assume-unchanged?","fromName":"","fromEmail":"alex@bellandwhistle.net","sentAt":"2014-04-18T00:36:56Z","receivedAt":"2014-04-18T00:36:56Z","isPatch":false,"sender":{"key":"alex@bellandwhistle.net","avatar":null},"body":"On 2014-04-16 16:45, Jonathan Nieder wrote:\n> Hi,\n> \n> alex@bellandwhistle.net wrote:\n> \n>> In particular, 'exclude' is spottily documented.\n> \n> Where did you expect to read about it?  I see some mention of\n> .git/info/exclude in the gitignore(5) page, but I wouldn't be\n> surprised if there's room for improvement there (improvements\n> welcome).\n\nI suppose I might consider amending the opening sentence at:\n\nhttp://git-scm.com/docs/gitignore\n\nfrom:\n\n\"A gitignore file specifies intentionally untracked files that Git \nshould ignore.\"\n\nto something that makes the point earlier about the similarity:\n\n\"Both gitignore and $GIT_DIR/info/exclude files specify intentionally \nuntracked files that Git should ignore.\"\n\nor:\n\n\"Like the $GIT_DIR/info/exclude file, gitignore files specify \nintentionally untracked files that Git should ignore. The difference is \nthat files matched by a pattern in a gitignore file will be untracked \nfor all users of the repository.\"\n\nor somesuch.\n\nThe other thing is that there is no warning in the docs that \nassume-unchanged is not an absolute promise to ignore. This is news to \nme. I don't see this anywhere. I understand now that the use case is \nperformance, but that could be clearer.\n\nthanks again\nAlex\n"},{"id":"239279","messageId":"CAH5451k+GGGdHXkwne2O-h2m2AyWg7K+5reNRG64+eF891pVUA@mail.gmail.com","threadId":"36424","inReplyTo":"4dd8389939fbf3dc77b58adcca7b17c1@bellandwhistle.net","subject":"Re: gitignore vs. exclude vs assume-unchanged?","fromName":"Andrew Ardill","fromEmail":"andrew.ardill@gmail.com","sentAt":"2014-04-22T00:40:43Z","receivedAt":"2014-04-22T00:40:43Z","isPatch":false,"sender":{"key":"andrew.ardill@gmail.com","avatar":"https://gravatar.com/avatar/da14cb7c091dd44dc6c63a4d3361b149acaf25226dc78eb4131a17b93d9b0993?d=mp&s=160"},"body":"On 18 April 2014 10:36,  <alex@bellandwhistle.net> wrote:\n> \"Like the $GIT_DIR/info/exclude file, gitignore files specify intentionally\n> untracked files that Git should ignore. The difference is that files matched\n> by a pattern in a gitignore file will be untracked for all users of the\n> repository.\"\n\nAs a data point, I have seen people add \".gitignore\" to their\n.gitignore file, as they don't want to share the file.\n\nThis seems like a misuse of the functionality, as\n$GIT_DIR/info/exclude is a better choice for the same use case, but\nI'm not sure why the misuse is there.\n\nMy guess is that users aren't aware of excludes, whilst gitignore is\nplaced front of mind living at the root of many repositories.\nEducation will help here, but is there any way to make the 'correct'\nway more intuitive?\n\nIt would be possible to check for this antipattern during normal use\nand provide a hint to the user, but that is probably too heavy handed\nand might annoy people with a legitimate use case. For that matter, if\nthe gitignore file is easier to use for the 'private ignore' use case\nwe have a bigger problem and shouldn't dictate to users what to use.\n\nAs to the documentation, it is already quite comprehensive. All\nexclusion methods are listed, and the reasons for why to use them are\nwell laid out. The introduction does specifically mention 'gitignore'\nfiles, but that seems to be due to all the ignore files\n($HOME/.config/git/ignore, $GIT_DIR/info/exclude, .gitignore) being\nclassified as 'gitignore' files.\n\nSo some possible improvements. We could replace 'gitignore' with 'git\nignore' in instances where we are referencing all forms of the ignore\nfile, not just the .gitignore file.\n\n\"Git ignore files specify intentionally untracked files that Git should ignore.\"\n\nWe could reference the multiple ignore locations earlier, for people\nwho don't read past the first paragraph of to documentation.\n\n\"Git ignore files specify intentionally untracked files that Git\nshould ignore. A git ignore file can be specified for all local\nrepositories, a specific local repository, or shared with other users\nof a repository. Files already tracked by Git are not affected; see\nthe NOTES below for details.\"\n\nFinally, it's a little confusing that one of the files is called 'exclude'.\n\nIt would be great to rename it to 'ignore'; $GIT_DIR/info/exclude ->\n$GIT_DIR/info/ignore. Is there any reason this shouldn't be done?\nI haven't checked how extensive a change this would need be, but it\nwould make the usage much more consistent. The only reference I have\nfound to this file is at http://markmail.org/message/l7shxticxo3kzdpn\nfrom Junio in a discussion around an RFD for ignore rules.\n\nI think these three changes together would make the intended usage\nmore obvious to both new and old users, though each change could stand\non its own as well.\n\nRegards,\n\nAndrew Ardill\n"},{"id":"239356","messageId":"xmqqtx9l5jxn.fsf@gitster.dls.corp.google.com","threadId":"36424","inReplyTo":"CAH5451k+GGGdHXkwne2O-h2m2AyWg7K+5reNRG64+eF891pVUA@mail.gmail.com","subject":"Re: gitignore vs. exclude vs assume-unchanged?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-04-22T17:54:28Z","receivedAt":"2014-04-22T17:54:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andrew Ardill <andrew.ardill@gmail.com> writes:\n\n> As a data point, I have seen people add \".gitignore\" to their\n> .gitignore file, as they don't want to share the file.\n\nInteresting.  It will break immediately when the project starts\nwanting to distribute its \"canonical\" ignore list, but until that\ntime, it would \"work\" (for some definition of \"working\").\n\n> It would be possible to check for this antipattern during normal use\n> and provide a hint to the user, but that is probably too heavy handed\n> and might annoy people with a legitimate use case. For that matter, if\n> the gitignore file is easier to use for the 'private ignore' use case\n> we have a bigger problem and shouldn't dictate to users what to use.\n\nVery true.\n\n> ... The introduction does specifically mention 'gitignore'\n> files, but that seems to be due to all the ignore files\n> ($HOME/.config/git/ignore, $GIT_DIR/info/exclude, .gitignore) being\n> classified as 'gitignore' files.\n\nYes.  Notice that that the blanket term used is not \"dot-gitignore\",\nbut \"gitignore\".  The difference may be too subtle, and your\nsuggestion to introduce a new phrase \"git ignore files\" as the\nblanket term might be one way to make it less subtle.  I would\nactually think \"ignore files\" (without Git, as all readers know we\nare talking about _our_ ignore mechanism in our documentation) may\neven be a better idea. \n\n> We could reference the multiple ignore locations earlier, for people\n> who don't read past the first paragraph of to documentation.\n>\n> \"Git ignore files specify intentionally untracked files that Git\n> should ignore. A git ignore file can be specified for all local\n> repositories, a specific local repository, or shared with other users\n> of a repository. Files already tracked by Git are not affected; see\n> the NOTES below for details.\"\n\nSounds good, with or without s/git ignore/ignore/.\n\n> Finally, it's a little confusing that one of the files is called 'exclude'.\n>\n> It would be great to rename it to 'ignore'; $GIT_DIR/info/exclude ->\n> $GIT_DIR/info/ignore. Is there any reason this shouldn't be done?\n\nIf we were starting Git from scratch, we may have called it\ninfo/ignore, but we do not live in an ideal world, so we need to\nworry about people's existing repositories, scripts and templates.\n\nThat does not mean we cannot transition over time, aiming to flip\nthe default in a future big version bump (no, not in 2.0), along the\nlines of (note: I haven't thought this thru, and do not take this as\nan authoritative and correct plan):\n\n  Step 1.\n\n   - Check if info/ignore exists, and read it without reading or\n     even checking the existence of info/exclude;\n\n   - Check if info/exclude exists, and read it.  Warn about future\n     default change and tell the user to rename (or if we are\n     absolutely sure that we are interactive, we can offer to do the\n     rename for the user by prompting).\n\n  Step 2.\n\n   - Wait for several major releases, until major distros catch up\n     with step 1.\n\n  Step 3.\n\n   - Drop the support for info/exclude altogether, without even\n     warning about our stopping to read it.\n"},{"id":"239726","messageId":"35592507346991e5c286144fcbd04097@bellandwhistle.net","threadId":"36424","inReplyTo":"xmqqtx9l5jxn.fsf@gitster.dls.corp.google.com","subject":"Re: gitignore vs. exclude vs assume-unchanged?","fromName":"","fromEmail":"alex@bellandwhistle.net","sentAt":"2014-04-25T23:09:47Z","receivedAt":"2014-04-25T23:09:47Z","isPatch":false,"sender":{"key":"alex@bellandwhistle.net","avatar":null},"body":"> Andrew Ardill <andrew.ardill@gmail.com> writes:\n> \n> As a data point, I have seen people add \".gitignore\" to their\n> .gitignore file, as they don't want to share the file.\n\nRight, I've seen that too. It confused the heck out of me. It only lends \ncredence to my point about the docs. Those users want the functionality \nof a pattern in '$GIT_DIR/info/exclude', but haven't been able to figure \nit out easily enough. They've just heard about .gitignore, so they're \nusing that. Yes, it's all there in the docs if you read it several \ntimes, and you already know what you're looking at, but not in a \nterribly accessible, best practices, \"advice from a smart friend who's \nbeen through it all already\" kind of way.\n\n> ... The introduction does specifically mention 'gitignore'\n> files, but that seems to be due to all the ignore files\n> ($HOME/.config/git/ignore, $GIT_DIR/info/exclude, .gitignore) being\n> classified as 'gitignore' files.\n\nYes, the 'gitignore' versus '.gitignore' distinction is hopelessly \nsubtle. It is very easy for a newcomer to think these are exactly the \nsame thing. I certainly did.\n\n> Finally, it's a little confusing that one of the files is called \n> 'exclude'.\n> \n> It would be great to rename it to 'ignore'; $GIT_DIR/info/exclude ->\n> $GIT_DIR/info/ignore. Is there any reason this shouldn't be done?\n\nWell, yes: semantics. Since they do slightly different things, they \nshould have different names. It makes reference and teaching much \neasier. In fact, if a renaming were to occur, I would actually prefer \neven better semantics:\n\n     .gitignore -> .shared-ignore\n\n     $GIT_DIR/info/exclude -> $GIT_DIR/info/local-ignore\n\nThese suggested names could perhaps be improved on. But if anything, the \nnames need to be more different, not less. Users should be able to \ninstantly know what a speaker is talking about without having to \ndoublecheck and ask if by \"git-ignore\", the speaker really meant \"git \nignore\" or \"dot-gitignore\".\n\nThanks,\nAlex\n"},{"id":"239747","messageId":"20140426075245.GA4123@luc-arch","threadId":"36424","inReplyTo":"35592507346991e5c286144fcbd04097@bellandwhistle.net","subject":"Re: gitignore vs. exclude vs assume-unchanged?","fromName":"","fromEmail":"luc.linux@mailoo.org","sentAt":"2014-04-26T07:52:45Z","receivedAt":"2014-04-26T07:52:45Z","isPatch":false,"sender":{"key":"luc.linux@mailoo.org","avatar":null},"body":"On Fri, Apr 25, 2014 at 04:09:47PM -0700, alex@bellandwhistle.net wrote:\n> >Andrew Ardill <andrew.ardill@gmail.com> writes:\n> >\n> >As a data point, I have seen people add \".gitignore\" to their\n> >.gitignore file, as they don't want to share the file.\n> \n> Right, I've seen that too.\nThat something I am actually doing in my projects, because I didn't\nknow they were other way to exclude files like .gitignore.\n\n> It confused the heck out of me. It only lends\n> credence to my point about the docs. Those users want the functionality of a\n> pattern in '$GIT_DIR/info/exclude', but haven't been able to figure it out\n> easily enough. They've just heard about .gitignore, so they're using that.\n> Yes, it's all there in the docs if you read it several times, and you\n> already know what you're looking at, but not in a terribly accessible, best\n> practices, \"advice from a smart friend who's been through it all already\"\n> kind of way.\n Well documentation can be useful when you know what you're looking for,\n but I won't go read it just for discovering new features I didn't know.\n\n> Well, yes: semantics. Since they do slightly different things, they should\n> have different names. It makes reference and teaching much easier. In fact,\n> if a renaming were to occur, I would actually prefer even better semantics:\n> \n>     .gitignore -> .shared-ignore\n> \n>     $GIT_DIR/info/exclude -> $GIT_DIR/info/local-ignore\n> \n> These suggested names could perhaps be improved on. But if anything, the\n> names need to be more different, not less. Users should be able to instantly\n> know what a speaker is talking about without having to doublecheck and ask\n> if by \"git-ignore\", the speaker really meant \"git ignore\" or\n> \"dot-gitignore\".\nI agree with a new name for .gitignore. A name like shared-ignore would\nmake explicite the fact it is shared, and then the user would look for\nanother way to locally exclude files. This would be a good approach, but\nchanging it won't be easy as most people already use .gitignore.\n\nWould it be acceptable to have git display a warning when it detects\nthat .gitignore is excluding itself, with eventually a link to the\ndocumentation or the path to $GIT_DIR/info/exclude ?\n\n"},{"id":"239752","messageId":"535BA5E4.5050609@gmx.com","threadId":"36424","inReplyTo":"xmqqtx9l5jxn.fsf@gitster.dls.corp.google.com","subject":"Re: gitignore vs. exclude vs assume-unchanged?","fromName":"Zé","fromEmail":"jose.passes@gmx.com","sentAt":"2014-04-26T12:26:12Z","receivedAt":"2014-04-26T12:26:12Z","isPatch":false,"sender":{"key":"jose.passes@gmx.com","avatar":null},"body":"On 04/22/2014 06:54 PM, Junio C Hamano wrote:\n> Interesting.  It will break immediately when the project starts\n> wanting to distribute its \"canonical\" ignore list\n\nIf that happens, that's a problem caused by the project wanting to \nmisuse .gitignore.\n\nThere are good practices and bad practices.  Forcing a common .gitignore \nupon everyone with access to the source code is not a good practice.\n\n-- \nZé\n"}]}