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
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/CherryPick.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/CherryPick.java
index 6913f77..d34d1e3 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/CherryPick.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/CherryPick.java
@@ -142,15 +142,16 @@
final PatchSetApproval submitAudit = args.mergeUtil.getSubmitter(n);
IdentifiedUser cherryPickUser;
+ PersonIdent serverNow = args.serverIdent.get();
PersonIdent cherryPickCommitterIdent;
if (submitAudit != null) {
cherryPickUser =
args.identifiedUserFactory.create(submitAudit.getAccountId());
cherryPickCommitterIdent = cherryPickUser.newCommitterIdent(
- submitAudit.getGranted(), args.serverIdent.get().getTimeZone());
+ serverNow.getWhen(), serverNow.getTimeZone());
} else {
cherryPickUser = args.identifiedUserFactory.create(n.change().getOwner());
- cherryPickCommitterIdent = args.serverIdent.get();
+ cherryPickCommitterIdent = serverNow;
}
final String cherryPickCmtMsg = args.mergeUtil.createCherryPickCommitMessage(n);
@@ -234,4 +235,4 @@
return args.mergeUtil.canCherryPick(args.mergeSorter, args.repo,
mergeTip, args.rw, toMerge);
}
-}
+}
\ No newline at end of file