Re: [PATCH JGIT] Propose author and committer in the commit dialog

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

 



Yann Simon <yann.simon.fr@xxxxxxxxx> wrote:
> 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..8438683 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java
> @@ -57,16 +57,6 @@
>  
>  	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
>  	 * 
> @@ -74,14 +64,8 @@ private static String getHostName() {
>  	 */
>  	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();
> -
> +		String username = config.getAuthorName();
> +		String email = config.getAuthorEmail();
>  		name = username;
>  		emailAddress = email;
>  		when = System.currentTimeMillis();

Heh.  I meant to write this patch myself yesterday but got
sidetracked and forgot.  Thanks.

Its unrelated to the other changes you were making.  Please submit
it as its own patch.

Aren't the local "username" and "email" variables now redundant?
Can't we just assign directly to the fields in the object?

Also, I think you should be using getCommitter{Name,Email} here
by default.  Sometimes people override the GIT_AUTHOR_* variables
in order to apply patches from others, but they almost never set the
GIT_COMMITTER_* variables.  We're using this constructor to create an
identity for use in commit objects, tag objects, or for the reflog.
All three prefer the committer name over the author name.

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