diff options
Diffstat (limited to 'builtin/show-index.c')
| -rw-r--r-- | builtin/show-index.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/builtin/show-index.c b/builtin/show-index.c index 540dc3dad1..9d4ecf5e7b 100644 --- a/builtin/show-index.c +++ b/builtin/show-index.c @@ -1,17 +1,22 @@ +#define USE_THE_REPOSITORY_VARIABLE +#define DISABLE_SIGN_COMPARE_WARNINGS + #include "builtin.h" #include "gettext.h" #include "hash.h" #include "hex.h" #include "pack.h" #include "parse-options.h" -#include "repository.h" static const char *const show_index_usage[] = { - "git show-index [--object-format=<hash-algorithm>]", + "git show-index [--object-format=<hash-algorithm>] < <pack-idx-file>", NULL }; -int cmd_show_index(int argc, const char **argv, const char *prefix) +int cmd_show_index(int argc, + const char **argv, + const char *prefix, + struct repository *repo UNUSED) { int i; unsigned nr; @@ -35,6 +40,15 @@ int cmd_show_index(int argc, const char **argv, const char *prefix) repo_set_hash_algo(the_repository, hash_algo); } + /* + * Fallback to SHA1 if we are running outside of a repository. + * + * TODO: Figure out and implement a way to detect the hash algorithm in use by the + * the index file passed in and use that instead. + */ + if (!the_hash_algo) + repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + hashsz = the_hash_algo->rawsz; if (fread(top_index, 2 * 4, 1, stdin) != 1) |
