Download raw body.
got diff chomps trailing \r
On Wed, May 10, 2023 at 05:29:31PM +0200, Christian Weisgerber wrote: > Last night I tried to generate a diff between OpenBSD src "master" and > an updated "llvm15" branch. Unfortunately, the output of "got diff" > would not apply to a checked-out src tree and I had to resort to git. > > Some of the LLVM files have \r\n line endings. The problem is that > got diff simply drops the \r from all context, - and + lines. > > ===> got diff | cat -v > > --- gnu/llvm/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp > +++ gnu/llvm/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp > @@ -91,12 +91,8 @@ int main(int argc, const char **argv) {^M > llvm::transform(Args, Argv.begin(), > [](const std::string &Arg) { return Arg.c_str(); }); > > - IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions(); > - unsigned MissingArgIndex, MissingArgCount; > - auto Opts = driver::getDriverOptTable(); > - auto ParsedArgs = Opts.ParseArgs(llvm::makeArrayRef(Argv).slice(1), > - MissingArgIndex, MissingArgCount); > - ParseDiagnosticArgs(*DiagOpts, ParsedArgs); > + IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = > + CreateAndPopulateDiagOpts(Argv); > > // Don't output diagnostics, because common scenarios such as > // cross-compiling fail with diagnostics. This is not fatal, but > > ===> git diff | cat -v > > --- a/gnu/llvm/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp > +++ b/gnu/llvm/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp > @@ -91,12 +91,8 @@ int main(int argc, const char **argv) { > llvm::transform(Args, Argv.begin(),^M > [](const std::string &Arg) { return Arg.c_str(); });^M > ^M > - IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();^M > - unsigned MissingArgIndex, MissingArgCount;^M > - auto Opts = driver::getDriverOptTable();^M > - auto ParsedArgs = Opts.ParseArgs(llvm::makeArrayRef(Argv).slice(1),^M > - MissingArgIndex, MissingArgCount);^M > - ParseDiagnosticArgs(*DiagOpts, ParsedArgs);^M > + IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts =^M > + CreateAndPopulateDiagOpts(Argv);^M > ^M > // Don't output diagnostics, because common scenarios such as^M > // cross-compiling fail with diagnostics. This is not fatal, but^M > > > Ironically, got preserves the \r for the function name line, but > git doesn't. Thanks! This should not be too hard to fix. As a first step it would be nice to have is a regression test. The fix will probably require work in diff.git which has its own set of tests. But I would be happy with a test for 'got diff' just the same. Does anyone want to write a test? I am short on time now but could look into fixing this during the next few days.
got diff chomps trailing \r