diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-03-05 09:44:42 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-03-05 09:44:42 -0800 |
| commit | 6249de53a3016e33dd32ef83620068f19a4e08af (patch) | |
| tree | 47b3177ed5f6e8016deedaa410226d6c5391c448 | |
| parent | b387623c12f3f4a376e4d35a610fd3e55d7ea907 (diff) | |
| parent | affe355fe706d79ce6959277c39a7f1b1ec35f58 (diff) | |
| download | git-6249de53a3016e33dd32ef83620068f19a4e08af.tar.gz | |
Merge branch 'jk/textconv-cache-outside-repo-fix'
The code incorrectly attempted to use textconv cache when asked,
even when we are not running in a repository, which has been
corrected.
* jk/textconv-cache-outside-repo-fix:
userdiff: skip textconv caching when not in a repository
| -rwxr-xr-x | t/t4042-diff-textconv-caching.sh | 22 | ||||
| -rw-r--r-- | userdiff.c | 4 |
2 files changed, 25 insertions, 1 deletions
diff --git a/t/t4042-diff-textconv-caching.sh b/t/t4042-diff-textconv-caching.sh index bf33aedf4b..8ebfa3c1be 100755 --- a/t/t4042-diff-textconv-caching.sh +++ b/t/t4042-diff-textconv-caching.sh @@ -118,4 +118,26 @@ test_expect_success 'log notes cache and still use cache for -p' ' git log --no-walk -p refs/notes/textconv/magic HEAD ' +test_expect_success 'caching is silently ignored outside repo' ' + mkdir -p non-repo && + echo one >non-repo/one && + echo two >non-repo/two && + echo "* diff=test" >attr && + test_expect_code 1 \ + nongit git -c core.attributesFile="$PWD/attr" \ + -c diff.test.textconv="tr a-z A-Z <" \ + -c diff.test.cachetextconv=true \ + diff --no-index one two >actual && + cat >expect <<-\EOF && + diff --git a/one b/two + index 5626abf..f719efd 100644 + --- a/one + +++ b/two + @@ -1 +1 @@ + -ONE + +TWO + EOF + test_cmp expect actual +' + test_done diff --git a/userdiff.c b/userdiff.c index 2b1dab2649..92ef649c99 100644 --- a/userdiff.c +++ b/userdiff.c @@ -3,6 +3,7 @@ #include "userdiff.h" #include "attr.h" #include "strbuf.h" +#include "environment.h" static struct userdiff_driver *drivers; static int ndrivers; @@ -459,7 +460,8 @@ struct userdiff_driver *userdiff_get_textconv(struct repository *r, if (!driver->textconv) return NULL; - if (driver->textconv_want_cache && !driver->textconv_cache) { + if (driver->textconv_want_cache && !driver->textconv_cache && + have_git_dir()) { struct notes_cache *c = xmalloc(sizeof(*c)); struct strbuf name = STRBUF_INIT; |
