Re: Can't push - Change-Id missing

5,258 views
Skip to first unread message

Martin Fick

unread,
Jan 24, 2013, 5:40:40 PM1/24/13
to repo-d...@googlegroups.com
On Thursday, January 24, 2013 01:57:49 pm Skip Montanaro wrote:
>
> So, why is Gerrit suggesting a Change-Id? Wasn't the commit-msg
hook
> supposed to add it automatically?

Yes, do a "git log -1", is it there?

> How do I get this suggested Change-Id into the commit message?

Did you put it in your .git/hooks dir? Did you give it execute permissions?

-Martin




Magnus Bäck

unread,
Jan 24, 2013, 8:09:21 PM1/24/13
to repo-d...@googlegroups.com
On Thursday, January 24, 2013 at 15:57 EST,
Skip Montanaro <skip.mo...@gmail.com> wrote:

> I'm a new Gerrit user (hopefully this is the right place to ask
> questions - if not, please point me in the right direction),

You've come to the right place.

> trying to perform my first push. I'm sure I've made some elementary
> mistake, but I can't figure out what's wrong. On my first attempt it
> complained about missing Change-Id and suggested I copy the commit-msg
> hook from the server. Did that. Checked that it was executable.
> Now, how to create a commit with a Change-Id?

The hook adds it to new commits as well as amended ones.

> I figured that with the new commit hook in place, future commits would
> have a Change-Id, so I figured out how to use the git rebase command
> (did I mention I'm also a new Git user?) and collapsed all my commits
> into one. Then I tried the push again. Same error. I did see a
> Change-Id scroll by in the output though:
>
> % git push gerrit:... HEAD:refs/for/...
> Counting objects: 34, done.
> Delta compression using up to 4 threads.
> Compressing objects: 100% (17/17), done.
> Writing objects: 100% (18/18), 1.65 KiB, done.
> Total 18 (delta 16), reused 0 (delta 0)
> remote: Resolving deltas: 100% (16/16)
> remote: Processing changes: refs: 1, done
> remote: ERROR: missing Change-Id in commit message footer
> remote: Suggestion for commit message:
> ...
> remote:
> remote: Change-Id: Ic8d0353b9df761ba80c0896c0a2b555dd323de56
> remote:
> remote: Hint: To automatically insert Change-Id, install the hook:
> ...
>
> So, why is Gerrit suggesting a Change-Id? Wasn't the commit-msg hook
> supposed to add it automatically? How do I get this suggested
> Change-Id into the commit message?

What is the commit message of the commit you're trying to push (use
"git log -1" as Martin suggested)? Feel free to s/[A-Za-z]/x/g if the
message contains confidential information. The hook should've added
the line, but without seeing the evidence there's not much point
speculating what's wrong.

I will say that Gerrit is picky about the Change-Id line being in the
last paragraph. Make sure it is.

--
Magnus Bäck
ba...@google.com

Torne Wuff

unread,
Jan 24, 2013, 9:34:22 PM1/24/13
to repo-d...@googlegroups.com
On 24 January 2013 17:09, Magnus Bäck <ba...@google.com> wrote:
On Thursday, January 24, 2013 at 15:57 EST,
     Skip Montanaro <skip.mo...@gmail.com> wrote:

> I'm a new Gerrit user (hopefully this is the right place to ask
> questions - if not, please point me in the right direction),

You've come to the right place.

> trying to perform my first push.  I'm sure I've made some elementary
> mistake, but I can't figure out what's wrong.  On my first attempt it
> complained about missing Change-Id and suggested I copy the commit-msg
> hook from the server.  Did that.  Checked that it was executable.
> Now, how to create a commit with a Change-Id?

The hook adds it to new commits as well as amended ones.

Does it add it to amended ones? It never has for me; I always have to git reset --soft HEAD^ and then commit again from scratch to get the change-id autogenerated.
 

Pursehouse, David

unread,
Jan 24, 2013, 9:41:40 PM1/24/13
to Torne Wuff, repo-d...@googlegroups.com
> Does it add it to amended ones?

Yes. I just tested it to make sure, and it works for me.


> It never has for me; I always have to git reset --soft HEAD^ and then commit again from scratch to get the change-id autogenerated.

Are you using the latest version of the hook?

Skip Montanaro

unread,
Jan 25, 2013, 12:22:55 PM1/25/13
to repo-d...@googlegroups.com

> How do I get this suggested Change-Id into the commit message?

Did you put it in your .git/hooks dir?  Did you give it execute permissions?

Thanks for all the responses.  I have no idea why Google Groups didn't notify me about them.  I'll just reply here, hoping to cover all the responses.

Yes, I scp'd the suggested file into the repositories .git/hooks directory and made sure it was executable.  I tried rebasing to squash the commits.  Still no Change-Id.  I eventually amended that commit and manually added the Change-Id suggested by Gerrit.  Then the push worked.

This morning I went to a git repo for another project and copied over the commit-msg hook from the above project.  Double-checked it was in the right directory and was executable, then made a small change to a comment in one file and committed.  Lo and behold, there was a Change-Id.  So, back to the original project's repo and make another nearly empty change and commit.  Once again, there is a Change-Id.

I still have no idea what was wrong yesterday, but basic commits seem to be doing the right thing now.  Back to the rebase issue.  I executed "git rebase -i HEAD~3", then picked the first commit and "squash"ed the other two.  I am now at the second commit edit.  Ignoring blank lines and comments, it looks like this:

more simple-exec stuff from svn
ignore pyc files
Test commit looking for Change-Id.
Change-Id: I89156c6309e357e0dfde0576c23a13dbcd2d9de3

That looks good to me, so exit the editor and run "git log".  Here's what I see:

commit f77348149f0df550e27a34f87277720e19a65ac4
Author: Skip Montanaro <...>
Date:   Wed Jan 23 11:15:23 2013 -0600

    more simple-exec stuff from svn

    ignore pyc files

    Test commit looking for Change-Id.

    Change-Id: I89156c6309e357e0dfde0576c23a13dbcd2d9de3

So, there is a Change-Id, but it's the one from the last simple commit.  Should I have removed it from the rebase commit message?

Back to project 'B' I was able to successfully rebase/squash, push my current  development branch, and create a review, so it appears my Gerrit/Git-fu is improving.

Thanks for the help.  I'm still not sure what was originally wrong, but it seems to have ironed itself out somehow.

Skip Montanaro
Reply all
Reply to author
Forward
0 new messages