Change-Id missing hint doesn't work with submodules in Git 1.8+

546 views
Skip to first unread message

Doug Kelly

unread,
Nov 20, 2013, 10:36:05 AM11/20/13
to repo-d...@googlegroups.com
Hi all,

If you enforce requiring a Change-Id in Gerrit, users without a Change-Id will see the hint to install the commit-msg hook with "scp -p -P 29418 user@server:hooks/commit-msg .git/hooks".  This is great for your root project, but if you're using submodules (and happen to be using Git >=1.8.0), the submodule's .git is actually a gitdir file pointing to the root project's modules folder.  I think a possible solution is:

gitdir=$(git rev-parse --git-dir) scp -p -P 29418 gerrit.consumer.garmin.com:hooks/commit-msg $gitdir/hooks

But, it's a bit ugly.  I'm not sure if we should attempt to make this more accurate, or keep the simple version and let the user figure out if they need to do something else?  Any other thoughts?

--Doug

Shawn Pearce

unread,
Nov 20, 2013, 12:17:57 PM11/20/13
to Doug Kelly, repo-discuss
We should just fix the recommendation as you suggest, something like:

scp -p -P 29418 review.example.com:hooks/commit-msg $(git rev-parse
--git-dir)/hooks

We use the rev-parse --git-dir on gerrit-review.googlesource.com, for example.

Doug Kelly

unread,
Nov 21, 2013, 9:13:51 AM11/21/13
to repo-d...@googlegroups.com, Doug Kelly
On Wednesday, November 20, 2013 11:17:57 AM UTC-6, Shawn Pearce wrote:
We should just fix the recommendation as you suggest, something like:

  scp -p -P 29418 review.example.com:hooks/commit-msg $(git rev-parse
--git-dir)/hooks

We use the rev-parse --git-dir on gerrit-review.googlesource.com, for example.

That was kinda my thought, but due to some unknown bug in msysgit (go figure), the command substitution inside the scp command breaks (the colon in the argument really throws it for a loop).  That's why I split it out before the command into a temporary variable (the shell seems to be fine with that).  Go figure.

I'm going to go back into my corner and mumble something incomprehensible about msys now. ;)

Shawn Pearce

unread,
Nov 21, 2013, 11:42:02 AM11/21/13
to Doug Kelly, repo-discuss
Wow. Learn something new. :-)

OK we should also maybe modify the suggestion given on gerrit-review to use a temporary variable. Just in case someone tries to use msys.
Reply all
Reply to author
Forward
0 new messages