[PATCH] D112056: [clang-format] git-clang-format throws an assertion when removing files as part of the commit

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


MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: curdeius, krasimir, HazardyKnusperkeks.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.

Following a change D111273: [clang-format-diff] Fix missing formatting for zero length git diff lines <https://reviews.llvm.org/D111273> to allow git-clang-format to see single lines being removed, we introduced a regression such that if you are removing a whole file it will assert in clang-format as its given the -lines=0:0  (lines are 1 based)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112056

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===================================================================
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -327,6 +327,8 @@
         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
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112056.380597.patch
Type: text/x-patch
Size: 465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211019/f58068a4/attachment.bin>


More information about the cfe-commits mailing list