Title: | provides xdiff access |
---|---|
Description: | Bundles xdiff to create unidiffs from R. |
Authors: | Jan Marvin Garbuszus [aut, cre], git project [cph] (Authors of included xdiff code), libgit2 project [cph] (Authors of included xdiff code) |
Maintainer: | Jan Marvin Garbuszus <[email protected]> |
License: | GPL-2 |
Version: | 0.1.1 |
Built: | 2024-10-28 05:35:52 UTC |
Source: | https://github.com/JanMarvin/libxdiffR |
merge3()
is a function designed to perform three-way merges between files or text inputs. Three-way merging is commonly used in version control systems to reconcile changes made by multiple contributors, allowing for the integration of modifications from different branches or versions with a shared common ancestor.
merge3(base, merge1, merge2, level = "minimal", favor = NULL, style = NULL)
merge3(base, merge1, merge2, level = "minimal", favor = NULL, style = NULL)
base |
The common ancestor file or text input. This is the original version from which the two modified versions ( |
merge1 , merge2
|
The first and second modified files or text input to be merged. |
level |
A string specifying the merging aggressiveness level. Options include:
|
favor |
favor: A string specifying which changes to favor in case of conflicts. Options are:
|
style |
A string specifying the merge style. Options include:
|
The merge3()
function takes three inputs—an ancestor version and two modified versions—and attempts to reconcile the differences between them, producing a single merged output. This process is crucial in collaborative development environments where multiple team members work on the same files.
The function supports different levels of merging aggressiveness, allowing users to tailor the merge process according to their needs. Additionally, users can specify which version's changes should be favored in case of conflicts, and choose between standard and zealous diff3-style outputs.
The function also supports inputs from URLs, making it versatile for remote file merging scenarios.
A character string containing the three way merge.
base <- "function(x) print(x) \n" merge1 <- "function(x) print(x) \n message(x)\n" merge2 <- "function(x) print(x) \n cat(x)\n" cat(merge3(base, merge1, merge2))
base <- "function(x) print(x) \n" merge1 <- "function(x) print(x) \n message(x)\n" merge2 <- "function(x) print(x) \n cat(x)\n" cat(merge3(base, merge1, merge2))
unidiff()
is a function designed to generate unified diffs between two files or text inputs. Unified diffs are widely used in version control systems to highlight differences between two versions of a file in a compact and readable format.
unidiff( old, new, create_head = TRUE, with_context = FALSE, context_length = 3, ignore_whitespace = NULL, algorithm = "minimal", indent_heuristic = FALSE, ignore = NULL )
unidiff( old, new, create_head = TRUE, with_context = FALSE, context_length = 3, ignore_whitespace = NULL, algorithm = "minimal", indent_heuristic = FALSE, ignore = NULL )
old |
The original file or text input. This can be a file path, a URL, or a string of text. |
new |
The modified file or text input to compare against the original. This can also be a file path, a URL, or a string of text. |
create_head |
A logical flag (default |
with_context |
A logical flag (default |
context_length |
An integer value (default |
ignore_whitespace |
A character vector indicating how whitespace differences should be treated. Options include |
algorithm |
A string specifying the diff algorithm to use. Options are |
indent_heuristic |
A logical flag (default |
ignore |
A single string specifying the regex pattern to use for ignoring lines in the diff process. If this is a non-empty string, it should be a valid regex pattern. Lines in the texts that match this pattern will be ignored in the diff. |
The unidiff()
function compares two inputs—whether they are files, URLs, or raw text—and generates a unified diff that highlights the differences between them. It supports advanced features like customizable context, whitespace handling, and different diff algorithms to suit various needs. The function can also handle inputs from URLs, making it flexible for remote file comparisons.
The output is a unified diff string, which can be directly used in version control systems or for manual inspection of changes.
For identical files, no diff is returned, and an empty character string is provided.
If regex support is not available on the current platform and a non-empty pattern is provided, an error will be raised.
A character string containing the unified diff.
cat(unidiff(old = "foo bar", new = "foo baz"))
cat(unidiff(old = "foo bar", new = "foo baz"))
The unidiff_dir()
function compares files between two directories and generates unified diffs for each differing file. This function is useful for identifying and displaying differences between two directory structures, such as when comparing different versions of a codebase.
unidiff_dir( old, new, pattern = NULL, create_head = TRUE, with_context = FALSE, context_length = 3, ignore_whitespace = NULL, algorithm = "minimal", indent_heuristic = FALSE, ignore = NULL )
unidiff_dir( old, new, pattern = NULL, create_head = TRUE, with_context = FALSE, context_length = 3, ignore_whitespace = NULL, algorithm = "minimal", indent_heuristic = FALSE, ignore = NULL )
old |
The directory path of the first directory to compare. |
new |
The directory path of the second directory to compare. |
pattern |
An optional regular expression. Only file names matching the pattern will be included in the comparison. Default is |
create_head |
A logical flag (default |
with_context |
A logical flag (default |
context_length |
An integer value (default |
ignore_whitespace |
A character vector indicating how whitespace differences should be treated. Options include |
algorithm |
A string specifying the diff algorithm to use. Options are |
indent_heuristic |
A logical flag (default |
ignore |
A single string specifying the regex pattern to use for ignoring lines in the diff process. If this is a non-empty string, it should be a valid regex pattern. Lines in the texts that match this pattern will be ignored in the diff. |
A character string containing the unified diffs for all differing files between the two directories.