summaryrefslogtreecommitdiff
path: root/add-interactive.h
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2019-12-13 08:08:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-12-13 20:37:14 (GMT)
commitbcdd297b782b19782d8e09b18682ec61d7c36897 (patch)
tree6920f685a3a23d0237ebce2f93ddbdff0cf364ce /add-interactive.h
parentb38dd9e7151f118b989f8c9851bc38a8a8733eaf (diff)
downloadgit-bcdd297b782b19782d8e09b18682ec61d7c36897.zip
git-bcdd297b782b19782d8e09b18682ec61d7c36897.tar.gz
git-bcdd297b782b19782d8e09b18682ec61d7c36897.tar.bz2
built-in add -p: implement hunk editing
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>
Diffstat (limited to 'add-interactive.h')
-rw-r--r--add-interactive.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/add-interactive.h b/add-interactive.h
index 584f304..062dc36 100644
--- a/add-interactive.h
+++ b/add-interactive.h
@@ -12,6 +12,9 @@ struct add_i_state {
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);