mirror of
https://github.com/git-for-windows/git.git
synced 2026-03-19 21:10:38 -05:00
The Perl version of `git add -p` reads the config setting `diff.algorithm` and if set, uses it to generate the diff using the specified algorithm. This patch ports that functionality to the C version. To make sure that this works as intended, we add a regression test case that tries to specify a bogus diff algorithm and then verifies that `git diff-files` produced the expected error message. Note: In that new test case, we actually ignore the exit code of `git add -p`. The reason is that the C version exits with failure (as one might expect), but the Perl version does not. In fact, the Perl version continues happily after the uncolored diff failed, trying to generate the colored diff, still not catching the problem, and then it pretends to have succeeded (with exit code 0). This is arguably a bug in the Perl version, and fixing it is safely outside the scope of this patch. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
51 lines
1.1 KiB
C
51 lines
1.1 KiB
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];
|
|
|
|
char *interactive_diff_filter, *interactive_diff_algorithm;
|
|
};
|
|
|
|
int init_add_i_state(struct repository *r, struct add_i_state *s);
|
|
|
|
enum color_add_i {
|
|
COLOR_HEADER = 0,
|
|
COLOR_HELP,
|
|
COLOR_PROMPT,
|
|
COLOR_ERROR,
|
|
COLOR_RESET,
|
|
};
|
|
const char *get_add_i_color(enum color_add_i ix);
|
|
const char *get_interactive_diff_filter(void);
|
|
const char *get_interactive_diff_algorithm(void);
|
|
|
|
struct repository;
|
|
struct pathspec;
|
|
int run_add_i(struct repository *r, const struct pathspec *ps);
|
|
|
|
enum add_p_mode {
|
|
ADD_P_STAGE,
|
|
ADD_P_STASH,
|
|
ADD_P_RESET,
|
|
ADD_P_CHECKOUT,
|
|
ADD_P_WORKTREE,
|
|
};
|
|
|
|
int run_add_p(struct repository *r, enum add_p_mode mode,
|
|
const char *revision, const struct pathspec *ps);
|
|
|
|
#endif
|