3

Stumbled across this error today to waste a good amount of time, while trying to have gerrit hook setup for a repository, was using the following command scp -p -P 29418 [email protected]:hooks/commit-msg .git/hooks/ on terminal after having checked-out the project via XCode

Two reasons for this are:

  1. Executing hook command on incorrect folder. Makes sure to execute this command on parent folder of the checked-out folder & not on checked-out folder.
  2. Executing hook on a different branch other than on the master branch. Make sure to run the hook command on the master branch, before switching/checking-out a different branch.
1
  • @Stephen, I wanted to share this information, since I couldn't find any related question listed created one for it. Also have shared the initial cause and solution for others to benefit and contribute.
    – Abhijeet
    Commented Aug 6, 2015 at 15:58

3 Answers 3

2

Make sure that you are trying to install the hook from the correct folder, which is the root folder of the repository (which contains the .git folder)

In my case, I have cloned the repo using SourceTree, which omitted putting the repo inside a root folder. So, there were a bunch of files inside a folder that I have manually created on Finder.

To fix it, I re-cloned the project through the terminal, it puts the files inside a root folder with the name of the project; then everything worked fine.

0

Wanted to answer even though this is kind of old , but who ever faces this still can benefit from by findings

We had similar error when downloading commit message hook

gerrit protocol error : expected control record

Usually hooks are stored in project_folder/.git/hooks/

And you will find file with name commit-msg

On looking further the file was owned by root causing above issue

When changing the permission to my account solved the problem

0

Another possibility is that the scp command is (under the hood) seeing data that it does not understand. If your login scripts (e.g., ~/.bashrc or ~/.kshrc) generate output in non-interactive sessions then scp will fail with the "expected control record" error.

Additional details (for one specific setup) here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.