summaryrefslogtreecommitdiffstats
path: root/userdiff.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2024-02-26 11:27:29 +0100
committerJunio C Hamano <gitster@pobox.com>2024-02-26 18:40:55 +0100
commitaffe355fe706d79ce6959277c39a7f1b1ec35f58 (patch)
tree6aeacb4da9b5db0b66591de6349b8112907e11f0 /userdiff.c
parentGit 2.43.3 (diff)
downloadgit-affe355fe706d79ce6959277c39a7f1b1ec35f58.tar.xz
git-affe355fe706d79ce6959277c39a7f1b1ec35f58.zip
userdiff: skip textconv caching when not in a repository
The textconv caching system uses git-notes to store its cache entries. But if you're using "diff --no-index" outside of a repository, then obviously that isn't going to work. Since caching is just an optimization, it's OK for us to skip it. However, the current behavior is much worse: we call notes_cache_init() which tries to look up the ref, and the low-level ref code hits a BUG(), killing the program. Instead, we should notice before setting up the cache that it there's no repository, and just silently skip it. Reported-by: Paweł Dominiak <dominiak.pawel@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'userdiff.c')
-rw-r--r--userdiff.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/userdiff.c b/userdiff.c
index e399543823..fce3a31efa 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;
@@ -460,7 +461,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;