mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:17:35 +00:00
LibDiff+patch: Support multiple patches in a single patch file
Multiple patches may be concatenated in the same patch file, such as git commits which are changing multiple files at the same time. To handle this, parse each patch in order in the patch file, and apply each patch sequentially. To determine whether we are at the end of a patch (and not just parsing another hunk) the parser will look for a leading '@@ ' after every hunk. If that is found, there is another hunk. Otherwise, we must be at the end of this patch.
This commit is contained in:
parent
ddbd77cca1
commit
dd373eacbc
4 changed files with 57 additions and 20 deletions
|
@ -80,11 +80,13 @@ class Parser : public GenericLexer {
|
|||
public:
|
||||
using GenericLexer::GenericLexer;
|
||||
|
||||
ErrorOr<Patch> parse_patch(Optional<size_t> const& strip_count = {});
|
||||
|
||||
ErrorOr<Vector<Hunk>> parse_hunks();
|
||||
|
||||
private:
|
||||
ErrorOr<Header> parse_header(Optional<size_t> const& strip_count);
|
||||
|
||||
private:
|
||||
ErrorOr<String> parse_file_line(Optional<size_t> const& strip_count);
|
||||
Optional<HunkLocation> consume_unified_location();
|
||||
bool consume_line_number(size_t& number);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue