From 1555d8dcf0b07b01632cb5699f081f8a701c7846 Mon Sep 17 00:00:00 2001 From: APPLE Date: Fri, 6 Mar 2026 13:36:38 +0530 Subject: [PATCH] Add --commit-interval option for fixed-interval commit playback Adds a new --commit-interval SECONDS option that spaces commits at a fixed time interval regardless of their real timestamps. This is useful for demos and presentations where clarity between commits matters more than historical time accuracy. When active, commit timestamps are remapped so each commit appears exactly N seconds after the previous one, while preserving chronological order. Auto-skip is automatically disabled in this mode. Closes #357 Co-Authored-By: Claude Opus 4.6 --- src/gource.cpp | 11 +++++++++++ src/gource.h | 3 +++ src/gource_settings.cpp | 17 +++++++++++++++++ src/gource_settings.h | 1 + 4 files changed, 32 insertions(+) diff --git a/src/gource.cpp b/src/gource.cpp index cf86c4f9..1fbcf37b 100644 --- a/src/gource.cpp +++ b/src/gource.cpp @@ -918,6 +918,9 @@ void Gource::reset() { commitqueue_max_size = 100; + commit_interval_count = 0; + commit_interval_base = 0; + rotate_angle = 0.0f; if(root!=0) delete root; @@ -1145,6 +1148,14 @@ void Gource::readLog() { continue; } + if(gGourceSettings.commit_interval > 0.0f) { + if(commit_interval_count == 0) { + commit_interval_base = commit.timestamp; + } + commit.timestamp = commit_interval_base + (time_t)(commit_interval_count * gGourceSettings.commit_interval); + commit_interval_count++; + } + if(gGourceSettings.stop_timestamp != 0 && commit.timestamp > gGourceSettings.stop_timestamp) { stop_position_reached = true; break; diff --git a/src/gource.h b/src/gource.h index 338e7ac5..eb256882 100644 --- a/src/gource.h +++ b/src/gource.h @@ -178,6 +178,9 @@ class Gource : public SDLApp { int commitqueue_max_size; float starting_z; + int commit_interval_count; + time_t commit_interval_base; + std::deque commitqueue; std::map users; std::map files; diff --git a/src/gource_settings.cpp b/src/gource_settings.cpp index 76ec9479..1f7a4d6c 100644 --- a/src/gource_settings.cpp +++ b/src/gource_settings.cpp @@ -74,6 +74,7 @@ void GourceSettings::help(bool extended_help) { printf(" for a number of seconds (default: 3)\n"); printf(" --disable-auto-skip Disable auto skip\n"); printf(" -s, --seconds-per-day SECONDS Speed in seconds per day (default: 10)\n"); + printf(" --commit-interval SECONDS Fixed number of seconds between commits\n"); printf(" --realtime Realtime playback speed\n"); printf(" --no-time-travel Use the time of the last commit if the\n"); printf(" time of a commit is in the past\n"); @@ -295,6 +296,7 @@ GourceSettings::GourceSettings() { arg_types["bloom-multiplier"] = "float"; arg_types["elasticity"] = "float"; arg_types["seconds-per-day"] = "float"; + arg_types["commit-interval"] = "float"; arg_types["auto-skip-seconds"] = "float"; arg_types["stop-at-time"] = "float"; arg_types["max-user-speed"] = "float"; @@ -408,6 +410,7 @@ void GourceSettings::setGourceDefaults() { auto_skip_seconds = 3.0f; days_per_second = 0.1f; // TODO: check this is right + commit_interval = -1.0f; file_idle_time = 0.0f; file_idle_time_at_end = 0.0f; time_scale = 1.0f; @@ -1208,6 +1211,20 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc days_per_second = 1.0 / seconds_per_day; } + if((entry = gource_settings->getEntry("commit-interval")) != 0) { + + if(!entry->hasValue()) conffile.entryException(entry, "specify commit-interval (seconds)"); + + commit_interval = entry->getFloat(); + + if(commit_interval <= 0.0f) { + conffile.invalidValueException(entry); + } + + // disable auto-skip in commit-interval mode + auto_skip_seconds = -1.0f; + } + if((entry = gource_settings->getEntry("auto-skip-seconds")) != 0) { if(!entry->hasValue()) conffile.entryException(entry, "specify auto-skip-seconds (seconds)"); diff --git a/src/gource_settings.h b/src/gource_settings.h index 8b29af8f..ae39ce5c 100644 --- a/src/gource_settings.h +++ b/src/gource_settings.h @@ -75,6 +75,7 @@ class GourceSettings : public SDLAppSettings { float auto_skip_seconds; float days_per_second; + float commit_interval; float file_idle_time; float file_idle_time_at_end; float loop_delay_seconds;