diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-01-17 20:25:00 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-01-17 20:25:00 +0100 |
commit | df2867ac2795bb86414c5973557c43a6cf529ff0 (patch) | |
tree | 43c73142eaa12e31ca93186462677bbd60907700 | |
parent | 68bbe7ca0a2832e55522ed2d0569403ac36784a4 (diff) | |
download | weechat-df2867ac2795bb86414c5973557c43a6cf529ff0.zip |
core: add git version in backtrace and log file
-rw-r--r-- | src/core/wee-backtrace.c | 4 | ||||
-rw-r--r-- | src/core/wee-command.c | 25 | ||||
-rw-r--r-- | src/core/wee-log.c | 4 | ||||
-rw-r--r-- | src/core/wee-version.c | 30 | ||||
-rw-r--r-- | src/core/wee-version.h | 1 | ||||
-rw-r--r-- | src/core/weechat.c | 10 |
6 files changed, 43 insertions, 31 deletions
diff --git a/src/core/wee-backtrace.c b/src/core/wee-backtrace.c index e45cab452..fd52a70d5 100644 --- a/src/core/wee-backtrace.c +++ b/src/core/wee-backtrace.c @@ -157,8 +157,8 @@ weechat_backtrace () #endif weechat_backtrace_printf ("======= WeeChat backtrace ======="); - weechat_backtrace_printf ("(written by %s, compiled on %s %s)", - version_get_name_version (), + weechat_backtrace_printf ("(written by WeeChat %s, compiled on %s %s)", + version_get_version_with_git (), version_get_compilation_date (), version_get_compilation_time ()); diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 1a59660b6..13dc764c8 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -5104,21 +5104,14 @@ command_version_display (struct t_gui_buffer *buffer, int display_git_version) { char string[512]; - const char *git_version; - - /* get git version */ - git_version = (display_git_version) ? version_get_git () : NULL; if (send_to_buffer_as_input) { if (translated_string) { snprintf (string, sizeof (string), - "WeeChat %s%s%s%s [%s %s %s]", - version_get_version (), - (git_version && git_version[0]) ? " (git: " : "", - (git_version && git_version[0]) ? git_version : "", - (git_version && git_version[0]) ? ")" : "", + "WeeChat %s [%s %s %s]", + (display_git_version) ? version_get_version_with_git () : version_get_version (), _("compiled on"), version_get_compilation_date (), version_get_compilation_time ()); @@ -5137,11 +5130,8 @@ command_version_display (struct t_gui_buffer *buffer, else { snprintf (string, sizeof (string), - "WeeChat %s%s%s%s [%s %s %s]", - version_get_version (), - (git_version && git_version[0]) ? " (git: " : "", - (git_version && git_version[0]) ? git_version : "", - (git_version && git_version[0]) ? ")" : "", + "WeeChat %s [%s %s %s]", + (display_git_version) ? version_get_version_with_git () : version_get_version (), "compiled on", version_get_compilation_date (), version_get_compilation_time ()); @@ -5160,12 +5150,9 @@ command_version_display (struct t_gui_buffer *buffer, } else { - gui_chat_printf (NULL, "%sWeeChat %s%s%s%s %s[%s%s %s %s%s]", + gui_chat_printf (NULL, "%sWeeChat %s %s[%s%s %s %s%s]", GUI_COLOR(GUI_COLOR_CHAT_BUFFER), - version_get_version (), - (git_version && git_version[0]) ? " (git: " : "", - (git_version && git_version[0]) ? git_version : "", - (git_version && git_version[0]) ? ")" : "", + (display_git_version) ? version_get_version_with_git () : version_get_version (), GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), GUI_COLOR(GUI_COLOR_CHAT_VALUE), _("compiled on"), diff --git a/src/core/wee-log.c b/src/core/wee-log.c index 49a2cb84c..7bf0c6e27 100644 --- a/src/core/wee-log.c +++ b/src/core/wee-log.c @@ -118,8 +118,8 @@ log_init () "with another home using \"--dir\" command line option.\n")); exit (1); } - log_printf ("%s (%s %s %s)", - version_get_name_version (), + log_printf ("WeeChat %s (%s %s %s)", + version_get_version_with_git (), _("compiled on"), version_get_compilation_date (), version_get_compilation_time ()); diff --git a/src/core/wee-version.c b/src/core/wee-version.c index b9c1558a2..69a5f0792 100644 --- a/src/core/wee-version.c +++ b/src/core/wee-version.c @@ -24,6 +24,8 @@ #endif #include "config-git.h" +#include <stdio.h> + /* * Returns package name ("weechat"). @@ -80,6 +82,34 @@ version_get_git () } /* + * Returns the WeeCht version + the git version (between brackets, and only if + * it is not empty). + * + * Examples: + * 0.3.9-dev (git: v0.3.9-104-g7eb5cc) + * 0.3.9-dev + * 0.3.9-rc1 (git: v0.3.9-rc1) + * 0.3.9 + */ + +const char * +version_get_version_with_git () +{ + const char *git_version; + static char version[256]; + + git_version = version_get_git (); + + snprintf (version, sizeof (version), "%s%s%s%s", + version_get_version (), + (git_version && git_version[0]) ? " (git: " : "", + (git_version && git_version[0]) ? git_version : "", + (git_version && git_version[0]) ? ")" : ""); + + return version; +} + +/* * Returns date of WeeChat compilation. * * Example: diff --git a/src/core/wee-version.h b/src/core/wee-version.h index 47ee89b19..5f3b29e2a 100644 --- a/src/core/wee-version.h +++ b/src/core/wee-version.h @@ -24,6 +24,7 @@ extern const char *version_get_name (); extern const char *version_get_version (); extern const char *version_get_name_version (); extern const char *version_get_git (); +extern const char *version_get_version_with_git (); extern const char *version_get_compilation_date (); extern const char *version_get_compilation_time (); diff --git a/src/core/weechat.c b/src/core/weechat.c index 80066fdb8..df1fb397a 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -104,19 +104,13 @@ char *weechat_startup_commands = NULL; /* startup commands (-r flag) */ void weechat_display_copyright () { - const char *git_version; - - git_version = version_get_git (); string_iconv_fprintf (stdout, "\n"); string_iconv_fprintf (stdout, /* TRANSLATORS: "%s %s" after "compiled on" is date and time */ - _("WeeChat %s%s%s%s Copyright %s, compiled on %s %s\n" + _("WeeChat %s Copyright %s, compiled on %s %s\n" "Developed by Sebastien Helleu <flashcode@flashtux.org> " "- %s"), - version_get_version (), - (git_version && git_version[0]) ? " (git: " : "", - (git_version && git_version[0]) ? git_version : "", - (git_version && git_version[0]) ? ")" : "", + version_get_version_with_git (), WEECHAT_COPYRIGHT_DATE, version_get_compilation_date (), version_get_compilation_time (), |