git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 4, 2009, 23:15 UTC
Message-ID
<1233789342-28079-2-git-send-email-spearce@spearce.org>
In-Reply-To
<1233789342-28079-1-git-send-email-spearce@spearce.org>

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@spearce.org>
---
 .../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
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 2 of 3 in “Allow RefUpdate callers to control the PersonIdent recorded”
  1. 1/3 Allow RefUpdate callers to control the PersonIdent recordedShawn O. Pearce, Feb 4, 2009
  2. 2/3 Allow the reflog identity to be set in ReceivePackShawn O. Pearce, Feb 4, 2009
  3. 3/3 Record pushes done over anonymous git:// using peer IPShawn O. Pearce, Feb 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.