From: Deiz Date: Mon, 6 Apr 2015 22:28:40 +0000 (-0400) Subject: Store Git commit identifier in its own object X-Git-Tag: 4.11~141^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cd4bc2adf5743bcf8b398a5beea9d5c1df690fe0;p=i3%2Fi3 Store Git commit identifier in its own object Fixes #1640 --- diff --git a/include/i3.h b/include/i3.h index 5ca87541..70ebc000 100644 --- a/include/i3.h +++ b/include/i3.h @@ -24,6 +24,9 @@ #include "data.h" #include "xcb.h" +/** Git commit identifier, from version.c */ +extern const char *i3_version; + /** The original value of RLIMIT_CORE when i3 was started. We need to restore * this before starting any other process, since we set RLIMIT_CORE to * RLIM_INFINITY for i3 debugging versions. */ diff --git a/src/config_parser.c b/src/config_parser.c index eef03cae..f3254812 100644 --- a/src/config_parser.c +++ b/src/config_parser.c @@ -996,7 +996,7 @@ bool parse_file(const char *f, bool use_nagbar) { check_for_duplicate_bindings(context); if (use_nagbar && (context->has_errors || context->has_warnings)) { - ELOG("FYI: You are using i3 version " I3_VERSION "\n"); + ELOG("FYI: You are using i3 version %s\n", i3_version); if (version == 3) ELOG("Please convert your configfile first, then fix any remaining errors (see above).\n"); diff --git a/src/ipc.c b/src/ipc.c index 8fed75f1..f8138f0a 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -791,7 +791,7 @@ IPC_HANDLER(get_version) { y(integer, PATCH_VERSION); ystr("human_readable"); - ystr(I3_VERSION); + ystr(i3_version); y(map_close); diff --git a/src/main.c b/src/main.c index 8b514178..ac40e7a3 100644 --- a/src/main.c +++ b/src/main.c @@ -188,7 +188,7 @@ static void handle_signal(int sig, siginfo_t *info, void *data) { int main(int argc, char *argv[]) { /* Keep a symbol pointing to the I3_VERSION string constant so that we have * it in gdb backtraces. */ - const char *i3_version __attribute__((unused)) = I3_VERSION; + const char *_i3_version __attribute__((unused)) = i3_version; char *override_configpath = NULL; bool autostart = true; char *layout_path = NULL; @@ -261,11 +261,11 @@ int main(int argc, char *argv[]) { only_check_config = true; break; case 'v': - printf("i3 version " I3_VERSION " © 2009-2014 Michael Stapelberg and contributors\n"); + printf("i3 version %s © 2009-2014 Michael Stapelberg and contributors\n", i3_version); exit(EXIT_SUCCESS); break; case 'm': - printf("Binary i3 version: " I3_VERSION " © 2009-2014 Michael Stapelberg and contributors\n"); + printf("Binary i3 version: %s © 2009-2014 Michael Stapelberg and contributors\n", i3_version); display_running_version(); exit(EXIT_SUCCESS); break; @@ -456,7 +456,7 @@ int main(int argc, char *argv[]) { free(cwd); } - LOG("i3 " I3_VERSION " starting\n"); + LOG("i3 %s starting\n", i3_version); conn = xcb_connect(NULL, &conn_screen); if (xcb_connection_has_error(conn)) diff --git a/src/version.c b/src/version.c new file mode 100644 index 00000000..d7d31b36 --- /dev/null +++ b/src/version.c @@ -0,0 +1,11 @@ +/* + * vim:ts=4:sw=4:expandtab + * + * i3 - an improved dynamic tiling window manager + * © 2009-2015 Michael Stapelberg and contributors (see also: LICENSE) + * + * Stores the latest Git commit identifier so that it can be linked into i3 + * and used dynamically without recompiling every object file. + * + */ +const char *i3_version = I3_VERSION;