[JGIT PATCH 2/3] Allow the reflog identity to be set in ReceivePack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daemons which run ReceivePack can now set the identity used to
record updates in the reflog of any affected refs.  If not set
then it defaults to the repository owner's identity, or that
of the running JVM.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 .../org/spearce/jgit/transport/ReceivePack.java    |   26 ++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
index bb6bf26..ba09366 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
@@ -57,6 +57,7 @@
 import org.spearce.jgit.lib.Constants;
 import org.spearce.jgit.lib.NullProgressMonitor;
 import org.spearce.jgit.lib.ObjectId;
+import org.spearce.jgit.lib.PersonIdent;
 import org.spearce.jgit.lib.Ref;
 import org.spearce.jgit.lib.RefComparator;
 import org.spearce.jgit.lib.RefUpdate;
@@ -94,6 +95,9 @@
 	/** Should an incoming transfer permit non-fast-forward requests? */
 	private boolean allowNonFastForwards;
 
+	/** Identity to record action as within the reflog. */
+	private PersonIdent refLogIdent;
+
 	/** Hook to validate the update commands before execution. */
 	private PreReceiveHook preReceive;
 
@@ -221,6 +225,27 @@ public void setAllowNonFastForwards(final boolean canRewind) {
 		allowNonFastForwards = canRewind;
 	}
 
+	/** @return identity of the user making the changes in the reflog. */
+	public PersonIdent getRefLogIdent() {
+		return refLogIdent;
+	}
+
+	/**
+	 * Set the identity of the user appearing in the affected reflogs.
+	 * <p>
+	 * The timestamp portion of the identity is ignored. A new identity with the
+	 * current timestamp will be created automatically when the updates occur
+	 * and the log records are written.
+	 * 
+	 * @param pi
+	 *            identity of the user. If null the identity will be
+	 *            automatically determined based on the repository
+	 *            configuration.
+	 */
+	public void setRefLogIdent(final PersonIdent pi) {
+		refLogIdent = pi;
+	}
+
 	/** @return get the hook invoked before updates occur. */
 	public PreReceiveHook getPreReceiveHook() {
 		return preReceive;
@@ -645,6 +670,7 @@ private void executeCommands() {
 	private void execute(final ReceiveCommand cmd) {
 		try {
 			final RefUpdate ru = db.updateRef(cmd.getRefName());
+			ru.setRefLogIdent(getRefLogIdent());
 			switch (cmd.getType()) {
 			case DELETE:
 				if (!ObjectId.zeroId().equals(cmd.getOldId())) {
-- 
1.6.1.2.492.g8554a

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux