Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-10-28 03:58:55 +0300
committerJunio C Hamano <gitster@pobox.com>2019-10-28 05:34:57 +0300
commit2eabd383134b7dedbda0e8367ef3df63c67a0445 (patch)
tree09ac0abf9b20bd2063baf57d2743d89196893a65 /builtin/rev-parse.c
parent1bcef512040979964816937162bfc9968d414a4d (diff)
rev-parse: add a --show-object-format option
Add an option to print the object format used for input, output, or storage. This allows shell scripts to discover the hash algorithm in use. Since the transition plan allows for multiple input algorithms, document that we may provide multiple results for input, and the format that the results may take. While we don't support this now, documenting it early means that script authors can future-proof their scripts for when we do. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r--builtin/rev-parse.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index f8bbe6d47ec..6c5d5d6a70f 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -918,6 +918,17 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
show_datestring("--min-age=", arg);
continue;
}
+ if (opt_with_value(arg, "--show-object-format", &arg)) {
+ const char *val = arg ? arg : "storage";
+
+ if (strcmp(val, "storage") &&
+ strcmp(val, "input") &&
+ strcmp(val, "output"))
+ die("unknown mode for --show-object-format: %s",
+ arg);
+ puts(the_hash_algo->name);
+ continue;
+ }
if (show_flag(arg) && verify)
die_no_single_rev(quiet);
continue;