[PATCH] D111273: [clang-format-diff] Fix missing formatting for zero length git diff lines

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 19 00:42:39 PDT 2021


MyDeveloperDay added a comment.

The following fix should resolve this

  $ git diff git-clang-format
  diff --git a/clang/tools/clang-format/git-clang-format b/clang/tools/clang-format/git-clang-format
  index 40e848d55a8c..c7e15eb7b483 100755
  --- a/clang/tools/clang-format/git-clang-format
  +++ b/clang/tools/clang-format/git-clang-format
  @@ -327,6 +327,8 @@ def extract_lines(patch_file):
           line_count = int(match.group(3))
         if line_count == 0:
           line_count = 1
  +      if start_line == 0:
  +        continue
         matches.setdefault(filename, []).append(Range(start_line, line_count))
     return matches

$ ./clang/tools/clang-format/git-clang-format -v -v HEAD~1
Ignoring changes in the following files (wrong extension or symlink):

  clang/tools/clang-format/git-clang-format

Running clang-format on the following files:

  llvm/include/llvm/ExecutionEngine/JITLink/TableManager.h
  llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp

old tree: 7584627b571deb7ed22068eb6e0496b51d76b63f
new tree: e88c2fb484c4fd0d63e150fa8d666c794ffd18ce
changed files:

  llvm/include/llvm/ExecutionEngine/JITLink/TableManager.h


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111273/new/

https://reviews.llvm.org/D111273



More information about the cfe-commits mailing list