Use current time for cherry picked commits
Cherry picking with the submitter time could cause massive clock skew in the Git commit graph if the server is shutdown before the submit can finish, and restarted hours later. In such a case Gerrit will write out new cherry picks using hour-old committer times. This can confuse a Git revision walker if there are many such badly dated commits, more than the "slop bucket" the revision walker can tolerate (5-10). Updating the commit time on each attempt also allows this strategy to work around bugs elsewhere in Gerrit that does not handle patch sets with the same commit SHA-1 well. Each new retry will get a new SHA-1, as the timestamp is updated. Change-Id: Ia0be365054cdc4692a8f5aa2afc2fb87f2e7888a
This commit is contained in:
@@ -142,15 +142,16 @@ public class CherryPick extends SubmitStrategy {
|
|||||||
final PatchSetApproval submitAudit = args.mergeUtil.getSubmitter(n);
|
final PatchSetApproval submitAudit = args.mergeUtil.getSubmitter(n);
|
||||||
|
|
||||||
IdentifiedUser cherryPickUser;
|
IdentifiedUser cherryPickUser;
|
||||||
|
PersonIdent serverNow = args.serverIdent.get();
|
||||||
PersonIdent cherryPickCommitterIdent;
|
PersonIdent cherryPickCommitterIdent;
|
||||||
if (submitAudit != null) {
|
if (submitAudit != null) {
|
||||||
cherryPickUser =
|
cherryPickUser =
|
||||||
args.identifiedUserFactory.create(submitAudit.getAccountId());
|
args.identifiedUserFactory.create(submitAudit.getAccountId());
|
||||||
cherryPickCommitterIdent = cherryPickUser.newCommitterIdent(
|
cherryPickCommitterIdent = cherryPickUser.newCommitterIdent(
|
||||||
submitAudit.getGranted(), args.serverIdent.get().getTimeZone());
|
serverNow.getWhen(), serverNow.getTimeZone());
|
||||||
} else {
|
} else {
|
||||||
cherryPickUser = args.identifiedUserFactory.create(n.change().getOwner());
|
cherryPickUser = args.identifiedUserFactory.create(n.change().getOwner());
|
||||||
cherryPickCommitterIdent = args.serverIdent.get();
|
cherryPickCommitterIdent = serverNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String cherryPickCmtMsg = args.mergeUtil.createCherryPickCommitMessage(n);
|
final String cherryPickCmtMsg = args.mergeUtil.createCherryPickCommitMessage(n);
|
||||||
@@ -234,4 +235,4 @@ public class CherryPick extends SubmitStrategy {
|
|||||||
return args.mergeUtil.canCherryPick(args.mergeSorter, args.repo,
|
return args.mergeUtil.canCherryPick(args.mergeSorter, args.repo,
|
||||||
mergeTip, args.rw, toMerge);
|
mergeTip, args.rw, toMerge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user