]> git.ipfire.org Git - thirdparty/git.git/commit - scalar.c
scalar: make 'unregister' idempotent
authorDerrick Stolee <derrickstolee@github.com>
Tue, 27 Sep 2022 13:56:59 +0000 (13:56 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Sep 2022 16:32:26 +0000 (09:32 -0700)
commitd871b6c6c634689134a92d068bfb066d77d8429d
tree72114758a276c62065dcab06a2eb4f1afa902949
parent1ebe6b029703e4bebf413ec052918a81390797ac
scalar: make 'unregister' idempotent

The 'scalar unregister' command removes a repository from the list of
registered Scalar repositories and removes it from the list of
repositories registered for background maintenance. If the repository
was not already registered for background maintenance, then the command
fails, even if the repository was still registered as a Scalar
repository.

After using 'scalar clone' or 'scalar register', the repository would be
enrolled in background maintenance since those commands run 'git
maintenance start'. If the user runs 'git maintenance unregister' on
that repository, then it is still in the list of repositories which get
new config updates from 'scalar reconfigure'. The 'scalar unregister'
command would fail since 'git maintenance unregister' would fail.

Further, the add_or_remove_enlistment() method in scalar.c already has
this idempotent nature built in as an expectation since it returns zero
when the scalar.repo list already has the proper containment of the
repository.

The previous change added the 'git maintenance unregister --force'
option, so use it within 'scalar unregister' to make it idempotent.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
scalar.c
t/t9210-scalar.sh