سؤال

I made a fatal mistake using Gerrit and was wondering if anybody could provide a solution/idea to this:

Current situation is that I have a branch feature-foo onto which our team is pushing changes for review. Some of these changes are already submitted/merged, and a great number is still open for review. Now, yesterday I decided to push a patchset to a specific change, one that has around 15 preceeding changes (not merged yet).

I accidentally pushed past code review (yes, I do have these permissions, and yes I was stupid enough to not deactivate them for my own safety - lesson learned). This resulted in those 15 changes/commits to be pushed directly onto the branch instead of into code review. So now all those changes are marked MERGED in Gerrit. My immediate idea was to do a push -f using the commit that I knew was originally the tip of feature-foo.

This correctly reset the branch to where it was supposed to be. But - those 15 changes are still marked MERGED in Gerrit. What I want: I need those changes to be back to state "Review in Progress", because they are in fact still being worked on.

Any ideas, anybody? I cannot imagine that this has not happened to somebody before...

regards,

--qu

EDIT 1: To clarify - the incorrectly pushed commit resulted in a fast-forward - not a merge. Nevertheless, for Gerrit those changes/commits are still "MERGED", as if somebody pressed "Submit Change" in the Gerrit-Webinterface. So - this question is in fact about Gerrit, not Git itself.

keywords: accidental push, accidental merge

هل كانت مفيدة؟

المحلول 3

Well, it turns out that this did the trick:

  1. Reset the branch to where it is supposed to be (force push past code review)
  2. Power down Gerrit, access the underlying H2 database and reset the Status of all affected Change-IDs to "Review in Progress" (standard SQL, use project name, branch name and Change-ID in the WHERE-Clause).

نصائح أخرى

The only way I know is to push it again, using a new Change-Id. This results in a new change being opened.

Update for Gerrit 3+ (using NoteDB):

When submitting a change (or even just pushing it, apparently) Gerrit creates a new patchset to a change, which comes with a "merged" attribute. This needs to be undone.

For a changeset 12345, you'll need to check out the git history of refs/changes/45/12345/meta. That "branch" contains the discussion to the changeset.

By resetting that branch to the last commit before the submission (the submission should have a message like "Create patch set 2", with an attribute "Status: merged" - take its parent) you remove all knowledge that the change has ever been merged.

You might have to flush the caches, too - I just did "gerrit flush-caches --all" on the SSH interface to be sure.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top