{"thread":{"id":"48015","subject":"Is context/directory sensitive config possible or even a god idea?","startedAt":"2018-03-09T22:34:01Z","lastAt":"2018-03-09T22:58:06Z","messageCount":2,"participants":["Eddy Petrișor","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"341375","messageId":"CAK0XTWfraH5B+1VkNPqrquLDWac=hB0dAASYXzZbG7oCb4hkkA@mail.gmail.com","threadId":"48015","inReplyTo":null,"subject":"Is context/directory sensitive config possible or even a god idea?","fromName":"Eddy Petrișor","fromEmail":"eddy.petrisor@gmail.com","sentAt":"2018-03-09T22:33:35Z","receivedAt":"2018-03-09T22:34:01Z","isPatch":false,"sender":{"key":"eddy.petrisor@gmail.com","avatar":"https://gravatar.com/avatar/e13eef6cecbe95604b4667c7bddf5aee2bb4af684c5fdceaf9e2aebfead3e9f5?d=mp&s=160"},"body":"Hello,\n\nIn some situations one person could be involved in various\nmulti-repository projects and need to use different user.email\ninformation, depending on the project.\n\nA simple example can be using the project specific email identity for\nall repositories part of Android, while using the personal email for\npersonal projects on github.\n\nThe developer has currently only 2 options, AFAICT:\na) use --global identity for the personal email and set the Android\nidentity in all project repos\nb) use the reverse, store Android identity in --global gitconfig, and\nmake sure to set the identity at repo level for personal projects.\n\nBoth solutions are suboptimal, especially if both the project in\nquestion has many repositories and the number github projects is high,\nbecause the user must remember to set the non-global user identity\neither in all github repos or in each Android repos, after checkout.\n\nIn my view, there should be a middle ground, having a\ncontext/directory dependent setting could be a solution.\n\nMy idea is somehting like \"for all repos cloned in subdirs of\ndirectory ~/src/android, use identity johm.doe@android.org\", so the\nonly thing to remember to make this work is to make sure all android\ncheckouts are done under ~/src/android, which most people already do\nbecause they need a clean home dir.\n\nWhen I saw he include.path feature I thought this was exactly that,\nbut when testing it did not work as I would have liked, the inluded\nconfig is simply added to the global config, if I add this to the\n~/.gitconfig file and the target file exists.\n\nI understand the use case I am thinking of is not the one that was\naddressed by the include.file feature, so I am thinking git would need\nsome other setting like\n'contextsensitive.include=/home/johndoe/src/android/.gitconfig' which\ncould mean include the settings from this config is we're in a dir on\nthe same level a the file, or a directory which has that dir as parent\nor ancestor.\n\n\nWhat I see already:\n1) it would be a perfomance hit if the test for \"do we need to apply\nany context sensitive setting\" must be done on every git command; for\nthe identity usecase might be less of a problem if only the subcomands\nthat need user.* would compare the prefix of the current dir with all\nall contextsensitive.inludes settings and applying only the longest\none\n2) what if the contextsensitive.inluclude file also includes another\ncontextsensitive.include, could that lead to ambiguous situations?\n3) having the feature could allow the user to set other project\nspecific settings. Nice usecases:\nif Android uses --no-ff merge.ff=false in ~/src/andoid/.gitconfig\ncontextsensitive.inlclude would ensure the expected strategy is used,\nand rebase is the preferred behaviour for pull, instead of merge)\n\n\n-- \nEddy Petrișor\n"},{"id":"341378","messageId":"xmqqfu585020.fsf@gitster-ct.c.googlers.com","threadId":"48015","inReplyTo":"CAK0XTWfraH5B+1VkNPqrquLDWac=hB0dAASYXzZbG7oCb4hkkA@mail.gmail.com","subject":"Re: Is context/directory sensitive config possible or even a god idea?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-03-09T22:57:59Z","receivedAt":"2018-03-09T22:58:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eddy Petrișor <eddy.petrisor@gmail.com> writes:\n\n> When I saw he include.path feature ...\n\nDo you mean includeIf.<condition>.path?\n"}]}