{"thread":{"id":"47142","subject":"[Query] Separate hooks for Git worktrees","startedAt":"2017-11-09T10:58:15Z","lastAt":"2017-11-13T03:16:53Z","messageCount":6,"participants":["Viresh Kumar","Stefan Beller","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"332112","messageId":"CAKohponsPQC6qTw99+xh1RSu0bZNDSo5TbbZZcYmup3NOW6QmA@mail.gmail.com","threadId":"47142","inReplyTo":null,"subject":"[Query] Separate hooks for Git worktrees","fromName":"Viresh Kumar","fromEmail":"viresh.kumar@linaro.org","sentAt":"2017-11-09T10:58:09Z","receivedAt":"2017-11-09T10:58:15Z","isPatch":false,"sender":{"key":"viresh.kumar@linaro.org","avatar":"https://gravatar.com/avatar/938b1abce576d6c6d2734c01fce1c75040618c8fc0d1b7e836277ecd9f35fb19?d=mp&s=160"},"body":"Hi,\n\nI have a typical use case, where I am using the same\nrepository for both Android and Linux kernel branches.\n\nAndroid needs us to keep a special hook \"commit-msg\"\nwhich adds a \"Change-Id\" to every commit we create.\n\nWhile this works fine with Android, the behavior doesn't change\nby simply changing to a upstream kernel branch and eventually\nby mistake I may end up sending patch with Change-Id to upstream\nkernel as well. And I want to avoid that.\n\nI am looking at ways to make this configuration work for me by\napplying the hook only for Android branches.\n\nI tried using the \"git worktrees\" command to create a separate\nlinked tree for my android branch, but it doesn't have a .git directory\nbut just a file linking to the main repository.\n\nAny idea how I can get around this problem without having separate\nrepositories for kernel and android ?\n\nThanks in advance.\n\n--\nviresh\n"},{"id":"332127","messageId":"CAGZ79ka9VnzYTYgtWgGAhvgn2LRpP_BCQyVvQ8iC1w9XJnRxEw@mail.gmail.com","threadId":"47142","inReplyTo":"CAKohponsPQC6qTw99+xh1RSu0bZNDSo5TbbZZcYmup3NOW6QmA@mail.gmail.com","subject":"Re: [Query] Separate hooks for Git worktrees","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-11-09T19:14:45Z","receivedAt":"2017-11-09T19:14:52Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Nov 9, 2017 at 2:58 AM, Viresh Kumar <viresh.kumar@linaro.org> wrote:\n> Hi,\n>\n> I have a typical use case, where I am using the same\n> repository for both Android and Linux kernel branches.\n>\n> Android needs us to keep a special hook \"commit-msg\"\n> which adds a \"Change-Id\" to every commit we create.\n\nThe standard hook for Gerrit can be {en,dis}-abled via\n  git config gerrit.createChangeId {true, false}\n\n> While this works fine with Android, the behavior doesn't change\n> by simply changing to a upstream kernel branch and eventually\n> by mistake I may end up sending patch with Change-Id to upstream\n> kernel as well. And I want to avoid that.\n>\n> I am looking at ways to make this configuration work for me by\n> applying the hook only for Android branches.\n>\n> I tried using the \"git worktrees\" command to create a separate\n> linked tree for my android branch, but it doesn't have a .git directory\n> but just a file linking to the main repository.\n\nWe have no worktree specific config yet, though patches for\nthis were floated on the mailing list.\n\nThough recent versions of git learned to conditionally include\nconfig files. (look for includeIf in man git-config), which I think\ncould be used to set the option gerrit.createChangeId  depending\non the worktree you are in.\n\n> Any idea how I can get around this problem without having separate\n> repositories for kernel and android ?\n\nThe proposed approach above might be hacky but sounds as if\nit should work?\n\nThanks,\nStefan\n"},{"id":"332147","messageId":"20171110033837.GJ3297@vireshk-i7","threadId":"47142","inReplyTo":"CAGZ79ka9VnzYTYgtWgGAhvgn2LRpP_BCQyVvQ8iC1w9XJnRxEw@mail.gmail.com","subject":"Re: [Query] Separate hooks for Git worktrees","fromName":"Viresh Kumar","fromEmail":"viresh.kumar@linaro.org","sentAt":"2017-11-10T03:38:37Z","receivedAt":"2017-11-10T03:38:45Z","isPatch":false,"sender":{"key":"viresh.kumar@linaro.org","avatar":"https://gravatar.com/avatar/938b1abce576d6c6d2734c01fce1c75040618c8fc0d1b7e836277ecd9f35fb19?d=mp&s=160"},"body":"On 09-11-17, 11:14, Stefan Beller wrote:\n> The proposed approach above might be hacky but sounds as if\n> it should work?\n\nYeah its hacky for sure, but it solved my problem. Thanks for your\nhelp Stefan :)\n\n-- \nviresh\n"},{"id":"332149","messageId":"xmqq60aihgod.fsf@gitster.mtv.corp.google.com","threadId":"47142","inReplyTo":"CAGZ79ka9VnzYTYgtWgGAhvgn2LRpP_BCQyVvQ8iC1w9XJnRxEw@mail.gmail.com","subject":"Re: [Query] Separate hooks for Git worktrees","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-11-10T05:00:02Z","receivedAt":"2017-11-10T05:00:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> We have no worktree specific config yet, though patches for\n> this were floated on the mailing list.\n>\n> Though recent versions of git learned to conditionally include\n> config files. (look for includeIf in man git-config), which I think\n> could be used to set the option gerrit.createChangeId  depending\n> on the worktree you are in.\n>\n>> Any idea how I can get around this problem without having separate\n>> repositories for kernel and android ?\n>\n> The proposed approach above might be hacky but sounds as if\n> it should work?\n\nIf you meant \"conditional include\" by \"proposed approach above\", I\ndo not see which part you found possibly hacky.  It is to allow\ndifferent set of configurations to apply depending on where you are\nworking at, which I think was invented exactly for something like\nthis.\n\nIt certainly is not any hackier than using the same repository to\nhouse separately manged projects even if they may be related\nprojects.\n\nWhere does the aversion of \"having separate repositories\" primarily\ncome from?  Is it bad due to disk consumption?  Is it bad because\nyou cannot do \"git diff android-branch kernel-branch\"?  Something\nelse?\n\nIf it is purely disk consumption that is an issue, perhaps the real\nsolution is to make it easier to maintain separate repositories\nwhile sharing as much disk space as possible.  GC may have to be\nmade a lot more robust in the presense of alternate object stores,\nfor example.\n\n\n"},{"id":"332199","messageId":"CAGZ79kZ8PKBwe+aWTUOgPwV2tNQS7+dUrLTVsWhzemj-e35kaA@mail.gmail.com","threadId":"47142","inReplyTo":"xmqq60aihgod.fsf@gitster.mtv.corp.google.com","subject":"Re: [Query] Separate hooks for Git worktrees","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-11-10T18:00:51Z","receivedAt":"2017-11-10T18:00:57Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Nov 9, 2017 at 9:00 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> We have no worktree specific config yet, though patches for\n>> this were floated on the mailing list.\n>>\n>> Though recent versions of git learned to conditionally include\n>> config files. (look for includeIf in man git-config), which I think\n>> could be used to set the option gerrit.createChangeId  depending\n>> on the worktree you are in.\n>>\n>>> Any idea how I can get around this problem without having separate\n>>> repositories for kernel and android ?\n>>\n>> The proposed approach above might be hacky but sounds as if\n>> it should work?\n>\n> If you meant \"conditional include\" by \"proposed approach above\", I\n> do not see which part you found possibly hacky.\n\nCompared to a per-worktree configuration that you can setup via\n\n    git config --for-worktree=X key value\n\nthe setup using conditional includes seems hacky to me.\n(I just realize that these conditional includes can be set using\nregular git-config, so maybe it is not as hacky as I thought.)\n\n>  It is to allow\n> different set of configurations to apply depending on where you are\n> working at, which I think was invented exactly for something like\n> this.\n\nFrom a UX perspective, I can imagine a way easier workflow,\nbut the data model seems to make sense.\n\n> It certainly is not any hackier than using the same repository to\n> house separately manged projects even if they may be related\n> projects.\n\nWell it is the same project with different upstream workflows.\nFor example I would imagine that Viresh wants to cherry-pick\nfrom one branch to another, or even send the same patch\n(just with different commit messages, with or without the\nChangeId) to the different upstreams?\n\n> Where does the aversion of \"having separate repositories\" primarily\n> come from?  Is it bad due to disk consumption?  Is it bad because\n> you cannot do \"git diff android-branch kernel-branch\"?  Something\n> else?\n\nYeah, that is an interesting question!\n(I suspect workflow related things, diff/cherry-pick)\n\n> If it is purely disk consumption that is an issue, perhaps the real\n> solution is to make it easier to maintain separate repositories\n> while sharing as much disk space as possible.  GC may have to be\n> made a lot more robust in the presense of alternate object stores,\n> for example.\n"},{"id":"332385","messageId":"20171113031643.GA4305@vireshk-i7","threadId":"47142","inReplyTo":"CAGZ79kZ8PKBwe+aWTUOgPwV2tNQS7+dUrLTVsWhzemj-e35kaA@mail.gmail.com","subject":"Re: [Query] Separate hooks for Git worktrees","fromName":"Viresh Kumar","fromEmail":"viresh.kumar@linaro.org","sentAt":"2017-11-13T03:16:43Z","receivedAt":"2017-11-13T03:16:53Z","isPatch":false,"sender":{"key":"viresh.kumar@linaro.org","avatar":"https://gravatar.com/avatar/938b1abce576d6c6d2734c01fce1c75040618c8fc0d1b7e836277ecd9f35fb19?d=mp&s=160"},"body":"On 10-11-17, 10:00, Stefan Beller wrote:\n> Well it is the same project with different upstream workflows.\n> For example I would imagine that Viresh wants to cherry-pick\n> from one branch to another, or even send the same patch\n> (just with different commit messages, with or without the\n> ChangeId) to the different upstreams?\n\nRight.\n\n-- \nviresh\n"}]}