Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2015-02-23 12:49:24 +0000
committerMatthias Sohn2015-02-24 15:39:19 +0000
commita8fd029a931f35db9f98e4f75530f299a70892eb (patch)
tree6b322847a5159e3a6b3f9a366322ab4b446ea49f /org.eclipse.jgit
parenta8743df19c2574bc3481fa5f811499b5960951a8 (diff)
downloadjgit-a8fd029a931f35db9f98e4f75530f299a70892eb.tar.gz
jgit-a8fd029a931f35db9f98e4f75530f299a70892eb.tar.xz
jgit-a8fd029a931f35db9f98e4f75530f299a70892eb.zip
Read user.name and email from environment first
According to [1] user name and email are taken first from the environment variables: GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL In case (some of) these environment variables are not set, the information is taken from the git configuration. JGit doesn not yet support the environment variables GIT_AUTHOR_DATE and GIT_COMMITTER_DATE. [1] https://www.kernel.org/pub/software/scm/git/docs/git-commit-tree.html#_commit_information Bug: 460586 Change-Id: I3ba582b4ae13674cf319652b5b13ebcbb96dd8ec Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/UserConfig.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/UserConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/UserConfig.java
index 60ac6f176d..b8d236c1da 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/UserConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/UserConfig.java
@@ -172,12 +172,13 @@ public class UserConfig {
}
private static String getNameInternal(Config rc, String envKey) {
- // try to get the user name from the local and global configurations.
- String username = rc.getString("user", null, "name"); //$NON-NLS-1$ //$NON-NLS-2$
+ // try to get the user name for the system property GIT_XXX_NAME
+ String username = system().getenv(envKey);
if (username == null) {
- // try to get the user name for the system property GIT_XXX_NAME
- username = system().getenv(envKey);
+ // try to get the user name from the local and global
+ // configurations.
+ username = rc.getString("user", null, "name"); //$NON-NLS-1$ //$NON-NLS-2$
}
return stripInvalidCharacters(username);
@@ -196,12 +197,12 @@ public class UserConfig {
}
private static String getEmailInternal(Config rc, String envKey) {
- // try to get the email from the local and global configurations.
- String email = rc.getString("user", null, "email"); //$NON-NLS-1$ //$NON-NLS-2$
+ // try to get the email for the system property GIT_XXX_EMAIL
+ String email = system().getenv(envKey);
if (email == null) {
- // try to get the email for the system property GIT_XXX_EMAIL
- email = system().getenv(envKey);
+ // try to get the email from the local and global configurations.
+ email = rc.getString("user", null, "email"); //$NON-NLS-1$ //$NON-NLS-2$
}
return stripInvalidCharacters(email);

Back to the top