Newbie question:How can I "repo upload" a issue-fixed commit?

794 views
Skip to first unread message

Chunlin Zhang

unread,
Feb 20, 2011, 11:02:22 PM2/20/11
to repo-d...@googlegroups.com
The case is that:I have "repo upload" a commit,but this commit is set to "ABANDONED",and I modify some code and "git commit" a issue-fixed commit,that I do "repo upload",and it just upload the second commit,if this commit review/verify ok,it will be "Change could not be merged because of a missing dependency."

Should the first commit be "Restore Change"?

And how will you do in this kind of case?

Thanks!

Luciano Carvalho

unread,
Feb 21, 2011, 9:56:12 AM2/21/11
to repo-d...@googlegroups.com

Instead of pushing a new change, I should have pushed a replacement patch to the first change you already had. Containing the contents of both the first patch and the fix.

If the new patch is a fix on top of the first one and you want to keep them separate, then yes, you must merge the first change before you're able to merge the second one.

sogan xie

unread,
Feb 21, 2011, 3:25:00 AM2/21/11
to repo-d...@googlegroups.com
Did you want to upload the two commits? Right?
If yes, you should merge the two commits into one point.

--



--
B.R.
Sogan.X
------------------------------------
Mail:    sog...@gmail.com


Chunlin Zhang

unread,
Feb 24, 2011, 12:51:46 AM2/24/11
to repo-d...@googlegroups.com, Luciano Carvalho
Git squash means "git commit --amend",is it?
I try this way,but at last fail.
Fail message:
----
testuser@testuser2:/media/linux/t/mtk$ repo upload
Upload project build/:
branch mytest_amend ( 1 commit, Thu Feb 24 13:20:40 2011 +0800):
7569a318 --amend test step 1,now add step 2
to 10.125.3.11:8080 (y/n)? y
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 370 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To ssh://test...@10.125.3.11:29418/platform/build
! [remote rejected] mytest_amend -> refs/for/master (no new changes)
error: failed to push some refs to
'ssh://test...@10.125.3.11:29418/platform/build'

----------------------------------------------------------------------
[FAILED] build/ mytest_amend (Upload failed)
----

And the git log graph is:
----
testuser@testuser2:/media/linux/t/mtk/build$ git log --all --graph
* commit 7569a3181a69ff8f92cbcd70275b219eec3ece3c
| Author: testuser <test...@mycompany.com>
| Date: Thu Feb 24 11:59:10 2011 +0800
|
| --amend test step 1,now add step 2
|
| Change-Id: Ia11c652c91c22b68fff5beebf2e578a4534e297f
|
| * commit 49969b735eafe1d59738bd74272ddac763b355fd
|/ Author: testuser <test...@mycompany.com>
| Date: Thu Feb 24 11:59:10 2011 +0800
|
| --amend test step 1
|
| Change-Id: Ia11c652c91c22b68fff5beebf2e578a4534e297f
|
* commit 7c6d302691e226e0d9d7c78c9991892ddb087796
Author: testuser <test...@mycompany.com>
Date: Fri Feb 11 16:42:51 2011 +0800

init with build
----

So have I made some mistake?
And the change-id after amend is same.

On Tue, Feb 22, 2011 at 11:41 PM, Luciano Carvalho <lsca...@gmail.com> wrote:
> Not merge, but squash.
> Squash the commits keeping the first Change-Id in the commit message, then
> repo upload.
>
> On Feb 22, 2011 1:51 AM, "Chunlin Zhang" <zhangc...@gmail.com> wrote:


>> On Mon, Feb 21, 2011 at 10:56 PM, Luciano Carvalho <lsca...@gmail.com>
>> wrote:
>>> Instead of pushing a new change, I should have pushed a replacement patch
>>> to
>>> the first change you already had. Containing the contents of both the
>>> first
>>> patch and the fix.

>> So I should "repo start" a new branch,merge previous commit and the
>> issue-fixed commit to one,then "repo upload"?
>> I will try this way.

Ragesh For U :-)

unread,
Feb 24, 2011, 1:28:01 AM2/24/11
to Chunlin Zhang, repo-d...@googlegroups.com, Luciano Carvalho
The error "(no new changes)" is since the "change ID : Ia11c652c91c22b68fff5beebf2e578a4534e297f" is already in Merge state.
You should remove that line also while amend.

