#define USE_THE_REPOSITORY_VARIABLE
#include "git-compat-util.h"
#include "add-interactive.h"
#include "advice.h"
#include "editor.h"
#include "environment.h"
#include "gettext.h"
#include "object-name.h"
#include "pager.h"
#include "read-cache-ll.h"
#include "repository.h"
#include "strbuf.h"
#include "sigchain.h"
#include "run-command.h"
#include "strvec.h"
#include "pathspec.h"
#include "color.h"
#include "compat/terminal.h"
#include "prompt.h"
enum prompt_mode_type { … };
struct patch_mode { … };
static struct patch_mode patch_mode_add = …;
static struct patch_mode patch_mode_stash = …;
static struct patch_mode patch_mode_reset_head = …;
static struct patch_mode patch_mode_reset_nothead = …;
static struct patch_mode patch_mode_checkout_index = …;
static struct patch_mode patch_mode_checkout_head = …;
static struct patch_mode patch_mode_checkout_nothead = …;
static struct patch_mode patch_mode_worktree_head = …;
static struct patch_mode patch_mode_worktree_nothead = …;
struct hunk_header { … };
struct hunk { … };
struct add_p_state { … };
static void add_p_state_clear(struct add_p_state *s)
{ … }
__attribute__((format (printf, 2, 3)))
static void err(struct add_p_state *s, const char *fmt, ...)
{ … }
LAST_ARG_MUST_BE_NULL
static void setup_child_process(struct add_p_state *s,
struct child_process *cp, ...)
{ … }
static int parse_range(const char **p,
unsigned long *offset, unsigned long *count)
{ … }
static int parse_hunk_header(struct add_p_state *s, struct hunk *hunk)
{ … }
static int is_octal(const char *p, size_t len)
{ … }
static void complete_file(char marker, struct hunk *hunk)
{ … }
static int normalize_marker(const char *p)
{ … }
static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
{ … }
static size_t find_next_line(struct strbuf *sb, size_t offset)
{ … }
static void render_hunk(struct add_p_state *s, struct hunk *hunk,
ssize_t delta, int colored, struct strbuf *out)
{ … }
static void render_diff_header(struct add_p_state *s,
struct file_diff *file_diff, int colored,
struct strbuf *out)
{ … }
static int merge_hunks(struct add_p_state *s, struct file_diff *file_diff,
size_t *hunk_index, int use_all, struct hunk *merged)
{ … }
static void reassemble_patch(struct add_p_state *s,
struct file_diff *file_diff, int use_all,
struct strbuf *out)
{ … }
static int split_hunk(struct add_p_state *s, struct file_diff *file_diff,
size_t hunk_index)
{ … }
static void recolor_hunk(struct add_p_state *s, struct hunk *hunk)
{ … }
static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)
{ … }
static ssize_t recount_edited_hunk(struct add_p_state *s, struct hunk *hunk,
size_t orig_old_count, size_t orig_new_count)
{ … }
static int run_apply_check(struct add_p_state *s,
struct file_diff *file_diff)
{ … }
static int read_single_character(struct add_p_state *s)
{ … }
static int prompt_yesno(struct add_p_state *s, const char *prompt)
{ … }
static int edit_hunk_loop(struct add_p_state *s,
struct file_diff *file_diff, struct hunk *hunk)
{ … }
static int apply_for_checkout(struct add_p_state *s, struct strbuf *diff,
int is_reverse)
{ … }
#define SUMMARY_HEADER_WIDTH …
#define SUMMARY_LINE_WIDTH …
static void summarize_hunk(struct add_p_state *s, struct hunk *hunk,
struct strbuf *out)
{ … }
#define DISPLAY_HUNKS_LINES …
static size_t display_hunks(struct add_p_state *s,
struct file_diff *file_diff, size_t start_index)
{ … }
static const char help_patch_remainder[] = …);
static int patch_update_file(struct add_p_state *s,
struct file_diff *file_diff)
{ … }
int run_add_p(struct repository *r, enum add_p_mode mode,
const char *revision, const struct pathspec *ps)
{ … }