diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2018-11-28 11:06:08 +0100 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2018-11-30 00:37:03 +0100 |
commit | 9c755c9e7c6905013aa03df1089ea0b93d3241ce (patch) | |
tree | f618a1db9a98180eccee1aefdbd8d018105d5f5e /org.eclipse.jgit | |
parent | 12d840dfcb0ea88d64eb05a564b5bf43ac81efac (diff) | |
download | jgit-9c755c9e7c6905013aa03df1089ea0b93d3241ce.tar.gz jgit-9c755c9e7c6905013aa03df1089ea0b93d3241ce.zip |
Set git environment variables for hooks
Set GIT_DIR and GIT_WORK_TREE when calling hooks.
Bug: 541622
Change-Id: I6153d8a6a934ec37a3a5e7319c2d0e516f539ab7
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index 7f0308f071..e864ba76c1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -1110,6 +1110,13 @@ public abstract class FS { hookPath); ProcessBuilder hookProcess = runInShell(cmd, args); hookProcess.directory(runDirectory); + Map<String, String> environment = hookProcess.environment(); + environment.put(Constants.GIT_DIR_KEY, + repository.getDirectory().getAbsolutePath()); + if (!repository.isBare()) { + environment.put(Constants.GIT_WORK_TREE_KEY, + repository.getWorkTree().getAbsolutePath()); + } try { return new ProcessResult(runProcess(hookProcess, outRedirect, errRedirect, stdinArgs), Status.OK); |