From 62b2718261b23075f276367697b7a2bbdba790ae Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 29 Sep 2022 15:18:41 -0700 Subject: [PATCH] Print on the title screen and in console if there are uncommitted changes --- src/Makefile | 8 ++++++++ src/comptime.c | 7 +++++++ src/d_netcmd.c | 3 +++ src/doomdef.h | 1 + src/f_finale.c | 2 ++ 5 files changed, 21 insertions(+) diff --git a/src/Makefile b/src/Makefile index 2367553ed..3c621001d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -195,6 +195,14 @@ passthru_opts:= # separate suffix with an underscore exesuffix:=$(call _,$(EXESUFFIX)) +# If there are uncommitted changes +# -uno: disregard untracked files +# Warning: this can only be accurate for comptime.c since +# that file is always recompiled! +ifneq ($(shell git status --porcelain -uno),) +opts+=-DCOMPVERSION_UNCOMMITTED +endif + include Makefile.d/platform.mk include Makefile.d/features.mk include Makefile.d/versions.mk diff --git a/src/comptime.c b/src/comptime.c index 398eda074..81b5ec7d6 100644 --- a/src/comptime.c +++ b/src/comptime.c @@ -15,6 +15,13 @@ const char *comprevision = SRB2_COMP_REVISION; #elif (defined(COMPVERSION)) #include "comptime.h" +const int compuncommitted = +#if (defined(COMPVERSION_UNCOMMITTED)) +1; +#else +0; +#endif + #else const char *compbranch = "Unknown"; const char *comprevision = "illegal"; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 58a17204b..8ecad7285 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4756,6 +4756,9 @@ static void Command_Version_f(void) CONS_Printf("\x87" "DEVELOP " "\x80"); #endif + if (compuncommitted) + CONS_Printf("\x85" "! UNCOMMITTED CHANGES ! " "\x80"); + CONS_Printf("\n"); } diff --git a/src/doomdef.h b/src/doomdef.h index 6997d7951..30c53c5c8 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -613,6 +613,7 @@ UINT32 quickncasehash (const char *p, size_t n) // Compile date and time and revision. extern const char *compdate, *comptime, *comprevision, *compbranch; +extern int compuncommitted; // Disabled code and code under testing // None of these that are disabled in the normal build are guaranteed to work perfectly diff --git a/src/f_finale.c b/src/f_finale.c index 005a4c6a1..7b5651535 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2006,6 +2006,8 @@ void F_TitleScreenDrawer(void) #else // Regular build addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s", VERSIONSTRING)); #endif + if (compuncommitted) + addtext(V_REDMAP|V_STRINGDANCE, "! UNCOMMITTED CHANGES !"); } #undef addtext }