From: kelson@shysecurity.com Date: Tue, 06 Jan 2015 16:19:55 GMT Subject: [PATCH 1/2] support for --no-relative and diff.relative Message-ID: <54AC0B2B.90107@shysecurity.com> In-Reply-To: <54A2FDC8.5010504@shysecurity.com> added --no-relative option for git-diff (code, documentation, and tests) --no-relative overrides --relative causing a return to standard behavior Signed-off-by: Brandon Phillips --- Documentation/diff-options.txt | 4 ++++ diff.c | 2 ++ t/t4045-diff-relative.sh | 46 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 6cb083a..2b15050 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -448,6 +448,10 @@ 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 as an argument. + +--no-relative:: + Turn off relative pathnames and include all changes in the + repository. endif::git-format-patch[] -a:: diff --git a/diff.c b/diff.c index d1bd534..7bceba8 100644 --- a/diff.c +++ b/diff.c @@ -3695,6 +3695,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) DIFF_OPT_SET(options, RELATIVE_NAME); options->prefix = arg; } + else if (!strcmp(arg, "--no-relative")) + DIFF_OPT_CLR(options, RELATIVE_NAME); /* xdiff options */ else if (!strcmp(arg, "--minimal")) diff --git a/t/t4045-diff-relative.sh b/t/t4045-diff-relative.sh index 3950f50..ccd67c7 100755 --- a/t/t4045-diff-relative.sh +++ b/t/t4045-diff-relative.sh @@ -12,8 +12,8 @@ test_expect_success 'setup' ' git commit -m one ' -check_diff() { -expect=$1; shift +store_diff_relative() { +expect=$1; cat >expected <expected <actual && test_cmp expected actual " } +check_norel_pre() { +store_diff_relative $1; shift +test_expect_success "-p --no-relative $*" " + git diff -p --no-relative $* HEAD^ >actual && + test_cmp expected actual +" +} + +check_norel_post() { +store_diff_absolute $1; shift +test_expect_success "-p $* --no-relative" " + git diff -p $* --no-relative HEAD^ >actual && + test_cmp expected actual +" +} + check_numstat() { expect=$1; shift cat >expected <