I am trying to achieve searching for bug fixes available on certain code repository. All I have is individual fix's code . I need to come up with an executable which can parse the entire file and can establish whether the fix is available or not based on comparison of fix's code in entire file the fix is intended. I need some suggestions algorithm to implement this pattern matching exercise which would be conditional in nature.
Asked
Active
Viewed 111 times
1
-
patch --dry-run gives an error if the fix is already applied or if it doesn't match the file. – stark Jan 20 '14 at 19:14
-
Does patch --dry-run is intelligent enough to identify the block in entire file even if the lines are little moved . I meant to say someone might have touched file and have inserted some lines above or below which makes line numbers irrelevant – pavan Jan 20 '14 at 19:31
-
If it uses a context diff it will find it. – stark Jan 20 '14 at 19:50
-
Thanks stark Let me find out if it fits my need and will leave feedback – pavan Jan 20 '14 at 19:54
1 Answers
0
Given the fix, I assume you can characterize it as a delta: the programmer made this change in that place/text in a file. (If you don't have that, you can get it from diff-like tools applied to the before-and-after files (see my Bio for a smart one).
Then you want to hunt for that text. You can do this with a regular expression probably fairly well, at least if the change is significant in size.
You're likely to have to show the matches to the user to vet them, since the search/match process is heuristic.

Ira Baxter
- 93,541
- 22
- 172
- 341
-
Thanks Baxter As the patches are available in git I have information on diff. I was trying to achieve this automated as User may not be involved . I wish to break them by delimiters and do a recursive search on file but needed an algorithm to implement. – pavan Jan 20 '14 at 19:27
-
What was wrong with "apply regexp to string representing file content"? – Ira Baxter Jan 20 '14 at 20:15