[PATCH JGIT] New PersonIdent of a repository is the default committer

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

 



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@xxxxxxxxx>
---
 .../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

--
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