sergeyt/parse-diff

Should quotes in file names in ---/+++ lines be removed?

alikhamesy opened this issue · 1 comments

Ie. should this test pass?

  it("should parse diff with single line quote escaped file names", function () {
    const diff = `
diff --git "a/file \\"space\\"" "b/file \\"space\\""
index 9daeafb..88bd214 100644
--- "a/file \\"space\\""  
+++ "b/file \\"space\\""  
@@ -1 +1 @@
-test
+test\n1234
`;
    const files = parse(diff);
    expect(files.length).toBe(1);
    const [file] = files;
    expect(file.from).toBe(`file \\"space\\"`);
    expect(file.to).toBe(`file \\"space\\"`);
  });

Repro:

Running this script will generate the diff above.

#!/bin/bash

git init > /dev/null
echo test > "file \"space\""
git add . > /dev/null
git commit -m "add file" > /dev/null
git tag -a BEFORE -m "" > /dev/null
echo "test\n1234" > "file \"space\""
git add . > /dev/null
git commit -m "update file" > /dev/null
git diff BEFORE

ubunutu v20.04
node v14.16.0
npm v6.14.11
git v2.25.1

P.S. I am willing to make a PR to fix it (if it is a bug).

@alikhamesy looks like a bug, please go ahead 😄