Kallithea issues archive

Issue #323: git hook error on push of first commit

Reported by: Thomas De Schampheleire
State: resolved
Created on: 2018-06-15 18:54
Updated on: 2018-09-15 18:24

Description

Kallithea default branch, commit eddb927e3473. Steps to reproduce:

  1. create new git repository via web UI
  2. clone this repo to a filesystem location (via a terminal)
  3. add a file and commit it
  4. git push

Results in terminal:

$ git push                                                                                                                                                                                                      
Password for 'http://user@localhost:5000': 
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 1.32 MiB | 7.61 MiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: No handlers could be found for logger "kallithea.lib.vcs.backends.git.repository"
remote: Traceback (most recent call last):
remote:   File "hooks/post-receive", line 30, in <module>
remote:     main()
remote:   File "hooks/post-receive", line 26, in main
remote:     sys.exit(_handler(repo_path, git_stdin_lines, os.environ))
remote:   File "/home/tdescham/repo/contrib/kallithea/kallithea-release/kallithea/lib/hooks.py", line 372, in handle_git_post_receive
remote:     return handle_git_receive(repo_path, git_stdin_lines, env, hook_type='post')
remote:   File "/home/tdescham/repo/contrib/kallithea/kallithea-release/kallithea/lib/hooks.py", line 456, in handle_git_receive
remote:     git_revs += repo.run_git_command(cmd)[0].splitlines()
remote:   File "/home/tdescham/repo/contrib/kallithea/kallithea-release/kallithea/lib/vcs/backends/git/repository.py", line 158, in run_git_command
remote:     return self._run_git_command(cmd, **opts)
remote:   File "/home/tdescham/repo/contrib/kallithea/kallithea-release/kallithea/lib/vcs/backends/git/repository.py", line 150, in _run_git_command
remote:     raise RepositoryError(tb_err)
remote: kallithea.lib.vcs.exceptions.RepositoryError: Couldn't run git command (['git', '-c', 'core.quotepath=false', 'log', '3020a2edb3161ade744d605c27215fafdf4daad6', '--reverse', '--pretty=format:%H', '--not', '']).
remote: Original error was:Subprocess exited due to an error:
remote: fatal: ambiguous argument '': unknown revision or path not in the working tree.
remote: Use '--' to separate paths from revisions, like this:
remote: 'git <command> [<revision>...] -- [<file>...]'
remote: 
remote: 
To http://localhost:5000/gitrepo
 * [new branch]      master -> master

The commit gets pushed correctly, but the error sent to the client is disturbing. Problem seems to be the empty argument '' which is calculated from

                    heads = heads.replace(push_ref['ref'], '')
                    for l in heads.splitlines():
                        cmd.append(l.strip())

(see kallithea/lib/hooks.py line 451)

Attachments

Comments

Comment by Mads Kiilerich, on 2018-06-16 16:07

Any thoughts on how it should be solved?

Will you fix it?

Comment by Thomas De Schampheleire, on 2018-06-17 19:30

Not knowing more about the command that is being composed, we could check whether heads is empty, and only if not proceed with calling the command. I'm not sure, though, if there are cases where it will not be empty, or whether this is dead code, or whether this depends on the git version.

Also, the output is used to log the push action, but it never shows in the log (not even pushes without error, i.e. on existing repo). I am planning on digging into that further.

Comment by Thomas De Schampheleire, on 2018-08-08 19:03

FYI, I had done some analysis at that time, but did not get to something that fixes the issue.

Comment by Mads Kiilerich, on 2018-08-09 01:33

re check whether heads is empty, and only if not proceed with calling the command : heads are heads to exclude. Even if that list of existing heads is empty, we still want to log all the revisions that got pushed.

Comment by Thomas De Schampheleire, on 2018-09-15 18:24