builtin: use default hash when outside a repository
We have some commands that can operate inside or outside a repository. If we're operating outside a repository, we clearly cannot use the repository's hash algorithm as a default since it doesn't exist, so instead, let's pick the default instead of specifically SHA-1. Right now this results in no functional change since the default is SHA-1, but that may change in the future. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
1f68f3da87
commit
dc9c16c2fc
@@ -29,7 +29,7 @@ int cmd_apply(int argc,
|
|||||||
* cf. https://lore.kernel.org/git/xmqqcypfcmn4.fsf@gitster.g/
|
* cf. https://lore.kernel.org/git/xmqqcypfcmn4.fsf@gitster.g/
|
||||||
*/
|
*/
|
||||||
if (!the_hash_algo)
|
if (!the_hash_algo)
|
||||||
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
|
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
|
||||||
|
|
||||||
argc = apply_parse_options(argc, argv,
|
argc = apply_parse_options(argc, argv,
|
||||||
&state, &force_apply, &options,
|
&state, &force_apply, &options,
|
||||||
|
|||||||
@@ -483,7 +483,7 @@ int cmd_diff(int argc,
|
|||||||
* configurable via a command line option.
|
* configurable via a command line option.
|
||||||
*/
|
*/
|
||||||
if (nongit)
|
if (nongit)
|
||||||
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
|
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
|
||||||
|
|
||||||
init_diff_ui_defaults();
|
init_diff_ui_defaults();
|
||||||
git_config(git_diff_ui_config, NULL);
|
git_config(git_diff_ui_config, NULL);
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ int cmd_hash_object(int argc,
|
|||||||
prefix = setup_git_directory_gently(&nongit);
|
prefix = setup_git_directory_gently(&nongit);
|
||||||
|
|
||||||
if (nongit && !the_hash_algo)
|
if (nongit && !the_hash_algo)
|
||||||
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
|
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
|
||||||
|
|
||||||
if (vpath && prefix) {
|
if (vpath && prefix) {
|
||||||
vpath_free = prefix_filename(prefix, vpath);
|
vpath_free = prefix_filename(prefix, vpath);
|
||||||
|
|||||||
@@ -2034,7 +2034,7 @@ int cmd_index_pack(int argc,
|
|||||||
* choice but to guess the object hash.
|
* choice but to guess the object hash.
|
||||||
*/
|
*/
|
||||||
if (!the_repository->hash_algo)
|
if (!the_repository->hash_algo)
|
||||||
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
|
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
|
||||||
|
|
||||||
opts.flags &= ~(WRITE_REV | WRITE_REV_VERIFY);
|
opts.flags &= ~(WRITE_REV | WRITE_REV_VERIFY);
|
||||||
if (rev_index) {
|
if (rev_index) {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ int cmd_ls_remote(int argc,
|
|||||||
* depending on what object hash the remote uses.
|
* depending on what object hash the remote uses.
|
||||||
*/
|
*/
|
||||||
if (!the_repository->hash_algo)
|
if (!the_repository->hash_algo)
|
||||||
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
|
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
|
||||||
|
|
||||||
packet_trace_identity("ls-remote");
|
packet_trace_identity("ls-remote");
|
||||||
|
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ int cmd_patch_id(int argc,
|
|||||||
* the code that computes patch IDs to always use SHA1.
|
* the code that computes patch IDs to always use SHA1.
|
||||||
*/
|
*/
|
||||||
if (!the_hash_algo)
|
if (!the_hash_algo)
|
||||||
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
|
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
|
||||||
|
|
||||||
generate_id_list(opts ? opts > 1 : config.stable,
|
generate_id_list(opts ? opts > 1 : config.stable,
|
||||||
opts ? opts == 3 : config.verbatim);
|
opts ? opts == 3 : config.verbatim);
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ int cmd_shortlog(int argc,
|
|||||||
* git/nongit so that we do not have to do this.
|
* git/nongit so that we do not have to do this.
|
||||||
*/
|
*/
|
||||||
if (nongit && !the_hash_algo)
|
if (nongit && !the_hash_algo)
|
||||||
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
|
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
|
||||||
|
|
||||||
git_config(git_default_config, NULL);
|
git_config(git_default_config, NULL);
|
||||||
shortlog_init(&log);
|
shortlog_init(&log);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ int cmd_show_index(int argc,
|
|||||||
* the index file passed in and use that instead.
|
* the index file passed in and use that instead.
|
||||||
*/
|
*/
|
||||||
if (!the_hash_algo)
|
if (!the_hash_algo)
|
||||||
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
|
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
|
||||||
|
|
||||||
hashsz = the_hash_algo->rawsz;
|
hashsz = the_hash_algo->rawsz;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user