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

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

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 6, 2009, 15:38 UTC
Message-ID
<20090206153849.GN26880@spearce.org>
In-Reply-To
<498C2BE5.3010602@gmail.com>
Yann Simon <yann.simon.fr@gmail.com> wrote:
Show 38 quoted lines
> 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.
Previous: Yann Simon
Message 2 of 2 in “Propose author and committer in the commit dialog”
  1. Propose author and committer in the commit dialogYann Simon, Feb 6, 2009
  2. Shawn O. PearceFeb 6, 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.