Skip to content

Diffs on strings with contents like $2 get improperly manged on gitDiff output  #11

Open

Description

@yahelc

Strings of the pattern \$\d seem to be getting substituted out. This is resulting in simple dollar amounts being mangled. I imagine this could be due to some step where those values are being run through a step that results shell command substitution of values like $1, $2, etc.

EXAMPLE (run on git-diff@2.0.6):

console.log( gitDiff("How about $2?\n","How 'bout $2?\n") )

EXPECTED RESULT:

@@ -1 +1 @@
-How about $2?
+How 'bout $2?

ACTUAL RESULT:

@@ -1 +1 @@
-How about ?
+How 'bout ?

Activity

  1. JoHuang commented on Jun 8, 2022

    @JoHuang

    Not only $[number], any $[word] applied.
    For example $pull , MongoDB queries.

  2. artem-pdus commented on Apr 10, 2023

    @artem-pdus
    var oldStr = '"price":"$0"\n';
    var newStr = '"price":"1"\n';
    var diff = gitDiff(oldStr, newStr);
    console.log(diff);
    

    outputs:

    @@ -1 +1 @@
    -"price":"/bin/sh"
    +"price":"1"
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions