git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/4] Handle refresh of changed files with non-ASCII names

From
Karl Hasselström <kha@treskal.com>
Date
Jun 2, 2008, 21:46 UTC
Message-ID
<20080602214636.18768.21389.stgit@yoghurt>
In-Reply-To
<20080602214212.18768.63775.stgit@yoghurt>
Without -z, git diff-files was quoting them for us.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/git.py                   |   39 +++++++++++++++++++++------------------
 t/t3200-non-ascii-filenames.sh |    2 +-
 2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/stgit/git.py b/stgit/git.py
index d4cd946..9032ddd 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -191,6 +191,19 @@ def ls_files(files, tree = None, full_name = True):
         raise GitException, \
             'Some of the given paths are either missing or not known to GIT'
 
+def parse_git_ls(output):
+    t = None
+    for line in output.split('\0'):
+        if not line:
+            # There's a zero byte at the end of the output, which
+            # gives us an empty string as the last "line".
+            continue
+        if t == None:
+            mode_a, mode_b, sha1_a, sha1_b, t = line.split(' ')
+        else:
+            yield (t, line)
+            t = None
+
 def tree_status(files = None, tree_id = 'HEAD', unknown = False,
                   noexclude = True, verbose = False, diff_flags = []):
     """Get the status of all changed files, or of a selected set of
@@ -236,29 +249,19 @@ def tree_status(files = None, tree_id = 'HEAD', unknown = False,
     args = diff_flags + [tree_id]
     if files:
         args += ['--'] + files
-    t = None
-    for line in GRun('diff-index', '-z', *args).raw_output().split('\0'):
-        if not line:
-            # There's a zero byte at the end of the output, which
-            # gives us an empty string as the last "line".
-            continue
-        if t == None:
-            mode_a, mode_b, sha1_a, sha1_b, t = line.split(' ')
-        else:
-            if not line in reported_files:
-                cache_files.append((t, line))
-                reported_files.add(line)
-            t = None
+    for t, fn in parse_git_ls(GRun('diff-index', '-z', *args).raw_output()):
+        if not fn in reported_files:
+            cache_files.append((t, fn))
+            reported_files.add(fn)
 
     # files in the index but changed on (or removed from) disk
     args = list(diff_flags)
     if files:
         args += ['--'] + files
-    for line in GRun('diff-files', *args).output_lines():
-        fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
-        if fs[1] not in reported_files:
-            cache_files.append(fs)
-            reported_files.add(fs[1])
+    for t, fn in parse_git_ls(GRun('diff-files', '-z', *args).raw_output()):
+        if not fn in reported_files:
+            cache_files.append((t, fn))
+            reported_files.add(fn)
 
     if verbose:
         out.done()
diff --git a/t/t3200-non-ascii-filenames.sh b/t/t3200-non-ascii-filenames.sh
index 055b152..892ebc9 100755
--- a/t/t3200-non-ascii-filenames.sh
+++ b/t/t3200-non-ascii-filenames.sh
@@ -31,7 +31,7 @@ test_expect_success 'Setup' '
     stg new p1 -m "Describe island"
 '
 
-test_expect_failure 'Refresh changes to non-ASCII file' '
+test_expect_success 'Refresh changes to non-ASCII file' '
     stg refresh
 '
 
Previous: Karl HasselströmNext: Karl Hasselström
Message 11 of 18 in “[StGIT BUG] StGIT errors out on rebasing patch deleting file with Unicode filename”
  1. Jakub NarebskiJun 1, 2008
  2. Jakub NarebskiJun 2, 2008
  3. Catalin MarinasJun 2, 2008
  4. Jakub NarebskiJun 2, 2008
  5. Catalin MarinasJun 2, 2008
  6. Add rebase test for when upstream has deleted a non-ASCII fileKarl Hasselström, Jun 2, 2008
  7. 0/4 Handle non-ASCII filenamesKarl Hasselström, Jun 2, 2008
  8. 1/4 Add rebase test for when upstream has deleted a non-ASCII fileKarl Hasselström, Jun 2, 2008
  9. 2/4 Handle changed files with non-ASCII namesKarl Hasselström, Jun 2, 2008
  10. 3/4 Test for another filename quoting issue in tree_status()Karl Hasselström, Jun 2, 2008
  11. 4/4 Handle refresh of changed files with non-ASCII namesKarl Hasselström, Jun 2, 2008
  12. 0/4 Handle non-ASCII filenamesKarl Hasselström, Jun 3, 2008
  13. 1/4 Add rebase test for when upstream has deleted a non-ASCII fileKarl Hasselström, Jun 3, 2008
  14. 2/4 Handle changed files with non-ASCII namesKarl Hasselström, Jun 3, 2008
  15. 3/4 Test for another filename quoting issue in tree_status()Karl Hasselström, Jun 3, 2008
  16. 4/4 Handle refresh of changed files with non-ASCII namesKarl Hasselström, Jun 3, 2008
  17. Catalin MarinasJun 3, 2008
  18. Karl HasselströmJun 3, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.