git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Query] Separate hooks for Git worktrees

From
Stefan Beller <sbeller@google.com>
Date
Nov 9, 2017, 19:14 UTC
Message-ID
<CAGZ79ka9VnzYTYgtWgGAhvgn2LRpP_BCQyVvQ8iC1w9XJnRxEw@mail.gmail.com>
In-Reply-To
<CAKohponsPQC6qTw99+xh1RSu0bZNDSo5TbbZZcYmup3NOW6QmA@mail.gmail.com>
On Thu, Nov 9, 2017 at 2:58 AM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
Show 7 quoted lines
> Hi,
>
> I have a typical use case, where I am using the same
> repository for both Android and Linux kernel branches.
>
> Android needs us to keep a special hook "commit-msg"
> which adds a "Change-Id" to every commit we create.
The standard hook for Gerrit can be {en,dis}-abled via
  git config gerrit.createChangeId {true, false}
Show 11 quoted lines
> While this works fine with Android, the behavior doesn't change
> by simply changing to a upstream kernel branch and eventually
> by mistake I may end up sending patch with Change-Id to upstream
> kernel as well. And I want to avoid that.
>
> I am looking at ways to make this configuration work for me by
> applying the hook only for Android branches.
>
> I tried using the "git worktrees" command to create a separate
> linked tree for my android branch, but it doesn't have a .git directory
> but just a file linking to the main repository.

We have no worktree specific config yet, though patches for this were floated on the mailing list.

Though recent versions of git learned to conditionally include config files. (look for includeIf in man git-config), which I think could be used to set the option gerrit.createChangeId depending on the worktree you are in.

> Any idea how I can get around this problem without having separate
> repositories for kernel and android ?

The proposed approach above might be hacky but sounds as if it should work?

Thanks, Stefan

Previous: Viresh KumarNext: Viresh Kumar
Message 2 of 6 in “[Query] Separate hooks for Git worktrees”
  1. Viresh KumarNov 9, 2017
  2. Stefan BellerNov 9, 2017
  3. Viresh KumarNov 10, 2017
  4. Junio C HamanoNov 10, 2017
  5. Stefan BellerNov 10, 2017
  6. Viresh KumarNov 13, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.