Thread (119 messages) 119 messages, 15 authors, 2021-09-27

[PATCH v9 0/3] maintenance: add support for systemd timers on Linux

flat view
STALE1850d SUPERSEDED

From: Lénaïc Huard <hidden>
Date: 2021-08-27 21:03:41

Revision v9 of 5 in this series.

Revisions (5)
  1. v6 [diff vs current]
  2. v7 [diff vs current]
  3. v8 [diff vs current]
  4. v9 current
  5. v10 [diff vs current]
Hello,

Please find hereafter my updated patchset to add support for systemd
timers on Linux for the `git maintenance start` command.

The goal of this re-roll is to address Derrick’s remarks [1]
Namely:
* Get rid of the #ifdef around real_is_systemd_timer_available
* Fix the whitespace issue in systemd_timer_setup_units

[1] https://lore.kernel.org/git/44904983-a6a8-d72f-24db-50bf112c585b@gmail.com/ (local)

The patches are:

* cache.h: Introduce a generic "xdg_config_home_for(…)" function

  This patch introduces a function to compute configuration files
  paths inside $XDG_CONFIG_HOME.

  This patch is unchanged compared to its previous version.

* maintenance: `git maintenance run` learned `--scheduler=<scheduler>`

  This patch adds a new parameter to the `git maintenance run` to let
  the user choose a scheduler.

  This patch is unchanged compared to its previous version.

* maintenance: add support for systemd timers on Linux

  This patch implements the support of systemd timers on top of
  crontab scheduler on Linux systems.

  * The whitespace nit has been fixed with `git rebase
    --whitespace=fix`

  * The #ifdef around real_is_systemd_timer_available has been dropped
    so that its code is compiled on every platform.

    This means that:
    * The availability of `launchctl` and `schtasks` are completely
      determined at compilation time by the platform.
    * The availability of `cron` and `systemd timers` are fully
      determined at runtime even if today only Linux might have systemd.

Best wishes,
Lénaïc.


Lénaïc Huard (3):
  cache.h: Introduce a generic "xdg_config_home_for(…)" function
  maintenance: `git maintenance run` learned `--scheduler=<scheduler>`
  maintenance: add support for systemd timers on Linux

 Documentation/git-maintenance.txt |  57 +++
 builtin/gc.c                      | 581 ++++++++++++++++++++++++++----
 cache.h                           |   7 +
 path.c                            |  13 +-
 t/t7900-maintenance.sh            | 110 +++++-
 5 files changed, 690 insertions(+), 78 deletions(-)

Diff-intervalle contre v8 :
-:  ---------- > 1:  1639bd151c cache.h: Introduce a generic "xdg_config_home_for(…)" function
-:  ---------- > 2:  ea5568269c maintenance: `git maintenance run` learned `--scheduler=<scheduler>`
1:  faf56c078f ! 3:  8c25ebd3be maintenance: add support for systemd timers on Linux
    @@ builtin/gc.c: static int crontab_update_schedule(int run_maintenance, int fd)
      	return result;
      }
      
    -+#ifdef __linux__
    -+
     +static int real_is_systemd_timer_available(void)
     +{
     +	struct child_process child = CHILD_PROCESS_INIT;
    @@ builtin/gc.c: static int crontab_update_schedule(int run_maintenance, int fd)
     +	return 1;
     +}
     +
    -+#else
    -+
    -+static int real_is_systemd_timer_available(void)
    -+{
    -+	return 0;
    -+}
    -+
    -+#endif
    -+
     +static int is_systemd_timer_available(void)
     +{
     +	const char *cmd = "systemctl";
    @@ builtin/gc.c: static int crontab_update_schedule(int run_maintenance, int fd)
     +	const char *exec_path = git_exec_path();
     +
     +	int ret = systemd_timer_write_unit_templates(exec_path) ||
    -+	          systemd_timer_enable_unit(1, SCHEDULE_HOURLY) ||
    -+	          systemd_timer_enable_unit(1, SCHEDULE_DAILY) ||
    -+	          systemd_timer_enable_unit(1, SCHEDULE_WEEKLY);
    ++		  systemd_timer_enable_unit(1, SCHEDULE_HOURLY) ||
    ++		  systemd_timer_enable_unit(1, SCHEDULE_DAILY) ||
    ++		  systemd_timer_enable_unit(1, SCHEDULE_WEEKLY);
     +	if (ret)
     +		systemd_timer_delete_units();
     +	return ret;
-- 
2.33.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help