3

When trying to run the command:

git p4 submit --shelve

(which runs git-p4.py) I am getting the error:

git: 'hook' is not a git command. See 'git --help'.

When I look in the code for git-p4.py, I see that it's trying to run the command:

git hook run p4-prepare-changelist

but, there doesn't seem to really be a command like git hook! The error message says it all! So what is going on?

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
JoelFan
  • 37,465
  • 35
  • 132
  • 205
  • git hooks are scripts run on some git events - not a command. Your git has extensive configuration customization so it will be hard for us to help you, since apparently something is wrong with this configuration. – Marek R Mar 11 '22 at 07:59
  • 1
    BTW which operating system you are running? Is there a `git-hook.py` script? – Marek R Mar 11 '22 at 08:02
  • Why do you say my git "has extensive configuration customization"? Are you talking about "git p4"? That is not so "extensive". That's nothing more than a python script called git-p4.py – JoelFan Mar 11 '22 at 08:02
  • this is "git for windows". I'm not aware of any `git-hook.py` script. Maybe that's what I need? – JoelFan Mar 11 '22 at 08:03
  • `p4` is custom command and use of hooks is also customization of git (by default hooks don't do anything). Error is result of missing `git-hook.*` script from l=already custom command. You should contact with person responsible for maintaining this customizations. – Marek R Mar 11 '22 at 08:05
  • 2
    No, `git p4` exists as a command. [Here](https://git-scm.com/docs/git-p4). – Romain Valeri Mar 11 '22 at 08:06
  • @RomainValeri yest you are right, I get confused since he wrote about script: `git-p4.py` and this kind of script are usually user defined. – Marek R Mar 11 '22 at 08:09
  • Could it be a `p4-pre-submit` [hook](https://git-scm.com/docs/git-p4#_p4_pre_submit) launching and preventing the `p4 submit`? – Romain Valeri Mar 11 '22 at 08:09
  • 1
    There is something fishy with extension, [here is code](https://github.com/git/git/blob/master/git-p4.py#L221-L228) which tries run `git hook`. Note there is no `git-hook.*` and there is no build in command like this. – Marek R Mar 11 '22 at 08:20
  • @JoelFan can you provide details of your git? Based on VonC answer apparently you are a victim of some bug which diverged versions of `git-p4.py` (you have not released version) and version of git. – Marek R Mar 11 '22 at 08:36
  • See my comment on the answer by VonC – JoelFan Mar 11 '22 at 09:14

1 Answers1

3

To my knowledge git hook run will only be released with Git 2.36 (Q2 2022).

The code mentioned in the comments has been introduced by git/git commit 0c8ac06, which is also for the next Git release.

It seems like the only way to get git-p4.py is to copy it from github . The one I have is the latest one from master

That means you need one matching your git version
For instance:

https://github.com/git/git/blob/v2.35.1/git-p4.py

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So how come he has new version of `git-p4.py` and old git? Is there some silent update of git scripts? – Marek R Mar 11 '22 at 08:26
  • @MarekR That I do not know, but unless it is used with a freshly compiled Git, said code would not work. – VonC Mar 11 '22 at 08:29
  • It seems like the only way to get `git-p4.py` is to copy it from `github` . The one I have is the latest one from `master` (https://github.com/git/git/blob/master/git-p4.py). Should I be using a different branch insetad of `master`? – JoelFan Mar 11 '22 at 09:12
  • 1
    @JoelFan Yes, get the version matching your own Git version. For instance https://github.com/git/git/blob/v2.35.1/git-p4.py – VonC Mar 11 '22 at 09:18
  • @VonC, that fixed it!!! – JoelFan Mar 11 '22 at 09:25
  • 1
    @JoelFan Great! I have already edited the answer accordingly. – VonC Mar 11 '22 at 09:27