Skip to content
Snippets Groups Projects
Commit cd91b70c authored by Georg Seibt's avatar Georg Seibt :nerd:
Browse files

add default options to the executed git command

core.quotePath and core.precomposeUnicode should remove unicode related problems caused by having to unquote paths
parent c466809a
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,10 @@ package de.uni_passau.fim.seibt.gitwrapper.repo; ...@@ -2,7 +2,10 @@ package de.uni_passau.fim.seibt.gitwrapper.repo;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Scanner; import java.util.Scanner;
...@@ -35,6 +38,7 @@ public class GitWrapper extends ToolWrapper { ...@@ -35,6 +38,7 @@ public class GitWrapper extends ToolWrapper {
private static final String GIT_VERSION_PREFIX = "git version"; private static final String GIT_VERSION_PREFIX = "git version";
private static final Map<String, String> env; private static final Map<String, String> env;
private static final List<String> defaultOptions;
static { static {
env = new HashMap<>(); env = new HashMap<>();
...@@ -43,6 +47,12 @@ public class GitWrapper extends ToolWrapper { ...@@ -43,6 +47,12 @@ public class GitWrapper extends ToolWrapper {
env.put("LANGUAGE", locale); env.put("LANGUAGE", locale);
env.put("LC_ALL", locale); env.put("LC_ALL", locale);
env.put("LANG", locale); env.put("LANG", locale);
defaultOptions = new ArrayList<>();
defaultOptions.add("-c");
defaultOptions.add("core.quotePath=false");
defaultOptions.add("-c");
defaultOptions.add("core.precomposeUnicode=true");
} }
/** /**
...@@ -206,16 +216,27 @@ public class GitWrapper extends ToolWrapper { ...@@ -206,16 +216,27 @@ public class GitWrapper extends ToolWrapper {
} }
/** /**
* Executes '&lt;git command&gt &lt;parameters&gt' and returns the exit code and the output of the command. If there is an * Executes '&lt;git command&gt &lt;firstParameter&gt &lt;parameters&gt' and returns the exit code and the output
* exception executing the command an empty {@link Optional} will be returned. * of the command. If there is an exception executing the command an empty {@link Optional} will be returned.
* *
* @param workingDirectory * @param workingDirectory
* the working directory for the command execution * the working directory for the command execution
* @param firstParameter
* the first git parameter
* @param parameters * @param parameters
* the git parameters * the git parameters
* @return the result of the execution * @return the result of the execution
*/ */
public Optional<ExecRes> exec(File workingDirectory, String... parameters) { public Optional<ExecRes> exec(File workingDirectory, String firstParameter, String... parameters) {
return exec(workingDirectory, true, env, asList(parameters)); List<String> pars = new ArrayList<>(defaultOptions.size() + ((parameters != null) ? parameters.length : 0));
pars.addAll(defaultOptions);
pars.add(firstParameter);
if (parameters != null) {
Collections.addAll(pars, parameters);
}
return exec(workingDirectory, true, env, pars);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment