Skip to content

Commit 11c62dd

Browse files
committed
git: Patch to enable repos on shared filesystems
Fixes termux#227.
1 parent 51b3110 commit 11c62dd

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

‎packages/git/build.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Distributed version control system designed to handle ev
33
# less is required as a pager for git log, and the busybox less does not handle used escape sequences.
44
TERMUX_PKG_DEPENDS="libcurl, less"
55
TERMUX_PKG_VERSION=2.8.1
6-
TERMUX_PKG_BUILD_REVISION=1
6+
TERMUX_PKG_BUILD_REVISION=2
77
TERMUX_PKG_SRCURL=https://www.kernel.org/pub/software/scm/git/git-${TERMUX_PKG_VERSION}.tar.xz
88
## This requires a working $TERMUX_PREFIX/bin/sh on the host building:
99
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"

‎packages/git/config.c.patch‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
diff -u -r ../git-2.8.1/config.c ./config.c
2+
--- ../git-2.8.1/config.c 2016-04-03 15:07:18.000000000 -0400
3+
+++ ./config.c 2016-04-21 18:37:26.707906688 -0400
4+
@@ -49,6 +49,25 @@
5+
*/
6+
static struct config_set the_config_set;
7+
8+
+/*
9+
+ * Protecting the project-specific git configuration file (.git/config) is
10+
+ * not possible on a shared file system on Android, which on an unpatched
11+
+ * git causes operations such as clone to fail with an error message.
12+
+ *
13+
+ * For the Termux git package we introduce a warning about the configuration
14+
+ * file being unprotected, but proceed in order to allow git repositories
15+
+ * to be cloned to shared storage accessible to other apps.
16+
+ */
17+
+static void termux_warn_once_about_lockfile()
18+
+{
19+
+ static int already_warned;
20+
+ if (!already_warned) {
21+
+ warning("Cannot protect .git/config on this file system"
22+
+ " - do not store sensitive information here.");
23+
+ already_warned = 1;
24+
+ }
25+
+}
26+
+
27+
static int config_file_fgetc(struct config_source *conf)
28+
{
29+
return getc_unlocked(conf->u.file);
30+
@@ -2125,10 +2147,14 @@
31+
in_fd = -1;
32+
33+
if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
34+
+#ifdef __ANDROID__
35+
+ termux_warn_once_about_lockfile();
36+
+#else
37+
error("chmod on %s failed: %s",
38+
get_lock_file_path(lock), strerror(errno));
39+
ret = CONFIG_NO_WRITE;
40+
goto out_free;
41+
+#endif
42+
}
43+
44+
if (store.seen == 0)
45+
@@ -2330,9 +2356,13 @@
46+
fstat(fileno(config_file), &st);
47+
48+
if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
49+
+#ifdef __ANDROID__
50+
+ termux_warn_once_about_lockfile();
51+
+#else
52+
ret = error("chmod on %s failed: %s",
53+
get_lock_file_path(lock), strerror(errno));
54+
goto out;
55+
+#endif
56+
}
57+
58+
while (fgets(buf, sizeof(buf), config_file)) {

0 commit comments

Comments
 (0)