| 775 | } |
| 776 | |
| 777 | void get_version_info(struct strbuf *buf, int show_build_options) |
| 778 | { |
| 779 | /* |
| 780 | * The format of this string should be kept stable for compatibility |
| 781 | * with external projects that rely on the output of "git version". |
| 782 | * |
| 783 | * Always show the version, even if other options are given. |
| 784 | */ |
| 785 | strbuf_addf(buf, "git version %s\n", git_version_string); |
| 786 | |
| 787 | if (show_build_options) { |
| 788 | strbuf_addf(buf, "cpu: %s\n", GIT_HOST_CPU); |
| 789 | if (git_built_from_commit_string[0]) |
| 790 | strbuf_addf(buf, "built from commit: %s\n", |
| 791 | git_built_from_commit_string); |
| 792 | else |
| 793 | strbuf_addstr(buf, "no commit associated with this build\n"); |
| 794 | strbuf_addf(buf, "sizeof-long: %d\n", (int)sizeof(long)); |
| 795 | strbuf_addf(buf, "sizeof-size_t: %d\n", (int)sizeof(size_t)); |
| 796 | strbuf_addf(buf, "shell-path: %s\n", SHELL_PATH); |
| 797 | /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */ |
| 798 | |
| 799 | #if defined WITH_RUST |
| 800 | strbuf_addstr(buf, "rust: enabled\n"); |
| 801 | #else |
| 802 | strbuf_addstr(buf, "rust: disabled\n"); |
| 803 | #endif |
| 804 | |
| 805 | if (fsmonitor_ipc__is_supported()) |
| 806 | strbuf_addstr(buf, "feature: fsmonitor--daemon\n"); |
| 807 | #if !defined NO_GETTEXT |
| 808 | strbuf_addstr(buf, "gettext: enabled\n"); |
| 809 | #endif |
| 810 | #if defined LIBCURL_VERSION |
| 811 | strbuf_addf(buf, "libcurl: %s\n", LIBCURL_VERSION); |
| 812 | #endif |
| 813 | #if defined OPENSSL_VERSION_TEXT |
| 814 | strbuf_addf(buf, "OpenSSL: %s\n", OPENSSL_VERSION_TEXT); |
| 815 | #endif |
| 816 | #if defined ZLIBNG_VERSION |
| 817 | strbuf_addf(buf, "zlib-ng: %s\n", ZLIBNG_VERSION); |
| 818 | #elif defined ZLIB_VERSION |
| 819 | strbuf_addf(buf, "zlib: %s\n", ZLIB_VERSION); |
| 820 | #endif |
| 821 | strbuf_addf(buf, "SHA-1: %s\n", SHA1_BACKEND); |
| 822 | #if defined SHA1_UNSAFE_BACKEND |
| 823 | strbuf_addf(buf, "non-collision-detecting-SHA-1: %s\n", |
| 824 | SHA1_UNSAFE_BACKEND); |
| 825 | #endif |
| 826 | strbuf_addf(buf, "SHA-256: %s\n", SHA256_BACKEND); |
| 827 | strbuf_addf(buf, "default-ref-format: %s\n", |
| 828 | ref_storage_format_to_name(REF_STORAGE_FORMAT_DEFAULT)); |
| 829 | strbuf_addf(buf, "default-hash: %s\n", hash_algos[GIT_HASH_DEFAULT].name); |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | int cmd_version(int argc, const char **argv, const char *prefix, struct repository *repository UNUSED) |
| 834 | { |
no test coverage detected