Unable to push to some repos, sonia.scm.web.GitReceiveHook - could not handle receive commands

Issue #994 resolved
Laurent Perez created an issue

Hi

Upgraded from 1.17 to 1.60 git 2.18.0 on both server and client jdk /opt/jdk1.8.0_181

git push is working fine, except for some of my repositories, I've disabled all of their git hooks for debugging purposes, but I still get :

To http://xxx:8580/scm/git/xxx
 ! [remote rejected]     testlaurent_push_forge -> testlaurent_push_forge (unspecified reason)

Stacktrace :
2018-08-24 22:43:13.730 [qtp1361960727-29] WARN  sonia.scm.repository.RepositoryUtil - path is shorter as the main repository path
2018-08-24 22:43:13.734 [qtp1361960727-29] ERROR sonia.scm.web.GitReceiveHook - could not handle receive commands
java.lang.IllegalStateException: value is empty
    at sonia.scm.util.AssertUtil.assertIsNotEmpty(AssertUtil.java:69)
    at sonia.scm.repository.DefaultRepositoryManager.get(DefaultRepositoryManager.java:461)
    at sonia.scm.repository.spi.HookEventFacade.handle(HookEventFacade.java:120)
    at sonia.scm.web.GitReceiveHook.handleReceiveCommands(GitReceiveHook.java:141)
    at sonia.scm.web.GitReceiveHook.onReceive(GitReceiveHook.java:176)
    at sonia.scm.web.GitReceiveHook.onPreReceive(GitReceiveHook.java:117)
    at org.eclipse.jgit.transport.ReceivePack.service(ReceivePack.java:264)

Looking at the source of 1.61-SNAPSHOT scm-webapp/src/main/java/sonia/scm/repository/DefaultRepositoryManager.java gets an empty name, type is not empty

It boils down to sonia.scm.repository.RepositoryUtil#getRepositoryName(java.io.File, java.io.File), getting path is shorter as the main repository path, returning a null name indeed, where I don't really understand the if clause and name rewriting

Do you have any hints ? Thanks

Comments (7)

  1. Laurent Perez reporter

    ok, I pinpointed it, it only fails for bare=false repositories under sonia.scm.web.GitReceiveHook#resolveRepositoryName referencing issue #415

    on non bare, directories canonical paths both resolve to the main repository path, so both canonicals are equal, the if clause fires and the repo name is returned as null - yet the name can be known, it is available in Directory#toString()

    I'm not sure how I should proceed ? 1.17 was working fine unless for post-receive hooks, a simple bash echo does not work under a 1.17 post-receive.

    I'm upgrading because the hooks code is better than in 1.17 : now all my post-receive hooks are working, but my non bare repositories now return a null name hence crashing the push

    Clues ?

  2. Laurent Perez reporter

    fyi I solved this by migrating my non bare to bare repos yet the "value is empty" could be more informative, or just handle non bare repos, I guess. unsure works now anyway with bare :)

  3. Sebastian Sdorra repo owner

    I think i've fixed the bug with the non bare repositories: 8ae8493.

    The patch will be delivered with the next scm-manager release.

  4. Log in to comment