From: kelson@shysecurity.com Date: Sun, 21 Dec 2014 20:23:05 GMT Subject: [PATCH v3 1/2] git-config support for diff.relative setting Message-ID: <54972C29.7060801@shysecurity.com> In-Reply-To: <548B7967.3060201@shysecurity.com> By default, git-diff shows changes and pathnames relative to the repository root. Setting diff.relative to "true" shows pathnames relative to the current directory and excludes changes outside this directory. --- Documentation/diff-config.txt | 5 +++++ diff.c | 8 ++++++++ t/t4045-diff-relative.sh | 21 +++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt index b001779..496e9b0 100644 --- a/Documentation/diff-config.txt +++ b/Documentation/diff-config.txt @@ -103,6 +103,11 @@ diff.orderfile:: one shell glob pattern per line. Can be overridden by the '-O' option to linkgit:git-diff[1]. +diff.relative:: + Show pathnames relative to the current directory and exclude + changes outside this directory; equivalent to the 'git diff' + option '--relative'. + diff.renameLimit:: The number of files to consider when performing the copy/rename detection; equivalent to the 'git diff' option '-l'. diff --git a/diff.c b/diff.c index d1bd534..03697a9 100644 --- a/diff.c +++ b/diff.c @@ -223,6 +223,14 @@ int git_diff_ui_config(const char *var, const char *value, void *cb) return 0; } + if (!strcmp(var, "diff.relative")) { + if (git_config_bool(var, value)) + DIFF_OPT_SET(&default_diff_options, RELATIVE_NAME); + else + DIFF_OPT_CLR(&default_diff_options, RELATIVE_NAME); + return 0; + } + if (git_color_config(var, value, cb) < 0) return -1; diff --git a/t/t4045-diff-relative.sh b/t/t4045-diff-relative.sh index 3950f50..8c8fe0b 100755 --- a/t/t4045-diff-relative.sh +++ b/t/t4045-diff-relative.sh @@ -29,6 +29,23 @@ test_expect_success "-p $*" " " } +check_config() { +expect=$1; shift +cat >expected <../actual) && + test_cmp expected actual +" +} + check_numstat() { expect=$1; shift cat >expected <