-Ragesh

Matthias Sohn

unread,
Feb 24, 2011, 1:41:09 AM2/24/11
to Chunlin Zhang, repo-d...@googlegroups.com, Luciano Carvalho
2011/2/24 Chunlin Zhang <zhangc...@gmail.com>

Git squash means "git commit --amend",is it?

no, squashing commits means you meld the diffs of multiple subsequent
changes into one using "git rebase -i"

So if this is your intention try the following:

$ git rebase -i HEAD~2

an editor will come up showing the last two commits (only do that with
commits which have not yet been submitted to master in Gerrit as
git rebase -i will rewrite these changes). Then replace "pick" by "squash"
for the commit "--amend test step 1,now add step 2" (the one HEAD is
pointing at) and save the editor. Another editor will come up so that
you can meld the two commit messages into one. Ensure that you remove
the Change-Id of commit "--amend test step 1,now add step 2" so that
your new squashed commit can replace the Gerrit change for the first
commit. Then push this to Gerrit, the squashed commit should end up
as a new patchset of the first change.
 
I try this way,but at last fail.
Fail message:
----
testuser@testuser2:/media/linux/t/mtk$ repo upload
Upload project build/:
 branch mytest_amend ( 1 commit, Thu Feb 24 13:20:40 2011 +0800):
        7569a318 --amend test step 1,now add step 2
to 10.125.3.11:8080 (y/n)? y
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 370 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To ssh://test...@10.125.3.11:29418/platform/build
 ! [remote rejected] mytest_amend -> refs/for/master (no new changes)
error: failed to push some refs to
'ssh://test...@10.125.3.11:29418/platform/build'

this means Gerrit didn't get anything new compared to what you pushed
before.
 
----------------------------------------------------------------------
[FAILED] build/          mytest_amend    (Upload failed)
----

And the git log graph is:
----
testuser@testuser2:/media/linux/t/mtk/build$ git log --all --graph
* commit 7569a3181a69ff8f92cbcd70275b219eec3ece3c
| Author: testuser <test...@mycompany.com>
| Date:   Thu Feb 24 11:59:10 2011 +0800
|
|     --amend test step 1,now add step 2
|
|     Change-Id: Ia11c652c91c22b68fff5beebf2e578a4534e297f
|
| * commit 49969b735eafe1d59738bd74272ddac763b355fd
|/  Author: testuser <test...@mycompany.com>
|   Date:   Thu Feb 24 11:59:10 2011 +0800
|
|       --amend test step 1
|
|       Change-Id: Ia11c652c91c22b68fff5beebf2e578a4534e297f
|
* commit 7c6d302691e226e0d9d7c78c9991892ddb087796
 Author: testuser <test...@mycompany.com>
 Date:   Fri Feb 11 16:42:51 2011 +0800

     init with build
----

So have I made some mistake?
And the change-id after amend is same.

If there is a change-id in a commit, neither gerrit commit message hook
nor Gerrit itself will replace it. If you want a new one amend the commit
to remove the change-id from the commit. Then you will get a new Gerrit
change when pushing this to Gerrit.

--
Matthias

Chunlin Zhang

unread,
Feb 24, 2011, 3:59:59 AM2/24/11
to repo-d...@googlegroups.com
Thank you for your detailed explain.
I try "git rebase -i HEAD~2" and success to squash a new commit into
the one before,and upload/submit OK,at last "Change has been
successfully merged into the git repository."

Chunlin Zhang

unread,
Feb 24, 2011, 4:14:25 AM2/24/11
to repo-d...@googlegroups.com
On Thu, Feb 24, 2011 at 2:28 PM, Ragesh For U :-) <rage...@gmail.com> wrote:
> The error "(no new changes)" is since the "change ID :
> Ia11c652c91c22b68fff5beebf2e578a4534e297f" is already in Merge state.
> You should remove that line also while amend.

Yes,this way is also OK for squash.
After remove the change-id line,gerrit treat the commit after amend as
a different commit.

Thank you!
> -Ragesh

Reply all
Reply to author
Forward
0 new messages