git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yann Simon <yann.simon.fr@gmail.com>
To: Robin Rosenberg <robin.rosenberg.lists@dewire.com>,
	"Shawn O. Pearce" <spearce@spearce.org>
Cc: git <git@vger.kernel.org>
Subject: [PATCH JGIT] New PersonIdent of a repository is the default committer
Date: Fri, 06 Feb 2009 17:04:18 +0100	[thread overview]
Message-ID: <498C5F82.2040205@gmail.com> (raw)

The constructor PersonIdent(Repository) uses the default values
from the configuration of the repository.

The new instance gets the name and the email of the default committer.

Signed-off-by: Yann Simon <yann.simon.fr@gmail.com>
---
 .../src/org/spearce/jgit/lib/PersonIdent.java      |   26 ++++----------------
 1 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java
index bc5479a..fb4ab20 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java
@@ -57,33 +57,17 @@
 
 	private final int tzOffset;
 
-	private static String getHostName() {
-		try {
-			java.net.InetAddress addr = java.net.InetAddress.getLocalHost();
-			String hostname = addr.getCanonicalHostName();
-			return hostname;
-		} catch (java.net.UnknownHostException e) {
-			return "localhost";
-		}
-	}
-
 	/**
-	 * Creates new PersonIdent from config info in repository, with current time
+	 * Creates new PersonIdent from config info in repository, with current time.
+	 * This new PersonIdent gets the info from the default committer as available
+	 * from the configuration.
 	 * 
 	 * @param repo
 	 */
 	public PersonIdent(final Repository repo) {
 		RepositoryConfig config = repo.getConfig();
-		String username = config.getString("user", null, "name");
-		if (username == null)
-			username = System.getProperty("user.name");
-
-		String email = config.getString("user", null, "email");
-		if (email == null)
-			email = System.getProperty("user.name") + "@" + getHostName();
-
-		name = username;
-		emailAddress = email;
+		name = config.getCommitterName();
+		emailAddress = config.getCommitterEmail();
 		when = System.currentTimeMillis();
 		tzOffset = TimeZone.getDefault().getOffset(when) / (60 * 1000);
 	}
-- 
1.6.0.4

                 reply	other threads:[~2009-02-06 16:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=498C5F82.2040205@gmail.com \
    --to=yann.simon.fr@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=robin.rosenberg.lists@dewire.com \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).