Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Gummerer <t.gummerer@gmail.com>2019-07-11 19:08:44 +0300
committerJunio C Hamano <gitster@pobox.com>2019-07-12 00:29:27 +0300
commitef283b3699f91c9138753946dd53bec55289498a (patch)
treeea5a150d96e677111cd7376c5a00f7193c3e75dd /apply.h
parent80e184123202761a4be32be12be12f7ff469fe5b (diff)
apply: make parse_git_diff_header public
Make 'parse_git_header()' (renamed to 'parse_git_diff_header()') a "public" function in apply.h, so we can re-use it in range-diff in a subsequent commit. We're renaming the function to make it clearer in other parts of the codebase that we're talking about a diff header and not just any header. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'apply.h')
-rw-r--r--apply.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/apply.h b/apply.h
index 5948348133..a795193435 100644
--- a/apply.h
+++ b/apply.h
@@ -117,6 +117,40 @@ struct apply_state {
int applied_after_fixing_ws;
};
+/*
+ * This represents a "patch" to a file, both metainfo changes
+ * such as creation/deletion, filemode and content changes represented
+ * as a series of fragments.
+ */
+struct patch {
+ char *new_name, *old_name, *def_name;
+ unsigned int old_mode, new_mode;
+ int is_new, is_delete; /* -1 = unknown, 0 = false, 1 = true */
+ int rejected;
+ unsigned ws_rule;
+ int lines_added, lines_deleted;
+ int score;
+ int extension_linenr; /* first line specifying delete/new/rename/copy */
+ unsigned int is_toplevel_relative:1;
+ unsigned int inaccurate_eof:1;
+ unsigned int is_binary:1;
+ unsigned int is_copy:1;
+ unsigned int is_rename:1;
+ unsigned int recount:1;
+ unsigned int conflicted_threeway:1;
+ unsigned int direct_to_threeway:1;
+ unsigned int crlf_in_old:1;
+ struct fragment *fragments;
+ char *result;
+ size_t resultsize;
+ char old_oid_prefix[GIT_MAX_HEXSZ + 1];
+ char new_oid_prefix[GIT_MAX_HEXSZ + 1];
+ struct patch *next;
+
+ /* three-way fallback result */
+ struct object_id threeway_stage[3];
+};
+
int apply_parse_options(int argc, const char **argv,
struct apply_state *state,
int *force_apply, int *options,
@@ -128,6 +162,20 @@ void clear_apply_state(struct apply_state *state);
int check_apply_state(struct apply_state *state, int force_apply);
/*
+ * Parse a git diff header, starting at line. Fills the relevant
+ * metadata information in 'struct patch'.
+ *
+ * Returns -1 on failure, the length of the parsed header otherwise.
+ */
+int parse_git_diff_header(struct strbuf *root,
+ int *linenr,
+ int p_value,
+ const char *line,
+ int len,
+ unsigned int size,
+ struct patch *patch);
+
+/*
* Some aspects of the apply behavior are controlled by the following
* bits in the "options" parameter passed to apply_all_patches().
*/