https://git.reactos.org/?p=reactos.git;a=commitdiff;h=454901ab0b485b4d28aee169cacd2762e8e1324a

commit 454901ab0b485b4d28aee169cacd2762e8e1324a
Author:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
AuthorDate: Thu Sep 7 18:09:32 2023 +0200
Commit:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
CommitDate: Mon Dec 18 22:21:35 2023 +0100

    [WINESYNC] Explicitly use posix paths for git file manipulations.
    
    Whenever using git, be it on Windows CMD, git-bash on Windows, or in
    *nix systems, git appears to always use posix-like paths internally.
    So, enforce them with posixpath when building/concatenating paths that
    are going to be passed to pygit2 functions.
    
    Otherwise, exceptions like the following one happens:
    
    ```
      File "./winesync.py", line 296, in revert_staged_patchset
        self.reactos_index.remove(os.path.join(self.staged_patch_dir, 
patch_file_name))
    [... skipped ...]
    OSError: index does not contain 
sdk\tools\winesync\setupapi_staging\0002-wine-staging-4.0-setupapi_winetest.patch
 at stage 0
    ```
    
    (The git index actually contains the specified path, but in "posix" form
    with slash-separators.)
    
    On *nix platforms, these changes should not matter.
---
 sdk/tools/winesync/winesync.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sdk/tools/winesync/winesync.py b/sdk/tools/winesync/winesync.py
index a517fa6bb12..652e4233e23 100644
--- a/sdk/tools/winesync/winesync.py
+++ b/sdk/tools/winesync/winesync.py
@@ -2,6 +2,7 @@
 
 import sys
 import os
+import posixpath
 import string
 import argparse
 import subprocess
@@ -54,7 +55,7 @@ class wine_sync:
         with open(module + '.cfg', 'r') as file_input:
             self.module_cfg = yaml.safe_load(file_input)
 
-        self.staged_patch_dir = os.path.join('sdk', 'tools', 'winesync', 
self.module + '_staging')
+        self.staged_patch_dir = posixpath.join('sdk', 'tools', 'winesync', 
self.module + '_staging')
 
     def create_or_checkout_wine_branch(self, wine_tag, wine_staging_tag):
         wine_branch_name = 'winesync-' + wine_tag + '-' + wine_staging_tag
@@ -110,7 +111,7 @@ class wine_sync:
         wine_dir, wine_file = os.path.split(wine_path)
         if wine_dir in self.module_cfg['directories']:
             # we have a mapping for the directory
-            return os.path.join(self.module_cfg['directories'][wine_dir], 
wine_file)
+            return posixpath.join(self.module_cfg['directories'][wine_dir], 
wine_file)
 
         # no match
         return None
@@ -228,7 +229,7 @@ class wine_sync:
                 os.mkdir(os.path.join(self.reactos_src, self.staged_patch_dir))
             with open(patch_path, 'w') as file_output:
                 file_output.write(complete_patch)
-            self.reactos_index.add(os.path.join(self.staged_patch_dir, 
patch_file_name))
+            self.reactos_index.add(posixpath.join(self.staged_patch_dir, 
patch_file_name))
 
         self.reactos_index.write()
 
@@ -264,7 +265,7 @@ class wine_sync:
 
     def revert_staged_patchset(self):
         # revert all of this in one commit
-        staged_patch_dir_path = os.path.join(self.reactos_src, 
self.staged_patch_dir)
+        staged_patch_dir_path = posixpath.join(self.reactos_src, 
self.staged_patch_dir)
         if not os.path.isdir(staged_patch_dir_path):
             return True
 
@@ -285,7 +286,7 @@ class wine_sync:
                     print('Please check, remove the offending patch with git 
rm, and relaunch this script')
                     return False
 
-            self.reactos_index.remove(os.path.join(self.staged_patch_dir, 
patch_file_name))
+            self.reactos_index.remove(posixpath.join(self.staged_patch_dir, 
patch_file_name))
             self.reactos_index.write()
             os.remove(patch_path)
 

Reply via email to