Git-Diff zu ignorieren ^ M

In einem Projekt, in dem einige Dateien ^ M als Trennzeichen für Zeilenumbrüche enthalten. Das Verteilen dieser Dateien ist anscheinend unmöglich, da git-diff die gesamte Datei als eine einzige Zeile ansieht.

Wie unterscheidet man sich von der Vorgängerversion?

Gibt es eine Option wie "^ M als Zeilenumbruch behandeln, wenn Unterschiede bestehen"?

prompt> git-diff "HEAD^" -- MyFile.as 
diff --git a/myproject/MyFile.as b/myproject/MyFile.as
index be78321..a393ba3 100644
--- a/myproject/MyFile.cpp
+++ b/myproject/MyFile.cpp
@@ -1 +1 @@
-<U+FEFF>import flash.events.MouseEvent;^Mimport mx.controls.*;^Mimport mx.utils.Delegate
\ No newline at end of file
+<U+FEFF>import flash.events.MouseEvent;^Mimport mx.controls.*;^Mimport mx.utils.Delegate
\ No newline at end of file
prompt>

AKTUALISIEREN:

Jetzt habe ich ein Skript geschrieben, das die letzten 10 Revisionen auscheckt und CR in LF konvertiert.

require 'fileutils'

if ARGV.size != 3
  puts "a git-path must be provided"
  puts "a filename must be provided"
  puts "a result-dir must be provided"
  puts "example:"
  puts "ruby gitcrdiff.rb project/dir1/dir2/dir3/ SomeFile.cpp tmp_somefile"
  exit(1)
end

gitpath = ARGV[0]
filename = ARGV[1]
resultdir = ARGV[2]

unless FileTest.exist?(".git")
  puts "this command must be run in the same dir as where .git resides"
  exit(1)
end

if FileTest.exist?(resultdir)
  puts "the result dir must not exist"
  exit(1)
end
FileUtils.mkdir(resultdir)

10.times do |i|
  revision = "^" * i
  cmd = "git show HEAD#{revision}:#{gitpath}#{filename} | tr '\\r' '\\n' > #{resultdir}/#{filename}_rev#{i}"
  puts cmd 
  system cmd
end

Antworten auf die Frage(9)

Ihre Antwort auf die Frage