diff --git a/src/main/java/nl/andrewl/distribugit/RepositoryAction.java b/src/main/java/nl/andrewl/distribugit/RepositoryAction.java
index 21fe36e..3e24413 100644
--- a/src/main/java/nl/andrewl/distribugit/RepositoryAction.java
+++ b/src/main/java/nl/andrewl/distribugit/RepositoryAction.java
@@ -17,6 +17,16 @@ public interface RepositoryAction {
* An action which executes a system command, as handled by
* {@link ProcessBuilder}. Note that the working directory of the command
* is set to the directory of the repository.
+ *
+ * Commands invoked via this method have access to the following
+ * environment variables:
+ *
+ *
+ * - DISTRIBUGIT_INVOKE_DIR - The directory in which distribugit
+ * was invoked.
+ * - DISTRIBUGIT_WORKING_DIR - The working directory of distribugit,
+ * which contains all repositories.
+ *
* @param command The command to run.
* @return The command action.
*/
@@ -24,6 +34,8 @@ public interface RepositoryAction {
return git -> {
ProcessBuilder pb = new ProcessBuilder(command);
pb.directory(git.getRepository().getWorkTree());
+ pb.environment().put("DISTRIBUGIT_INVOKE_DIR", pb.directory().getParentFile().getParentFile().getAbsolutePath());
+ pb.environment().put("DISTRIBUGIT_WORKING_DIR", pb.directory().getParentFile().getAbsolutePath());
pb.inheritIO();
Process p = pb.start();
int result = p.waitFor();