[PATCH v3 0/4] maintenance: use systemd timers on Linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Thanks again for your valuable feedback!
I’ve reworked this submission to hopefully address all the raised
concerns.

As it’s becoming bigger, I’ve split it in several patches:

* cache.h: rename "xdg_config_home" to "xdg_config_home_git"

In order to honor `$XDG_CONFIG_HOME` to built the path of systemd units,
a lot of code from the `xdg_config_home()` function was
duplicated. This existing function couldn’t be used as-is because
it was hard-coding the `git` sub-directory below `$XDG_CONFIG_HOME`.

This first preparatory patch re-purposes `xdg_config_home()` to make
it more generic by removing the `git` path it used to append to
`$XDG_CONFIG_HOME`.
Thanks to this refactoring, `xdg_config_home()` can be used to build
paths like:
* `$XDG_CONFIG_HOME/git/…` it’s the new `xdg_config_home_git()`
function and
* `$XDG_CONFIG_HOME/systemd/user/…` it’s the new
`xdg_config_home_systemd()` function which will be introduced later,
in the last patch of this series.

* maintenance: introduce ENABLE/DISABLE for code clarity

Some functions in git maintenance are doing one thing and the exact
opposite, depending on a parameter that could be `0` or `1`.
This could sometimes be confusing.
This patch introduces an enum with `ENABLE` and `DISABLE` values to
make the code more explicit.

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

This patch contains all the code that is related to the addition of
the new `--scheduler` parameter of the `git maintenance start`
command, independently of the systemd timers.

This part has significantly changed to review the testing mechanisms.
The `GIT_TEST_MAINT_SCHEDULER` environment variable can now take a
comma separated list of schedulers and their mock in order to be able
to test cases where multiple schedulers are available.

It allows to test that `git maintenance start --scheduler=XXX` not
only enables the scheduler XXX, but it also disables all the other
available ones.
We can also test that `git maintenance stop`, stops all the available
schedulers.

In order to remove the `cmd` parameter that was passed to a lot of
functions, the parsing of `GIT_TEST_MAINT_SCHEDULER` is now factorized
in a `get_schedule_cmd()` function that is invoked from the leaves of
the function call tree.
It means that this function is called many times to parse
`GIT_TEST_MAINT_SCHEDULER` again and again.
It is inefficient but as it is used for test only, it shouldn’t be a
concern.

`int get_schdule_cmd(const char **cmd, int *is_available)`

This function returns `true` if `GIT_TEST_MAINT_SCHEDULER` is
defined. `false` otherwise.

`*is_available` is set to `true` if `*cmd` is present in
`$GIT_TEST_MAINT_SCHEDULER`, and to `false` otherwise.

If `*cmd` is present in `$GIT_TEST_MAINT_SCHEDULER`, it’s value is
updated to its mock.

* maintenance: optionally use systemd timers on Linux

This last patch adds the support for systemd timers.

Lénaïc Huard (4):
  cache.h: rename "xdg_config_home" to "xdg_config_home_git"
  maintenance: introduce ENABLE/DISABLE for code clarity
  maintenance: `git maintenance run` learned `--scheduler=<scheduler>`
  maintenance: optionally use systemd timers on Linux

 Documentation/git-maintenance.txt |  60 ++++
 attr.c                            |   2 +-
 builtin/config.c                  |   2 +-
 builtin/credential-cache.c        |   2 +-
 builtin/credential-store.c        |   2 +-
 builtin/gc.c                      | 549 ++++++++++++++++++++++++++----
 cache.h                           |  12 +-
 config.c                          |   2 +-
 dir.c                             |   2 +-
 path.c                            |  35 +-
 sequencer.c                       |   2 +-
 t/t7900-maintenance.sh            | 110 +++++-
 12 files changed, 685 insertions(+), 95 deletions(-)

-- 
2.31.1




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux