diff: add config option relative
PATCH v2 1/1 diff: add config option relative
The diff.relative boolean option set to true show only changes on the current directory and show relative pathnames.
Teach --no-relative to override earlier --relative
Signed-off-by Laurent Arnoud <[email protected]>
--- Documentation/config/diff.txt | 4 ++ Documentation/diff-options.txt | 2 + diff.c | 10 ++++ t/t9904-diff-relative-config.sh | 93 +++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100755 t/t9904-diff-relative-config.sh
Documentation/config/diff.txt +4 -0
@@ -105,6 +105,10 @@ diff.mnemonicPrefix:: diff.noprefix:: If set, 'git diff' does not show any source or destination prefix. +diff.relative:: + If set to "true", 'git diff' does not show changes outside of the directory + and show pathnames relative. + diff.orderFile:: File indicating how to order files within a diff. See the '-O' option to linkgit:git-diff[1] for details.
Documentation/diff-options.txt +2 -0
@@ -651,6 +651,8 @@ ifndef::git-format-patch[] not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument. +--no-relative:: + Turn off relative pathnames and include all changes in the repository. endif::git-format-patch[] -a::
diff.c +10 -0
@@ -48,6 +48,7 @@ static const char *diff_order_file_cfg;int diff_auto_refresh_index =1 ;static int diff_mnemonic_prefix;static int diff_no_prefix; +static int diff_relative;static int diff_stat_graph_width;static int diff_dirstat_permille_default =30 ;static struct diff_options default_diff_options;
@@ -386,6 +387,10 @@ int git_diff_ui_config(const char *var, const char *value, void *cb) diff_no_prefix =git_config_bool (var, value);return 0 ; } +if (!strcmp (var,"diff.relative" )) { + diff_relative =git_config_bool (var, value); +return 0 ; + }if (!strcmp (var,"diff.statgraphwidth" )) { diff_stat_graph_width =git_config_int (var, value);return 0 ;
@@ -4558,6 +4563,8 @@ void repo_diff_setup(struct repository *r, struct diff_options *options) options->b_prefix ="b/" ; } + options->flags.relative_name = diff_relative; + options->color_moved = diff_color_moved_default; options->color_moved_ws_handling = diff_color_moved_ws_default;
@@ -5494,6 +5501,9 @@ static void prep_parse_options(struct diff_options *options) N_("when run from subdir, exclude changes outside and show relative paths"), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_relative), +OPT_SET_INT_F (0 ,"no-relative" , &options->flags.relative_name, +N_ ("disable diff.relative config option" ), +0 ,PARSE_OPT_NONEG ),OPT_BOOL ('a' ,"text" , &options->flags.text,N_ ("treat all files as text" )), OPT_BOOL('R', NULL, &options->flags.reverse_diff,
t/t9904-diff-relative-config.sh new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
2.26.2