#1284·lefthook

Multiple same name "dirs" in remotes clash

Author: scopCreated Jan 20, 2026Updated Jul 30, 2026
Labelsbug

Description

If one tries to configure multiple remotes having the same final dir name in their git URL, they will clash and some remotes will not run at all. I suppose it might cause some other problems as well.

This is apparently because the checkout dir name in .git/info/lefthook-remotes is used from the git_url as is.

lefthook.yml

yaml
remotes:
  - git_url: https://git.example.com/shared/lefthook.git
    configs:
      - lefthook-stuff.yaml
  - git_url: https://github.com/evilmartians/lefthook.git
    configs:
      - examples/remote/ping.yml

Commands to reproduce

Lefthook version

2.0.14

Possible solution

Use a "more qualified" checkout dir for remotes in .git/info/lefthook-remotes. For example, take a hex digest of the whole git_ref with some appropriate algorithm, and use that as is, e.g. .git/info/lefthook-remotes/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 (with SHA-256). Or prefix that with the original dir name so it's a bit easier to map for humans, e.g. .git/info/lefthook-remotes/lefthook-9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 for a remote whose dir is "lefthook".

Doing it this way would solve another problem with current remotes, if one changes some other part of the git_url than the last dir name, lefthook won't notice and will continue accessing the old if the old checked out dir is present in .git/info/lefthook-remotes.