GNOME Bugzilla – Bug 615661
git under cygwin path normalization
Last modified: 2013-03-31 04:27:06 UTC
Created attachment 158609 [details] [review] patch for git under cygwin path normalization Git expects paths to be unix forward slash even on Windows. Maintain the paths os specific until the stage where they are handed back to git. Example: git status returns "modified: meld/vcview.py" but needs to be "modified: meld\vcview.py"
What's the actual impact of this on Meld? I'm looking for a concrete example of the problem for testing.
Here is an example: mkdir test_repo cd test_repo echo "file content" > file1.txt mkdir folder1 echo "file content" > folder1/file2.txt git init git add . git commit -m "initial commit" echo "new file content" > file1.txt echo "new file content" > folder1/file2.txt git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # # modified: file1.txt # modified: folder1/file2.txt # meld . Meld will show that file1.txt is modified but will not show folder/file2.txt because meld can't find file2.txt due to the path. You will also need the patches that I supplied on bugs 590760 and 578985 to get the vc code working on Windows. I can supply my complete patched code if that would be helpful. Thanks for your time. -robert wahler
Review of attachment 158609 [details] [review]: ::: meld/vc/git.py @@ +70,3 @@ return self.root + def normalize_path(self, path): + return re.sub(r"\\", "/", path) Can't this just be path.replace("\\", "/"), avoiding importing re. Also, I think we want an OS-based guard here. This would incorrectly munge valid paths on non-Windows systems. @@ +85,3 @@ for entry in entries: statekey, name = entry.split("\t", 2) + path = os.path.join(self.root, os.path.normpath(name.strip())) It's not immediately obvious to me why normpath is required. Could you explain? ::: meld/vcview.py @@ +406,3 @@ else: workdir = self.vc.get_working_directory( _commonprefix(files) ) + files = [ self.vc.normalize_path(relpath(workdir, f)) for f in files ] I know this mimics the original line, but I'd appreciate it if you could fix spacing, etc. as you go (i.e., remove the spaces inside the list comprehension brackets).
This problem is fixed in current git. I fixed it in the new infrastructure rather than having to deal with the older patching style, but it works for me using msysgit. Thanks for your bug report.