From f5bd5f5a60fe570f746488c96e529c86cbd968a3 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Mon, 18 May 2026 19:07:17 -0500 Subject: [PATCH] Run rebase sequence editor through shell --- app/build.gradle.kts | 4 ++-- .../solutions/tretter/githugandroid/GitRuntime.kt | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3dacbd8..e29f087 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -19,8 +19,8 @@ android { applicationId = "solutions.tretter.githugandroid" minSdk = 26 targetSdk = 35 - versionCode = 148 - versionName = "0.1.147" + versionCode = 149 + versionName = "0.1.148" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/solutions/tretter/githugandroid/GitRuntime.kt b/app/src/main/java/solutions/tretter/githugandroid/GitRuntime.kt index aa5a2f5..d0520a9 100644 --- a/app/src/main/java/solutions/tretter/githugandroid/GitRuntime.kt +++ b/app/src/main/java/solutions/tretter/githugandroid/GitRuntime.kt @@ -333,7 +333,7 @@ class GitRepositoryRuntime private constructor( |cat ${todoFile.absolutePath.toShellSingleQuoted()} > "$1" |""".trimMargin(), ) - setExecutable(true, true) + setReadable(true, true) } val arguments = GitSandboxEngine.tokenizeCommand(invocation.command).drop(1) val result = runGit( @@ -341,7 +341,7 @@ class GitRepositoryRuntime private constructor( workingDir, arguments, mapOf( - "GIT_SEQUENCE_EDITOR" to editorScript.absolutePath, + "GIT_SEQUENCE_EDITOR" to "${shellExecutable().toShellSingleQuoted()} ${editorScript.absolutePath.toShellSingleQuoted()}", "GIT_EDITOR" to "true", ), ) @@ -943,6 +943,14 @@ class GitRepositoryRuntime private constructor( return "'" + replace("'", "'\"'\"'") + "'" } + private fun shellExecutable(): String { + return when { + context != null -> "/system/bin/sh" + File("/bin/sh").exists() -> "/bin/sh" + else -> "sh" + } + } + private fun runGit( binary: File, workingDir: File,