mirror of
https://github.com/git/git
synced 2024-10-30 14:03:28 +00:00
bcdd297b78
Just like `git add --edit` allows the user to edit the diff before it is being applied to the index, this feature allows the user to edit the diff *hunk*. Naturally, it gets a bit more complicated here because the result has to play well with the remaining hunks of the overall diff. Therefore, we have to do a loop in which we let the user edit the hunk, then test whether the result would work, and if not, drop the edits and let the user decide whether to try editing the hunk again. Note: in contrast to the Perl version, we use the same diff "coalescing" (i.e. merging overlapping hunks into a single one) also for the check after editing, and we introduce a new flag for that purpose that asks the `reassemble_patch()` function to pretend that all hunks were selected for use. This allows us to continue to run `git apply` *without* the `--allow-overlap` option (unlike the Perl version), and it also fixes two known breakages in `t3701-add-interactive.sh` (which we cannot mark as resolved so far because the Perl script version is still the default and continues to have those breakages). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
27 lines
687 B
C
27 lines
687 B
C
#ifndef ADD_INTERACTIVE_H
|
|
#define ADD_INTERACTIVE_H
|
|
|
|
#include "color.h"
|
|
|
|
struct add_i_state {
|
|
struct repository *r;
|
|
int use_color;
|
|
char header_color[COLOR_MAXLEN];
|
|
char help_color[COLOR_MAXLEN];
|
|
char prompt_color[COLOR_MAXLEN];
|
|
char error_color[COLOR_MAXLEN];
|
|
char reset_color[COLOR_MAXLEN];
|
|
char fraginfo_color[COLOR_MAXLEN];
|
|
char context_color[COLOR_MAXLEN];
|
|
char file_old_color[COLOR_MAXLEN];
|
|
char file_new_color[COLOR_MAXLEN];
|
|
};
|
|
|
|
void init_add_i_state(struct add_i_state *s, struct repository *r);
|
|
|
|
struct repository;
|
|
struct pathspec;
|
|
int run_add_i(struct repository *r, const struct pathspec *ps);
|
|
int run_add_p(struct repository *r, const struct pathspec *ps);
|
|
|
|
#endif
|