aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-05-13 12:24:54 -0700
committerJunio C Hamano <gitster@pobox.com>2024-05-13 12:24:54 -0700
commit17bc3a4767f2de77b9eb4a8a7b7da966ffbe7ec0 (patch)
tree3e91636cac7d4405f77b8722efce98d488671e9c /builtin/diff.c
parent3e4a232f6e3bd3b7dd920bb07b21cf1c8b4e1a7f (diff)
parentc8aed5e8dadf913e041cde72d704aa91f378b71b (diff)
downloadgit-17bc3a4767f2de77b9eb4a8a7b7da966ffbe7ec0.tar.gz
Merge branch 'ps/undecided-is-not-necessarily-sha1' into jc/undecided-is-not-necessarily-sha1-fix
* ps/undecided-is-not-necessarily-sha1: repository: stop setting SHA1 as the default object hash oss-fuzz/commit-graph: set up hash algorithm builtin/shortlog: don't set up revisions without repo builtin/diff: explicitly set hash algo when there is no repo builtin/bundle: abort "verify" early when there is no repository builtin/blame: don't access potentially unitialized `the_hash_algo` builtin/rev-parse: allow shortening to more than 40 hex characters remote-curl: fix parsing of detached SHA256 heads attr: fix BUG() when parsing attrs outside of repo attr: don't recompute default attribute source parse-options-cb: only abbreviate hashes when hash algo is known path: move `validate_headref()` to its only user path: harden validation of HEAD with non-standard hashes
Diffstat (limited to 'builtin/diff.c')
-rw-r--r--builtin/diff.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin/diff.c b/builtin/diff.c
index efc37483b3..9b6cdabe15 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -465,6 +465,15 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
no_index = DIFF_NO_INDEX_IMPLICIT;
}
+ /*
+ * When operating outside of a Git repository we need to have a hash
+ * algorithm at hand so that we can generate the blob hashes. We
+ * default to SHA1 here, but may eventually want to change this to be
+ * configurable via a command line option.
+ */
+ if (nongit)
+ repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
+
init_diff_ui_defaults();
git_config(git_diff_ui_config, NULL);
prefix = precompose_argv_prefix(argc, argv, prefix);