Merge branch 'jc/denoise-rm-to-resolve'
[gitweb.git] / apply.h
diff --git a/apply.h b/apply.h
index b80d8ba73633c042989e52a00f7df8ee3afcd192..a7951934352cacf9869221a651504973bd4e7f9e 100644 (file)
--- a/apply.h
+++ b/apply.h
@@ -1,6 +1,11 @@
 #ifndef APPLY_H
 #define APPLY_H
 
+#include "lockfile.h"
+#include "string-list.h"
+
+struct repository;
+
 enum apply_ws_error_action {
        nowarn_ws_error,
        warn_on_ws_error,
@@ -62,6 +67,7 @@ struct apply_state {
        int unsafe_paths;
 
        /* Other non boolean parameters */
+       struct repository *repo;
        const char *index_file;
        enum apply_verbosity apply_verbosity;
        const char *fake_ancestor;
@@ -111,14 +117,63 @@ struct apply_state {
        int applied_after_fixing_ws;
 };
 
-extern int apply_parse_options(int argc, const char **argv,
-                              struct apply_state *state,
-                              int *force_apply, int *options,
-                              const char * const *apply_usage);
-extern int init_apply_state(struct apply_state *state,
-                           const char *prefix);
-extern void clear_apply_state(struct apply_state *state);
-extern int check_apply_state(struct apply_state *state, int force_apply);
+/*
+ * 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,
+                       const char * const *apply_usage);
+int init_apply_state(struct apply_state *state,
+                    struct repository *repo,
+                    const char *prefix);
+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
@@ -127,9 +182,8 @@ extern int check_apply_state(struct apply_state *state, int force_apply);
 #define APPLY_OPT_INACCURATE_EOF       (1<<0) /* accept inaccurate eof */
 #define APPLY_OPT_RECOUNT              (1<<1) /* accept inaccurate line count */
 
-extern int apply_all_patches(struct apply_state *state,
-                            int argc,
-                            const char **argv,
-                            int options);
+int apply_all_patches(struct apply_state *state,
+                     int argc, const char **argv,
+                     int options);
 
 #endif