Hooks broken if ITK as part of a SuperProject


I tried to set ITK up as part of a superbuild and the gerrit integration does not work “at all” …

This makes me reluctant on contributing (this is mostly due to the custom hooks not being properly set up).

How to recreate:

  • create a “personal superbuild”
  • create a submodule for itk
  • develop a patch within that submodule
  • try to set up the hooks with Utilities/SetupForDevelopment.sh

– this does not work since if does not find …/…/.git/hooks (which does not exist, since it is a superbuild project)

Solution: Fix SetupForDevelopment.h for Superbuilds


In your superbuild, how are you getting ITK? git? tar-ball?

Some superbuild projects allow the setting of the source code directory of the sub-projects (ITK), this allows you to build the superbuild project against a custom version of the external project. This is much better that editing files in a check out source directory that is part of the superbuild build directory, because the superbuild may modify or change that checked out/untared directory when a top-level build is done.

Well, since it is my personal superbuild, I want it to have everything in there, because that way I have the same environment on all machines and do not manually need to update everything.

As you might be ablt to read from the initial post, I am kinda frustrated…

Hi David,

Can you share the project so the issue can be reproduced?


Unfortunately I cannot, but I quickly reproduced the errors by:

  1. creating a new repo (by TortoiseGIT)

  2. creating a submodule within (/itk) sourcing from itk (git://itk.org/ITK.git) (by TortoiseGIT)

  3. Trying to run SetupForDevelopment.sh (on a cygwin Terminal) (see below)

    dkuegler@pc2046 ~
    $ cd …/g/super/

    dkuegler@pc2046 /cygdrive/g/super
    $ cd itk

    dkuegler@pc2046 /cygdrive/g/super/itk
    $ ./Utilities/SetupForDevelopment.sh
    Checking Git version…
    Git version 2.14.1 is OK.

    Setting pushurl for origin.

    Checking basic user information…
    Please enter your full name, such as ‘John Doe’: David K____
    Setting name to 'David Kügler’
    Please enter your email address, such as ‘john@gmail.com’: david.k___@___
    Setting email address to 'david.k___@____'
    Your commits will have the following author:

    David K___ <david.k___@___>

    Is the author name and email address above correct? [Y/n]

    Setting up git hooks…
    ./SetupHooks.sh: Zeile 39: cd: /cygdrive/g/super/itk/Utilities/DevelopmentSetupScripts/…/…/.git/hooks: Not a directory
    Leeres Git-Repository in /cygdrive/g/super/itk/Utilities/DevelopmentSetupScripts/.git/ initialisiert
    Pulling the hooks…
    warning: Leite nach https://public.kitware.com/ITK.git/ um
    remote: Counting objects: 202, done.
    remote: Compressing objects: 100% (81/81), done.
    remote: Total 202 (delta 122), reused 195 (delta 117)
    Empfange Objekte: 100% (202/202), 39.95 KiB | 300.00 KiB/s, Fertig.
    Löse Unterschiede auf: 100% (122/122), Fertig.
    Von http://public.kitware.com/ITK

    • branch hooks -> FETCH_HEAD
      HEAD ist jetzt bei 76566ed Add a ‘post-commit’ hook.
      Setting up the uncrustify hook…
      Setting up the KWStyle hook…

    Setting up useful Git aliases…
    Would you like general Git aliases to be global? [y/N]:

    Setting up Gerrit…
    Gerrit is a code review system that works with Git.

    In order to use Gerrit, an account must be registered at the review site:


    In order to register you need an OpenID


    Enter your gerrit user (set in Gerrit Settings/Profile) [dk____]:

Also running the script from the top level folder does not work either…

Well, in order to work properly, I think SetupForDevelopment would need to be modified, so it can actually “reroute” to super/.git/modules/itk instead of …/…/.git

SetupForDevelopment seems to be just not compatible with superbuilds…

I remember there was a similar issue once in the plus toolkit (they seem to have copied the script from ITK).

But I think it might have been solved there…

Thanks for the details, David.

This patch will address the issue.

@matt.mccormick It looks like you double-pushed to gerrit. You abandoned the patch which you linked. The active one is here.

1 Like