Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: 108: Command line tools fon't run with Cygwin git #170

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -24,7 +24,14 @@
DIR=$(dirname "${0}")
OS=$(uname)

if [ "${OS}" = "Linux" -o "${OS}" = "Darwin" ]; then
case "${OS}" in
Linux) USEBAT=0 ;;
Darwin) USEBAT=0 ;;
CYGWIN*) USEBAT=0 ;;
*) USEBAT=1 ;;
esac

if [ ${USEBAT} -eq 0 ]; then
if [ ! -x "${DIR}/bin/bin/git-skara" ]; then
echo "Compiling ..."
(cd "${DIR}" && sh gradlew)
@@ -42,8 +49,8 @@ if [ -d "${DIR}/build" ]; then
mv "${DIR}/build" "${DIR}/bin"
fi

if [ "${OS}" = "Linux" -o "${OS}" = "Darwin" ]; then
if [ ${USEBAT} -eq 0 ]; then
exec "${DIR}/bin/bin/git-skara" "${@}"
else
exec "${DIR}/bin/bin/git-skara.bat" "${@}"
fi
fi
@@ -108,6 +108,7 @@ private static void await(java.lang.Process p) throws IOException {
}

public GitRepository(Path dir) {
System.err.println("DEBUG: GitRepository: dir = " + dir);
this.dir = dir.toAbsolutePath();
}

@@ -446,12 +447,23 @@ public Path root() throws IOException {
if (res2.stdout().size() != 1) {
throw new IOException("Unexpected output\n" + res2);
}
// CYGWIN: FIXME: map cygwin path to Windows path
cachedRoot = dir.resolve(Path.of(res2.stdout().get(0)));
return cachedRoot;
}
}

cachedRoot = Path.of(res.stdout().get(0));
// CYGWIN: map cygwin path to Windows path (OK to use `/`)
// FIXME: only do this if using Cygwin git, and use cygpath
var cygPrefix = "/cygdrive/c";
var dirString = res.stdout().get(0);
System.err.println("DEBUG: root dir = " + dirString);
if (dirString.startsWith(cygPrefix + "/")) {
dirString = "C:" + dirString.substring(cygPrefix.length());
System.err.println("DEBUG: converted root dir = " + dirString);
}
cachedRoot = Path.of(dirString);
System.err.println("DEBUG: root path = " + cachedRoot);
return cachedRoot;
}
}
@@ -651,7 +663,9 @@ public void rebase(Hash hash, String committerName, String committerEmail) throw

@Override
public Optional<Hash> resolve(String ref) throws IOException {
try (var p = capture("git", "rev-parse", ref + "^{commit}")) {
// CYGWIN: need to escape the { and }
// FIXME: only do this if using Cygwin git
try (var p = capture("git", "rev-parse", ref + "^\\{commit\\}")) {
var res = p.await();
if (res.status() == 0 && res.stdout().size() == 1) {
return Optional.of(new Hash(res.stdout().get(0)));
@@ -701,7 +715,9 @@ public Branch defaultBranch() throws IOException {
}

private String treeEntry(Path path, Hash hash) throws IOException {
try (var p = Process.capture("git", "ls-tree", hash.hex(), path.toString())
// CYGWIN: map `\` to `/`
// FIXME: only do this if using Cygwin git
try (var p = Process.capture("git", "ls-tree", hash.hex(), path.toString().replace("\\", "/"))
.workdir(root())
.execute()) {
var res = await(p);
@@ -719,7 +735,9 @@ private String treeEntry(Path path, Hash hash) throws IOException {
var cmd = new ArrayList<String>();
cmd.addAll(List.of("git", "ls-tree", "-r"));
cmd.add(hash.hex());
cmd.addAll(paths.stream().map(Path::toString).collect(Collectors.toList()));
// CYGWIN: map `\` to `/`
// FIXME: only do this if using Cygwin git
cmd.addAll(paths.stream().map(Path::toString).map(s -> s.replace("\\", "/")).collect(Collectors.toList()));
try (var p = Process.capture(cmd.toArray(new String[0]))
.workdir(root())
.execute()) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.