[libgit2-glib/wip/albfan/stage-windows] Invalid path resolving relative path on windows
- From: Alberto Fanjul <albfan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib/wip/albfan/stage-windows] Invalid path resolving relative path on windows
- Date: Fri, 21 May 2021 06:35:22 +0000 (UTC)
commit 26d52aff31fa94ff8cdead1cbd5a98c3b4d6c241
Author: Alberto Fanjul <albertofanjul gmail com>
Date: Tue May 18 08:56:03 2021 +0200
Invalid path resolving relative path on windows
libgit2-glib/ggit-index.c | 6 ++++++
meson.build | 4 ++++
meson_options.txt | 1 +
3 files changed, 11 insertions(+)
---
diff --git a/libgit2-glib/ggit-index.c b/libgit2-glib/ggit-index.c
index 20cb8cd..d330119 100644
--- a/libgit2-glib/ggit-index.c
+++ b/libgit2-glib/ggit-index.c
@@ -341,6 +341,9 @@ ggit_index_remove (GgitIndex *idx,
g_object_unref (repo);
path = g_file_get_relative_path (wd, file);
+#ifdef TRANSLATE_WINDOWS_PATHS
+ g_string_replace (path, "\\", "/", 0);
+#endif
g_object_unref (wd);
g_return_val_if_fail (path != NULL, FALSE);
@@ -456,6 +459,9 @@ ggit_index_add_file (GgitIndex *idx,
wd = ggit_repository_get_workdir (repo);
path = g_file_get_relative_path (wd, file);
+#ifdef TRANSLATE_WINDOWS_PATHS
+ g_string_replace (path, "\\", "/", 0);
+#endif
g_object_unref (wd);
g_object_unref (repo);
diff --git a/meson.build b/meson.build
index a36b606..e65d95b 100644
--- a/meson.build
+++ b/meson.build
@@ -105,6 +105,10 @@ if get_option('b_ndebug') == 'true'
common_flags += ['-DG_DISABLE_ASSERT']
endif
+if get_option('translate-windows-paths')
+ common_flags += ['-DTRANSLATE_WINDOWS_PATHS']
+endif
+
add_project_arguments(common_flags, language: 'c')
if cc.has_link_argument('-Wl,-Bsymbolic-functions')
diff --git a/meson_options.txt b/meson_options.txt
index 90b3188..86f85d5 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -3,3 +3,4 @@ option('introspection', type: 'boolean', value: true, description: 'Enable GObje
option('python', type: 'boolean', value: true, description: 'Build with python support')
option('ssh', type: 'boolean', value: true, description: 'Build with libgit2 ssh support')
option('vapi', type: 'boolean', value: true, description: 'Build Vala bindings')
+option('translate-windows-paths', type: 'boolean', value: true, description: 'Turn windows path into Unix')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]