rs-parsepatch misses some diffs

Open
#92 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python, rust
Domain
tooling

Research direction

Start by running the Python reproduction against rs_parsepatch.get_diffs with the supplied patch and confirm that it yields 2 instead of 3. Trace how get_diffs handles the two files and their hunks, then verify that the corrected behavior reports all 3 diffs.

Written by the indexing model from the issue text.

Description

Assuming that variable path is a patch defined in the following python code:

import rs_parsepatch

patch = """
--- a/js/src/vm/Printer.cpp	2023-06-20 15:04:32.907323769 +0000
+++ b/js/src/vm/Printer.cpp	2023-06-20 15:05:18.491323769 +0000
@@ -52,7 +52,7 @@
 }

 bool GenericPrinter::put(mozilla::Span<const char16_t> str) {
-  for (char16_t c: str) {
+  for (char16_t c : str) {
     if (!putChar(c)) {
       return false;
     }
@@ -245,7 +245,7 @@
     return false;
   }

-  for (char16_t c: str) {
+  for (char16_t c : str) {
     MOZ_ASSERT(IsAsciiPrintable(c));
     *bp++ = char(c);
   }

--- a/js/src/vm/BytecodeUtil.cpp	2023-06-20 15:04:32.907323769 +0000
+++ b/js/src/vm/BytecodeUtil.cpp	2023-06-20 15:05:18.439323769 +0000
@@ -2308,9 +2308,7 @@
   MOZ_CRASH("No binding");
 }

-UniqueChars ExpressionDecompiler::getOutput() {
-  return sprinter.release();
-}
+UniqueChars ExpressionDecompiler::getOutput() { return sprinter.release(); }

 }  // anonymous namespace



"""

diffs = 0
for diff in rs_parsepatch.get_diffs(patch):
    diffs += 1
print(diffs)

Expected behaviour would be to have printed out 3 but in this case we have 2, which is wrong.
This has been tested and reproduced on the latest version: 0.3.9

Dominant language
Rust
Stars
8
Forks
4
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mozilla/pyo3-parsepatch

All issues in mozilla/pyo3-parsepatch

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.