Don't create a new commit when creating an edit
The first step to make an edit just needs to establish the ref. There is no need to immediately amend the commit with the caller as committer. After creating the edit ref another operation will happen to record a new message or a new file contents, and that will write out a new (amended) commit object for the caller. Change-Id: I7b51e813ece58ecdbc6e75e0e19b49a25f513247
This commit is contained in:
@@ -24,6 +24,7 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GitUtil.Commit;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.RestSession;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.server.change.GetRelated.ChangeAndCommit;
|
||||
@@ -166,6 +167,8 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
||||
|
||||
Change ch2 = getChange(c2);
|
||||
editModifier.createEdit(ch2, getPatchSet(ch2));
|
||||
editModifier.modifyFile(editUtil.byChange(ch2).get(), "a.txt",
|
||||
RestSession.newRawInput(new byte[] {'a'}));
|
||||
String editRev = editUtil.byChange(ch2).get().getRevision().get();
|
||||
|
||||
List<ChangeAndCommit> related = getRelated(ch2.getId(), 0);
|
||||
|
@@ -124,18 +124,13 @@ public class ChangeEditModifier {
|
||||
}
|
||||
|
||||
RevWalk rw = new RevWalk(repo);
|
||||
ObjectInserter inserter = repo.newObjectInserter();
|
||||
try {
|
||||
RevCommit revision = rw.parseCommit(ObjectId.fromString(
|
||||
ps.getRevision().get()));
|
||||
ObjectId commit = createCommit(me, inserter, revision, revision.getTree());
|
||||
inserter.flush();
|
||||
ObjectId revision = ObjectId.fromString(ps.getRevision().get());
|
||||
String editRefName = editRefName(me.getAccountId(), change.getId(),
|
||||
ps.getId());
|
||||
return update(repo, me, editRefName, rw, ObjectId.zeroId(), commit);
|
||||
return update(repo, me, editRefName, rw, ObjectId.zeroId(), revision);
|
||||
} finally {
|
||||
rw.release();
|
||||
inserter.release();
|
||||
}
|
||||
} finally {
|
||||
repo.close();
|
||||
|
Reference in New Issue
Block a user