[PATCH] D51444: [git-llvm] Fix eol conversion on Windows for explicit CRLF files

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 29 10:46:47 PDT 2018


zturner created this revision.
zturner added a reviewer: rnk.

We were checking for 'native', but we weren't considering files that are explicitly EOL.  Secondly, dos2unix does not have a -q option on Windows (how did that even work for you?), so if the command fails we retry without -q.


https://reviews.llvm.org/D51444

Files:
  llvm/utils/git-svn/git-llvm


Index: llvm/utils/git-svn/git-llvm
===================================================================
--- llvm/utils/git-svn/git-llvm
+++ llvm/utils/git-svn/git-llvm
@@ -223,7 +223,7 @@
     crlf_files = []
     if len(files) == 1:
         # No need to split propget output on ' - ' when we have one file.
-        if eol_props.strip() == 'native':
+        if eol_props.strip() in ['native', 'CRLF']:
             crlf_files = files
     else:
         for eol_prop in eol_props.split('\n'):
@@ -237,12 +237,17 @@
                 eprint(eol_prop)
                 continue
             (f, eol_style) = prop_parts
-            if eol_style == 'native':
+            if eol_style in ['native', 'CRLF']:
                 crlf_files.append(f)
-    # Reformat all files with native SVN line endings to Unix format. SVN knows
-    # files with native line endings are text files. It will commit just the
-    # diff, and not a mass line ending change.
-    shell(['dos2unix', '-q'] + crlf_files, cwd=svn_sr_path)
+    if len(crlf_files) > 0:
+        # Reformat all files with native/CRLF SVN line endings to Unix format. SVN knows
+        # files with CRLF line endings are text files. It will commit just the diff,
+        # and not a mass line ending change.
+        try:
+            # GnuWin32 dos2unix doesn't have the -q option.
+            shell(['dos2unix', '-q'] + crlf_files, die_on_failure=False, cwd=svn_sr_path)
+        except RuntimeError:
+            shell(['dos2unix'] + crlf_files, die_on_failure=True, cwd=svn_sr_path)
 
 
 def svn_push_one_rev(svn_repo, rev, dry_run):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51444.163139.patch
Type: text/x-patch
Size: 1594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180829/e15c540d/attachment.bin>


More information about the llvm-commits mailing list