1

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.

4
  • patch --dry-run gives an error if the fix is already applied or if it doesn't match the file. Commented Jan 20, 2014 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 Commented Jan 20, 2014 at 19:31
  • If it uses a context diff it will find it. Commented Jan 20, 2014 at 19:50
  • Thanks stark Let me find out if it fits my need and will leave feedback Commented Jan 20, 2014 at 19:54

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
What was wrong with "apply regexp to string representing file content"?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.