Can I check that the diff between two versions of a file solely contains a new prefix that I've added?












2














Background



As part work to abstract a few classes to one interface, I've had to changes a file which makes use of one of these old classes to now point it to the interface fields.



The file previously would have looked something like this (simplified for example).



public class Foo{

public string RetrieveValue(MyModel model)
{
return model.Area.Street.Flat;
}

public string RetrieveOtherValue(MyModel model)
{
return model.Area.Shop;
}

}


But would now look like this.



public class Foo{

public string RetrieveValue(MyModel model)
{
return model.Base_Area.Base_Street.Base_Flat;
}

public string RetrieveOtherValue(MyModel model)
{
return model.Base_Area.Base_Shop;
}

}


Question



Can I check easily that the only change here was the inclusion of Base_ in various places?



It's easy to see on this scale with a diff tool, but the file big enough that I don't trust just eyeballing it. My source control in use is git but I'm happy to use other tools if necessary.



Ideally I'd like to ignore all sorts of whitespace, too.










share|improve this question



























    2














    Background



    As part work to abstract a few classes to one interface, I've had to changes a file which makes use of one of these old classes to now point it to the interface fields.



    The file previously would have looked something like this (simplified for example).



    public class Foo{

    public string RetrieveValue(MyModel model)
    {
    return model.Area.Street.Flat;
    }

    public string RetrieveOtherValue(MyModel model)
    {
    return model.Area.Shop;
    }

    }


    But would now look like this.



    public class Foo{

    public string RetrieveValue(MyModel model)
    {
    return model.Base_Area.Base_Street.Base_Flat;
    }

    public string RetrieveOtherValue(MyModel model)
    {
    return model.Base_Area.Base_Shop;
    }

    }


    Question



    Can I check easily that the only change here was the inclusion of Base_ in various places?



    It's easy to see on this scale with a diff tool, but the file big enough that I don't trust just eyeballing it. My source control in use is git but I'm happy to use other tools if necessary.



    Ideally I'd like to ignore all sorts of whitespace, too.










    share|improve this question

























      2












      2








      2







      Background



      As part work to abstract a few classes to one interface, I've had to changes a file which makes use of one of these old classes to now point it to the interface fields.



      The file previously would have looked something like this (simplified for example).



      public class Foo{

      public string RetrieveValue(MyModel model)
      {
      return model.Area.Street.Flat;
      }

      public string RetrieveOtherValue(MyModel model)
      {
      return model.Area.Shop;
      }

      }


      But would now look like this.



      public class Foo{

      public string RetrieveValue(MyModel model)
      {
      return model.Base_Area.Base_Street.Base_Flat;
      }

      public string RetrieveOtherValue(MyModel model)
      {
      return model.Base_Area.Base_Shop;
      }

      }


      Question



      Can I check easily that the only change here was the inclusion of Base_ in various places?



      It's easy to see on this scale with a diff tool, but the file big enough that I don't trust just eyeballing it. My source control in use is git but I'm happy to use other tools if necessary.



      Ideally I'd like to ignore all sorts of whitespace, too.










      share|improve this question













      Background



      As part work to abstract a few classes to one interface, I've had to changes a file which makes use of one of these old classes to now point it to the interface fields.



      The file previously would have looked something like this (simplified for example).



      public class Foo{

      public string RetrieveValue(MyModel model)
      {
      return model.Area.Street.Flat;
      }

      public string RetrieveOtherValue(MyModel model)
      {
      return model.Area.Shop;
      }

      }


      But would now look like this.



      public class Foo{

      public string RetrieveValue(MyModel model)
      {
      return model.Base_Area.Base_Street.Base_Flat;
      }

      public string RetrieveOtherValue(MyModel model)
      {
      return model.Base_Area.Base_Shop;
      }

      }


      Question



      Can I check easily that the only change here was the inclusion of Base_ in various places?



      It's easy to see on this scale with a diff tool, but the file big enough that I don't trust just eyeballing it. My source control in use is git but I'm happy to use other tools if necessary.



      Ideally I'd like to ignore all sorts of whitespace, too.







      git version-control diff






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 14:46









      Geesh_SO

      57921138




      57921138
























          2 Answers
          2






          active

          oldest

          votes


















          2














          I think the following should get close:



          git diff --word-diff-regex=. > changes.txt
          grep -oP '+[^+]++' changes.txt | tr -d '+' | sort -u


          In the first line, you make a diff which you write to a file.

          The second line extracts the changes on character basis and removes the "+". In the end it is sorted and unique values are kept. I applied the above code to your example and got the following result:



          Base_


          This even works with more files or files which were changed in other folders. You still get the answer right away - but in case, analysis takes more time.






          share|improve this answer























          • You can also add --word-diff=porcelain to have to grep less
            – max630
            Nov 22 '18 at 11:56



















          1














          How about this?



          diff <(git show HEAD~1:/path/to/file) <(sed 's/Base_//' /path/to/file)


          Change to HEAD~0 If you have not commited the file yet.






          share|improve this answer























          • This does not work in my case. And it would would only work for "Area"?
            – Christoph
            Nov 21 '18 at 18:05










          • Well. Now it is better. Ofcourse, you may have to tune it to fit the exact needs..
            – balki
            Nov 21 '18 at 18:34










          • I guess, my answer is closer as you see immediatelly, if there is only one change :-)
            – Christoph
            Nov 22 '18 at 8:08













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414581%2fcan-i-check-that-the-diff-between-two-versions-of-a-file-solely-contains-a-new-p%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          I think the following should get close:



          git diff --word-diff-regex=. > changes.txt
          grep -oP '+[^+]++' changes.txt | tr -d '+' | sort -u


          In the first line, you make a diff which you write to a file.

          The second line extracts the changes on character basis and removes the "+". In the end it is sorted and unique values are kept. I applied the above code to your example and got the following result:



          Base_


          This even works with more files or files which were changed in other folders. You still get the answer right away - but in case, analysis takes more time.






          share|improve this answer























          • You can also add --word-diff=porcelain to have to grep less
            – max630
            Nov 22 '18 at 11:56
















          2














          I think the following should get close:



          git diff --word-diff-regex=. > changes.txt
          grep -oP '+[^+]++' changes.txt | tr -d '+' | sort -u


          In the first line, you make a diff which you write to a file.

          The second line extracts the changes on character basis and removes the "+". In the end it is sorted and unique values are kept. I applied the above code to your example and got the following result:



          Base_


          This even works with more files or files which were changed in other folders. You still get the answer right away - but in case, analysis takes more time.






          share|improve this answer























          • You can also add --word-diff=porcelain to have to grep less
            – max630
            Nov 22 '18 at 11:56














          2












          2








          2






          I think the following should get close:



          git diff --word-diff-regex=. > changes.txt
          grep -oP '+[^+]++' changes.txt | tr -d '+' | sort -u


          In the first line, you make a diff which you write to a file.

          The second line extracts the changes on character basis and removes the "+". In the end it is sorted and unique values are kept. I applied the above code to your example and got the following result:



          Base_


          This even works with more files or files which were changed in other folders. You still get the answer right away - but in case, analysis takes more time.






          share|improve this answer














          I think the following should get close:



          git diff --word-diff-regex=. > changes.txt
          grep -oP '+[^+]++' changes.txt | tr -d '+' | sort -u


          In the first line, you make a diff which you write to a file.

          The second line extracts the changes on character basis and removes the "+". In the end it is sorted and unique values are kept. I applied the above code to your example and got the following result:



          Base_


          This even works with more files or files which were changed in other folders. You still get the answer right away - but in case, analysis takes more time.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 '18 at 13:53

























          answered Nov 21 '18 at 17:30









          Christoph

          2,73521540




          2,73521540












          • You can also add --word-diff=porcelain to have to grep less
            – max630
            Nov 22 '18 at 11:56


















          • You can also add --word-diff=porcelain to have to grep less
            – max630
            Nov 22 '18 at 11:56
















          You can also add --word-diff=porcelain to have to grep less
          – max630
          Nov 22 '18 at 11:56




          You can also add --word-diff=porcelain to have to grep less
          – max630
          Nov 22 '18 at 11:56













          1














          How about this?



          diff <(git show HEAD~1:/path/to/file) <(sed 's/Base_//' /path/to/file)


          Change to HEAD~0 If you have not commited the file yet.






          share|improve this answer























          • This does not work in my case. And it would would only work for "Area"?
            – Christoph
            Nov 21 '18 at 18:05










          • Well. Now it is better. Ofcourse, you may have to tune it to fit the exact needs..
            – balki
            Nov 21 '18 at 18:34










          • I guess, my answer is closer as you see immediatelly, if there is only one change :-)
            – Christoph
            Nov 22 '18 at 8:08


















          1














          How about this?



          diff <(git show HEAD~1:/path/to/file) <(sed 's/Base_//' /path/to/file)


          Change to HEAD~0 If you have not commited the file yet.






          share|improve this answer























          • This does not work in my case. And it would would only work for "Area"?
            – Christoph
            Nov 21 '18 at 18:05










          • Well. Now it is better. Ofcourse, you may have to tune it to fit the exact needs..
            – balki
            Nov 21 '18 at 18:34










          • I guess, my answer is closer as you see immediatelly, if there is only one change :-)
            – Christoph
            Nov 22 '18 at 8:08
















          1












          1








          1






          How about this?



          diff <(git show HEAD~1:/path/to/file) <(sed 's/Base_//' /path/to/file)


          Change to HEAD~0 If you have not commited the file yet.






          share|improve this answer














          How about this?



          diff <(git show HEAD~1:/path/to/file) <(sed 's/Base_//' /path/to/file)


          Change to HEAD~0 If you have not commited the file yet.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 21 '18 at 18:32

























          answered Nov 21 '18 at 14:50









          balki

          11k1760107




          11k1760107












          • This does not work in my case. And it would would only work for "Area"?
            – Christoph
            Nov 21 '18 at 18:05










          • Well. Now it is better. Ofcourse, you may have to tune it to fit the exact needs..
            – balki
            Nov 21 '18 at 18:34










          • I guess, my answer is closer as you see immediatelly, if there is only one change :-)
            – Christoph
            Nov 22 '18 at 8:08




















          • This does not work in my case. And it would would only work for "Area"?
            – Christoph
            Nov 21 '18 at 18:05










          • Well. Now it is better. Ofcourse, you may have to tune it to fit the exact needs..
            – balki
            Nov 21 '18 at 18:34










          • I guess, my answer is closer as you see immediatelly, if there is only one change :-)
            – Christoph
            Nov 22 '18 at 8:08


















          This does not work in my case. And it would would only work for "Area"?
          – Christoph
          Nov 21 '18 at 18:05




          This does not work in my case. And it would would only work for "Area"?
          – Christoph
          Nov 21 '18 at 18:05












          Well. Now it is better. Ofcourse, you may have to tune it to fit the exact needs..
          – balki
          Nov 21 '18 at 18:34




          Well. Now it is better. Ofcourse, you may have to tune it to fit the exact needs..
          – balki
          Nov 21 '18 at 18:34












          I guess, my answer is closer as you see immediatelly, if there is only one change :-)
          – Christoph
          Nov 22 '18 at 8:08






          I guess, my answer is closer as you see immediatelly, if there is only one change :-)
          – Christoph
          Nov 22 '18 at 8:08




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414581%2fcan-i-check-that-the-diff-between-two-versions-of-a-file-solely-contains-a-new-p%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'