From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>,
Jakub Narebski <jnareb@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGit PATCH v2 4/4] Handle refresh of changed files with non-ASCII names
Date: Tue, 03 Jun 2008 02:41:57 +0200 [thread overview]
Message-ID: <20080603004157.25028.65176.stgit@yoghurt> (raw)
In-Reply-To: <20080603003846.25028.49353.stgit@yoghurt>
Without -z, git diff-files was quoting them for us.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/git.py | 43 +++++++++++++++++++++-------------------
t/t3200-non-ascii-filenames.sh | 2 +-
2 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/stgit/git.py b/stgit/git.py
index 8c637d5..8e6bdf4 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -191,6 +191,19 @@ def ls_files(files, tree = 'HEAD', 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
@@ -242,21 +255,12 @@ def tree_status(files = None, tree_id = 'HEAD', unknown = False,
args = diff_flags + [tree_id]
if files_left:
args += ['--'] + files_left
- 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:
- # the condition is needed in case files is emtpy and
- # diff-index lists those already reported
- 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()):
+ # the condition is needed in case files is emtpy and
+ # diff-index lists those already reported
+ if not fn in reported_files:
+ cache_files.append((t, fn))
+ reported_files.add(fn)
files_left = [f for f in files if f not in reported_files]
# files in the index but changed on (or removed from) disk. Only
@@ -267,13 +271,12 @@ def tree_status(files = None, tree_id = 'HEAD', unknown = False,
args = list(diff_flags)
if files_left:
args += ['--'] + files_left
- for line in GRun('diff-files', *args).output_lines():
- fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
+ for t, fn in parse_git_ls(GRun('diff-files', '-z', *args).raw_output()):
# the condition is needed in case files is empty and
# diff-files lists those already reported
- if fs[1] not in reported_files:
- cache_files.append(fs)
- reported_files.add(fs[1])
+ 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 3146b8d..1aa78ed 100755
--- a/t/t3200-non-ascii-filenames.sh
+++ b/t/t3200-non-ascii-filenames.sh
@@ -40,7 +40,7 @@ test_expect_success 'Setup' '
cat > expected.txt <<EOF
M skärgårdsö.txt
EOF
-test_expect_failure 'Status of modified non-ASCII file' '
+test_expect_success 'Status of modified non-ASCII file' '
stg status > output.txt &&
diff -u expected.txt output.txt
'
next prev parent reply other threads:[~2008-06-03 0:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-01 8:46 [StGIT BUG] StGIT errors out on rebasing patch deleting file with Unicode filename Jakub Narebski
2008-06-02 7:39 ` Jakub Narebski
2008-06-02 13:26 ` Catalin Marinas
2008-06-02 15:47 ` Jakub Narebski
2008-06-02 16:11 ` Catalin Marinas
2008-06-02 20:23 ` [PATCH] Add rebase test for when upstream has deleted a non-ASCII file Karl Hasselström
2008-06-02 21:46 ` [StGit PATCH 0/4] Handle non-ASCII filenames Karl Hasselström
2008-06-02 21:46 ` [PATCH 1/4] Add rebase test for when upstream has deleted a non-ASCII file Karl Hasselström
2008-06-02 21:46 ` [PATCH 2/4] Handle changed files with non-ASCII names Karl Hasselström
2008-06-02 21:46 ` [PATCH 3/4] Test for another filename quoting issue in tree_status() Karl Hasselström
2008-06-02 21:46 ` [PATCH 4/4] Handle refresh of changed files with non-ASCII names Karl Hasselström
2008-06-03 0:41 ` [StGit PATCH v2 0/4] Handle non-ASCII filenames Karl Hasselström
2008-06-03 0:41 ` [StGit PATCH v2 1/4] Add rebase test for when upstream has deleted a non-ASCII file Karl Hasselström
2008-06-03 0:41 ` [StGit PATCH v2 2/4] Handle changed files with non-ASCII names Karl Hasselström
2008-06-03 0:41 ` [StGit PATCH v2 3/4] Test for another filename quoting issue in tree_status() Karl Hasselström
2008-06-03 0:41 ` Karl Hasselström [this message]
2008-06-03 7:56 ` [StGit PATCH 0/4] Handle non-ASCII filenames Catalin Marinas
2008-06-03 9:27 ` Karl Hasselström
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080603004157.25028.65176.stgit@yoghurt \
--to=kha@treskal.com \
--cc=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).