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

Re: [PATCH JGIT] Compute the author/commiter name and email from the git configuration

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 3, 2009, 23:20 UTC
Message-ID
<alpine.DEB.1.00.0902040019030.9822@pacific.mpi-cbg.de>
In-Reply-To
<20090203231357.GZ26880@spearce.org>
Hi,
On Tue, 3 Feb 2009, Shawn O. Pearce wrote:
Show 33 quoted lines
> Yann Simon <yann.simon.fr@gmail.com> wrote:
>
> > @@ -308,6 +312,83 @@ public String getString(final String section, String subsection, final String na
> >  		return result;
> >  	}
> >  
> > +	/**
> > +	 * @return the author name as defined in the git variables
> > +	 *         and configurations. If no name could be found, try
> > +	 *         to use the system user name instead.
> > +	 */
> > +	public String getAuthorName() {
> > +		return getUsernameInternal(Constants.GIT_AUTHOR_NAME_KEY);
> > +	}
> > +
> > +	/**
> > +	 * @return the commiter name as defined in the git variables
> > +	 *         and configurations. If no name could be found, try
> > +	 *         to use the system user name instead.
> > +	 */
> > +	public String getCommiterName() {
> > +		return getUsernameInternal(Constants.GIT_COMMITER_NAME_KEY);
> > +	}
> > +
> > +	private String getUsernameInternal(String gitVariableKey) {
> > +		// try to get the user name from the local and global configurations.
> > +		String username = getString("user", null, "name");
> > +
> > +		if (username == null) {
> > +			// try to get the user name for the system property GIT_XXX_NAME 
> > +			username = System.getProperty(gitVariableKey);
> 
> Shouldn't that be System.getenv()?
According to
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getenv(java.lang.String)

getenv() is deprecated. However, in later editions (Java5 and later, to be precise), that deprecation seems to be lifted...

Ciao, Dscho

Previous: Shawn O. PearceNext: Robin Rosenberg
Message 3 of 10 in “Compute the author/commiter name and email from the git configuration”
  1. Compute the author/commiter name and email from the git configurationYann Simon, Feb 3, 2009
  2. Shawn O. PearceFeb 3, 2009
  3. Johannes SchindelinFeb 3, 2009
  4. Robin RosenbergFeb 4, 2009
  5. Shawn O. PearceFeb 4, 2009
  6. Shawn O. PearceFeb 4, 2009
  7. Robin RosenbergFeb 4, 2009
  8. Yann SimonFeb 4, 2009
  9. Yann SimonFeb 4, 2009
  10. Yann SimonFeb 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.