Skip to content

Pre-push hook contract is different from git's pre-push contract #693

@samskiter

Description

@samskiter

We're trying to use git-lfs with pre-commit.

Git lfs has a pre-push hook that looks like this:

#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.\n"; exit 2; }
git lfs pre-push "$@"

When we set this script up to be called from pre-commit's config it can hang if pre-commit uses the --all-files option (i.e. if it hits https://github.com/samskiter/pre-commit/blob/1bfd108593a268bdaf961249866f958081135ce1/pre_commit/resources/pre-push-tmpl#L13)

We can repro the issue by running pre-commit directly with --all-files. The git-lfs pre-push will hang, as if waiting for STDIN, or processing too much.

In other situations pre-commit will pass origin and source to the git-lfs pre-push script and it will run correctly.

Is there perhaps and option we could pass to pre-commit to have it run our pre-push hook as if git had called it (i.e. just fwd all arguments as if it were installed as 'legacy')?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions