[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:51:51 +0000 (UTC)
commit 41a50f8ce834428b0b664bd6e3b4af632e45cf77
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 | 12 ++++++++++++
meson.build | 4 ++++
meson_options.txt | 1 +
3 files changed, 17 insertions(+)
---
diff --git a/libgit2-glib/ggit-index.c b/libgit2-glib/ggit-index.c
index 20cb8cd..02b3313 100644
--- a/libgit2-glib/ggit-index.c
+++ b/libgit2-glib/ggit-index.c
@@ -330,6 +330,7 @@ ggit_index_remove (GgitIndex *idx,
gchar *path;
GgitRepository *repo;
GFile *wd;
+ GString *gs_path;
g_return_val_if_fail (GGIT_IS_INDEX (idx), FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
@@ -341,6 +342,11 @@ ggit_index_remove (GgitIndex *idx,
g_object_unref (repo);
path = g_file_get_relative_path (wd, file);
+#ifdef TRANSLATE_WINDOWS_PATHS
+ gs_path = g_string_new (path);
+ g_string_replace (gs_path, "\\", "/", 0);
+ path = g_string_free (gs_path, FALSE);
+#endif
g_object_unref (wd);
g_return_val_if_fail (path != NULL, FALSE);
@@ -447,6 +453,7 @@ ggit_index_add_file (GgitIndex *idx,
GFile *wd;
gchar *path;
gint ret;
+ GString *gs_path;
g_return_val_if_fail (GGIT_IS_INDEX (idx), FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
@@ -456,6 +463,11 @@ ggit_index_add_file (GgitIndex *idx,
wd = ggit_repository_get_workdir (repo);
path = g_file_get_relative_path (wd, file);
+#ifdef TRANSLATE_WINDOWS_PATHS
+ gs_path = g_string_new (path);
+ g_string_replace (gs_path, "\\", "/", 0);
+ path = g_string_free (gs_path, FALSE);
+#endif
g_object_unref (wd);
g_object_unref (repo);
diff --git a/meson.build b/meson.build
index a36b606..ab37219 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..b7a837b 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 paths into Unix
paths')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]