This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGf93169226a29: [clang-format-diff] Fix missing formatting for zero length git diff lines (authored by zequanwu).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111273/new/ https://reviews.llvm.org/D111273 Files: clang/tools/clang-format/clang-format-diff.py 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 @@ -321,8 +321,9 @@ line_count = 1 if match.group(3): line_count = int(match.group(3)) - if line_count > 0: - matches.setdefault(filename, []).append(Range(start_line, line_count)) + if line_count == 0: + line_count = 1 + matches.setdefault(filename, []).append(Range(start_line, line_count)) return matches Index: clang/tools/clang-format/clang-format-diff.py =================================================================== --- clang/tools/clang-format/clang-format-diff.py +++ clang/tools/clang-format/clang-format-diff.py @@ -90,9 +90,11 @@ line_count = 1 if match.group(3): line_count = int(match.group(3)) - if line_count == 0: - continue - end_line = start_line + line_count - 1 + # Also format lines range if line_count is 0 in case of deleting + # surrounding statements. + end_line = start_line + if line_count != 0: + end_line += line_count - 1 lines_by_file.setdefault(filename, []).extend( ['-lines', str(start_line) + ':' + str(end_line)])
Index: clang/tools/clang-format/git-clang-format =================================================================== --- clang/tools/clang-format/git-clang-format +++ clang/tools/clang-format/git-clang-format @@ -321,8 +321,9 @@ line_count = 1 if match.group(3): line_count = int(match.group(3)) - if line_count > 0: - matches.setdefault(filename, []).append(Range(start_line, line_count)) + if line_count == 0: + line_count = 1 + matches.setdefault(filename, []).append(Range(start_line, line_count)) return matches Index: clang/tools/clang-format/clang-format-diff.py =================================================================== --- clang/tools/clang-format/clang-format-diff.py +++ clang/tools/clang-format/clang-format-diff.py @@ -90,9 +90,11 @@ line_count = 1 if match.group(3): line_count = int(match.group(3)) - if line_count == 0: - continue - end_line = start_line + line_count - 1 + # Also format lines range if line_count is 0 in case of deleting + # surrounding statements. + end_line = start_line + if line_count != 0: + end_line += line_count - 1 lines_by_file.setdefault(filename, []).extend( ['-lines', str(start_line) + ':' + str(end_line)])
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits