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
This commit is contained in:
Ray Donnelly
2016-04-21 11:48:38 +01:00
parent 54cc2834fe
commit 2a8310be3e
3 changed files with 94 additions and 34 deletions

View File

@@ -1,29 +0,0 @@
From 6a2f2505379985d934dfb31a5fbca10a2dfef46e Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
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

View File

@@ -1,9 +1,9 @@
# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Ray Donnelly <mingw.android@gmail.com>
# Maintainer: Ray Donnelly <mingw.android@gmail.com>
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

View File

@@ -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 <sys/cygwin.h>
+#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);