Can I check that the diff between two versions of a file solely contains a new prefix that I've added?
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
add a comment |
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
add a comment |
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
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
git version-control diff
asked Nov 21 '18 at 14:46
Geesh_SO
57921138
57921138
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
You can also add --word-diff=porcelain to have to grep less
– max630
Nov 22 '18 at 11:56
add a comment |
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.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
You can also add --word-diff=porcelain to have to grep less
– max630
Nov 22 '18 at 11:56
add a comment |
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.
You can also add --word-diff=porcelain to have to grep less
– max630
Nov 22 '18 at 11:56
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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