git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [Query] Separate hooks for Git worktrees
@ 2017-11-09 10:58 Viresh Kumar
  2017-11-09 19:14 ` Stefan Beller
  0 siblings, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2017-11-09 10:58 UTC (permalink / raw)
  To: Git Mailing List, Junio C Hamano; +Cc: Vincent Guittot

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.

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.

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

Thanks in advance.

--
viresh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Query] Separate hooks for Git worktrees
  2017-11-09 10:58 [Query] Separate hooks for Git worktrees Viresh Kumar
@ 2017-11-09 19:14 ` Stefan Beller
  2017-11-10  3:38   ` Viresh Kumar
  2017-11-10  5:00   ` Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Beller @ 2017-11-09 19:14 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: Git Mailing List, Junio C Hamano, Vincent Guittot

On Thu, Nov 9, 2017 at 2:58 AM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> 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}

> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Query] Separate hooks for Git worktrees
  2017-11-09 19:14 ` Stefan Beller
@ 2017-11-10  3:38   ` Viresh Kumar
  2017-11-10  5:00   ` Junio C Hamano
  1 sibling, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2017-11-10  3:38 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Git Mailing List, Junio C Hamano, Vincent Guittot

On 09-11-17, 11:14, Stefan Beller wrote:
> The proposed approach above might be hacky but sounds as if
> it should work?

Yeah its hacky for sure, but it solved my problem. Thanks for your
help Stefan :)

-- 
viresh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Query] Separate hooks for Git worktrees
  2017-11-09 19:14 ` Stefan Beller
  2017-11-10  3:38   ` Viresh Kumar
@ 2017-11-10  5:00   ` Junio C Hamano
  2017-11-10 18:00     ` Stefan Beller
  1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2017-11-10  5:00 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Viresh Kumar, Git Mailing List, Vincent Guittot

Stefan Beller <sbeller@google.com> writes:

> 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?

If you meant "conditional include" by "proposed approach above", I
do not see which part you found possibly hacky.  It is to allow
different set of configurations to apply depending on where you are
working at, which I think was invented exactly for something like
this.

It certainly is not any hackier than using the same repository to
house separately manged projects even if they may be related
projects.

Where does the aversion of "having separate repositories" primarily
come from?  Is it bad due to disk consumption?  Is it bad because
you cannot do "git diff android-branch kernel-branch"?  Something
else?

If it is purely disk consumption that is an issue, perhaps the real
solution is to make it easier to maintain separate repositories
while sharing as much disk space as possible.  GC may have to be
made a lot more robust in the presense of alternate object stores,
for example.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Query] Separate hooks for Git worktrees
  2017-11-10  5:00   ` Junio C Hamano
@ 2017-11-10 18:00     ` Stefan Beller
  2017-11-13  3:16       ` Viresh Kumar
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Beller @ 2017-11-10 18:00 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Viresh Kumar, Git Mailing List, Vincent Guittot

On Thu, Nov 9, 2017 at 9:00 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> writes:
>
>> 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?
>
> If you meant "conditional include" by "proposed approach above", I
> do not see which part you found possibly hacky.

Compared to a per-worktree configuration that you can setup via

    git config --for-worktree=X key value

the setup using conditional includes seems hacky to me.
(I just realize that these conditional includes can be set using
regular git-config, so maybe it is not as hacky as I thought.)

>  It is to allow
> different set of configurations to apply depending on where you are
> working at, which I think was invented exactly for something like
> this.

From a UX perspective, I can imagine a way easier workflow,
but the data model seems to make sense.

> It certainly is not any hackier than using the same repository to
> house separately manged projects even if they may be related
> projects.

Well it is the same project with different upstream workflows.
For example I would imagine that Viresh wants to cherry-pick
from one branch to another, or even send the same patch
(just with different commit messages, with or without the
ChangeId) to the different upstreams?

> Where does the aversion of "having separate repositories" primarily
> come from?  Is it bad due to disk consumption?  Is it bad because
> you cannot do "git diff android-branch kernel-branch"?  Something
> else?

Yeah, that is an interesting question!
(I suspect workflow related things, diff/cherry-pick)

> If it is purely disk consumption that is an issue, perhaps the real
> solution is to make it easier to maintain separate repositories
> while sharing as much disk space as possible.  GC may have to be
> made a lot more robust in the presense of alternate object stores,
> for example.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Query] Separate hooks for Git worktrees
  2017-11-10 18:00     ` Stefan Beller
@ 2017-11-13  3:16       ` Viresh Kumar
  0 siblings, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2017-11-13  3:16 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Junio C Hamano, Git Mailing List, Vincent Guittot

On 10-11-17, 10:00, Stefan Beller wrote:
> Well it is the same project with different upstream workflows.
> For example I would imagine that Viresh wants to cherry-pick
> from one branch to another, or even send the same patch
> (just with different commit messages, with or without the
> ChangeId) to the different upstreams?

Right.

-- 
viresh

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-11-13  3:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 10:58 [Query] Separate hooks for Git worktrees Viresh Kumar
2017-11-09 19:14 ` Stefan Beller
2017-11-10  3:38   ` Viresh Kumar
2017-11-10  5:00   ` Junio C Hamano
2017-11-10 18:00     ` Stefan Beller
2017-11-13  3:16       ` Viresh Kumar

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git