From 2a8310be3e14a6942e63bb0409c32ca651464aca Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Thu, 21 Apr 2016 11:48:38 +0100 Subject: [PATCH] git: Rewrite DOS path patch 1. To work for clone destination dirs too. 2. To be Cygwin-friendly. Fixes https://github.com/Alexpux/MSYS2-packages/issues/554 and: https://cygwin.com/ml/cygwin/2016-04/msg00474.html --- ...a-copy-of-has_dos_drive_prefix-logic.patch | 29 ------ git/PKGBUILD | 11 +-- git/git-2.8.1-Cygwin-Allow-DOS-paths.patch | 88 +++++++++++++++++++ 3 files changed, 94 insertions(+), 34 deletions(-) delete mode 100644 git/0001-msys2-Use-a-copy-of-has_dos_drive_prefix-logic.patch create mode 100644 git/git-2.8.1-Cygwin-Allow-DOS-paths.patch diff --git a/git/0001-msys2-Use-a-copy-of-has_dos_drive_prefix-logic.patch b/git/0001-msys2-Use-a-copy-of-has_dos_drive_prefix-logic.patch deleted file mode 100644 index 51077f69..00000000 --- a/git/0001-msys2-Use-a-copy-of-has_dos_drive_prefix-logic.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 6a2f2505379985d934dfb31a5fbca10a2dfef46e Mon Sep 17 00:00:00 2001 -From: Ray Donnelly -Date: Sun, 21 Feb 2016 16:33:22 +0000 -Subject: [PATCH] msys2: Use a copy of has_dos_drive_prefix logic - -in git_has_dos_drive_prefix ---- - git-compat-util.h | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/git-compat-util.h b/git-compat-util.h -index 693a336..4aaa1e6 100644 ---- a/git-compat-util.h -+++ b/git-compat-util.h -@@ -332,7 +332,11 @@ extern char *gitdirname(char *); - #ifndef has_dos_drive_prefix - static inline int git_has_dos_drive_prefix(const char *path) - { -+#if defined(__MSYS__) -+ return (isalpha(*(path)) && (path)[1] == ':' ? 2 : 0); -+#else - return 0; -+#endif - } - #define has_dos_drive_prefix git_has_dos_drive_prefix - #endif --- -2.7.0 - diff --git a/git/PKGBUILD b/git/PKGBUILD index 19b2dc12..14e63773 100644 --- a/git/PKGBUILD +++ b/git/PKGBUILD @@ -1,9 +1,9 @@ # Maintainer: Alexey Pavlov -# Contributor: Ray Donnelly +# Maintainer: Ray Donnelly pkgname=git pkgver=2.8.1 -pkgrel=1 +pkgrel=2 pkgdesc="The fast distributed version control system" arch=('i686' 'x86_64') url="https://git-scm.com/" @@ -43,18 +43,19 @@ optdepends=(#'tk: gitk and git gui' #install=git.install replaces=('git-core') provides=('git-core') +#options=('debug' '!strip') source=("${pkgname}-${pkgver}.tar.gz"::https://github.com/git/git/archive/v${pkgver}.tar.gz 1.7.9-cygwin.patch git-1.9.0-manifest-msys2.patch git-1.8.4-msys2.patch git-2.3.5-mingw-pwd.patch - 0001-msys2-Use-a-copy-of-has_dos_drive_prefix-logic.patch) + git-2.8.1-Cygwin-Allow-DOS-paths.patch) sha256sums=('e08503ecaf5d3ac10c40f22871c996a392256c8d038d16f52ebf974cba29ae42' 'c5e735d829e11f79e2d508b663d0924030498f48fc716881031fb975dbf187a5' 'deb39583002770bdfb3d612562e9db73cd6fbd6cc6639fc5d3aeeae25e54ebcc' 'a82df3fc9a80b9f9003a9b9feca063413b14630c043c0b2b88bf2c61c46154cc' 'f67412f829e026b677d4c3ceacfb21da0549ad4636fb07c283e52c3fd5aa3e22' - '93f2be6ea51c2d35e59632666492283430126c632e9fff0c5ce10938753253ca') + '8771a9050b38737fce1e35ddf9961df0685b492013e33ec191afd80c176cefa7') prepare() { cd "${srcdir}/${pkgname}-${pkgver}" @@ -64,7 +65,7 @@ prepare() { patch -p1 -i "${srcdir}"/git-1.9.0-manifest-msys2.patch patch -p1 -i "${srcdir}"/git-1.8.4-msys2.patch patch -p2 -i "${srcdir}"/git-2.3.5-mingw-pwd.patch - patch -p1 -i "${srcdir}"/0001-msys2-Use-a-copy-of-has_dos_drive_prefix-logic.patch + patch -p1 -i "${srcdir}"/git-2.8.1-Cygwin-Allow-DOS-paths.patch local _arch= if [ "${CARCH}" == 'x86_64' ]; then diff --git a/git/git-2.8.1-Cygwin-Allow-DOS-paths.patch b/git/git-2.8.1-Cygwin-Allow-DOS-paths.patch new file mode 100644 index 00000000..e48eab03 --- /dev/null +++ b/git/git-2.8.1-Cygwin-Allow-DOS-paths.patch @@ -0,0 +1,88 @@ +--- git-2.8.1/cache.h.orig 2016-04-03 18:14:12.000000000 +0100 ++++ git-2.8.1/cache.h 2016-04-21 11:10:05.248614400 +0100 +@@ -989,6 +989,7 @@ + int normalize_path_copy(char *dst, const char *src); + int longest_ancestor_length(const char *path, struct string_list *prefixes); + char *strip_path_suffix(const char *path, const char *suffix); ++char *maybe_xstrdup_cyg_conv_path(const char *path, int always_dupe); + int daemon_avoid_alias(const char *path); + extern int is_ntfs_dotgit(const char *name); + +--- git-2.8.1/path.c.orig 2016-04-21 10:47:09.080902100 +0100 ++++ git-2.8.1/path.c 2016-04-21 11:09:35.644921100 +0100 +@@ -6,6 +6,10 @@ + #include "string-list.h" + #include "dir.h" + ++#if defined(__CYGWIN__) ++#include ++#endif ++ + static int get_st_mode_bits(const char *path, int *mode) + { + struct stat st; +@@ -1101,6 +1105,29 @@ + return xstrndup(path, chomp_trailing_dir_sep(path, path_len)); + } + ++/* ++ * Always duplicates `path` even if no conversion was performed. ++ */ ++char *maybe_xstrdup_cyg_conv_path(const char *path, int always_dupe) ++{ ++#if defined(__CYGWIN__) ++ int dos_prefix = has_dos_drive_prefix(path) ? 1 : 0; ++ int backslash = strchr(path, '\\') ? 1 : 0; ++ if (dos_prefix || backslash) ++ { ++ cygwin_conv_path_t form = dos_prefix ? CCP_ABSOLUTE : CCP_RELATIVE; ++ form |= CCP_WIN_A_TO_POSIX; ++ ssize_t cyg_len = cygwin_conv_path(form, path, NULL, 0); ++ char *cyg_path = (char *)alloca(cyg_len + 1); ++ if (cyg_path == NULL) ++ die("Couldn't alloca space for cyg_path"); ++ cygwin_conv_path(form, path, cyg_path, cyg_len); ++ return xstrndup(cyg_path, cyg_len); ++ } ++#endif ++ return always_dupe ? xstrdup(path) : (char*)path; ++} ++ + int daemon_avoid_alias(const char *p) + { + int sl, ndot; +--- git-2.8.1/strbuf.c.orig 2016-04-03 18:14:12.000000000 +0100 ++++ git-2.8.1/strbuf.c 2016-04-21 11:16:24.612312700 +0100 +@@ -665,6 +665,10 @@ + + void strbuf_add_absolute_path(struct strbuf *sb, const char *path) + { ++#if defined(__CYGWIN__) ++ const char *in_path = path; ++ path = maybe_xstrdup_cyg_conv_path(path, 0); ++#endif + if (!*path) + die("The empty string is not a valid path"); + if (!is_absolute_path(path)) { +@@ -686,6 +690,10 @@ + free(cwd); + } + strbuf_addstr(sb, path); ++#if defined(__CYGWIN__) ++ if (in_path != path) ++ free((void*)path); ++#endif + } + + int printf_ln(const char *fmt, ...) +--- git-2.8.1/builtin/clone.c.orig 2016-04-03 18:14:12.000000000 +0100 ++++ git-2.8.1/builtin/clone.c 2016-04-21 11:09:52.730898400 +0100 +@@ -887,7 +887,7 @@ + die(_("depth %s is not a positive number"), option_depth); + + if (argc == 2) +- dir = xstrdup(argv[1]); ++ dir = maybe_xstrdup_cyg_conv_path(argv[1], 1); + else + dir = guess_dir_name(repo_name, is_bundle, option_bare); + strip_trailing_slashes(dir);