From 11c62dd2484d16cd4cce471166765b8550873956 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 21 Apr 2016 19:32:02 -0400 Subject: [PATCH] git: Patch to enable repos on shared filesystems Fixes #227. --- packages/git/build.sh | 2 +- packages/git/config.c.patch | 58 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 packages/git/config.c.patch diff --git a/packages/git/build.sh b/packages/git/build.sh index 0bb5c365..47dd68b3 100755 --- a/packages/git/build.sh +++ b/packages/git/build.sh @@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Distributed version control system designed to handle ev # less is required as a pager for git log, and the busybox less does not handle used escape sequences. TERMUX_PKG_DEPENDS="libcurl, less" TERMUX_PKG_VERSION=2.8.1 -TERMUX_PKG_BUILD_REVISION=1 +TERMUX_PKG_BUILD_REVISION=2 TERMUX_PKG_SRCURL=https://www.kernel.org/pub/software/scm/git/git-${TERMUX_PKG_VERSION}.tar.xz ## This requires a working $TERMUX_PREFIX/bin/sh on the host building: TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--without-tcltk --with-curl --with-shell=$TERMUX_PREFIX/bin/sh ac_cv_header_libintl_h=no ac_cv_fread_reads_directories=yes ac_cv_snprintf_returns_bogus=yes" diff --git a/packages/git/config.c.patch b/packages/git/config.c.patch new file mode 100644 index 00000000..05db6356 --- /dev/null +++ b/packages/git/config.c.patch @@ -0,0 +1,58 @@ +diff -u -r ../git-2.8.1/config.c ./config.c +--- ../git-2.8.1/config.c 2016-04-03 15:07:18.000000000 -0400 ++++ ./config.c 2016-04-21 18:37:26.707906688 -0400 +@@ -49,6 +49,25 @@ + */ + static struct config_set the_config_set; + ++/* ++ * Protecting the project-specific git configuration file (.git/config) is ++ * not possible on a shared file system on Android, which on an unpatched ++ * git causes operations such as clone to fail with an error message. ++ * ++ * For the Termux git package we introduce a warning about the configuration ++ * file being unprotected, but proceed in order to allow git repositories ++ * to be cloned to shared storage accessible to other apps. ++ */ ++static void termux_warn_once_about_lockfile() ++{ ++ static int already_warned; ++ if (!already_warned) { ++ warning("Cannot protect .git/config on this file system" ++ " - do not store sensitive information here."); ++ already_warned = 1; ++ } ++} ++ + static int config_file_fgetc(struct config_source *conf) + { + return getc_unlocked(conf->u.file); +@@ -2125,10 +2147,14 @@ + in_fd = -1; + + if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) { ++#ifdef __ANDROID__ ++ termux_warn_once_about_lockfile(); ++#else + error("chmod on %s failed: %s", + get_lock_file_path(lock), strerror(errno)); + ret = CONFIG_NO_WRITE; + goto out_free; ++#endif + } + + if (store.seen == 0) +@@ -2330,9 +2356,13 @@ + fstat(fileno(config_file), &st); + + if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) { ++#ifdef __ANDROID__ ++ termux_warn_once_about_lockfile(); ++#else + ret = error("chmod on %s failed: %s", + get_lock_file_path(lock), strerror(errno)); + goto out; ++#endif + } + + while (fgets(buf, sizeof(buf), config_file)) { -- 2.11.0