]> git.ipfire.org Git - thirdparty/git.git/commitdiff
scalar: implement 'scalar list'
authorDerrick Stolee <dstolee@microsoft.com>
Fri, 3 Dec 2021 13:34:22 +0000 (13:34 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 5 Dec 2021 05:52:23 +0000 (21:52 -0800)
The produced list simply consists of those repositories registered under
the multi-valued `scalar.repo` config setting in the user's Git config.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/scalar/scalar.c
contrib/scalar/scalar.txt

index ec783e72ef323c99d6d964ebc183abe99a53ff0e..65da885c5acd3a10649a48d3ee20ff8c4f4dbbc0 100644 (file)
@@ -251,6 +251,16 @@ static int unregister_dir(void)
        return res;
 }
 
+static int cmd_list(int argc, const char **argv)
+{
+       if (argc != 1)
+               die(_("`scalar list` does not take arguments"));
+
+       if (run_git("config", "--global", "--get-all", "scalar.repo", NULL) < 0)
+               return -1;
+       return 0;
+}
+
 static int cmd_register(int argc, const char **argv)
 {
        struct option options[] = {
@@ -337,6 +347,7 @@ static struct {
        const char *name;
        int (*fn)(int, const char **);
 } builtins[] = {
+       { "list", cmd_list },
        { "register", cmd_register },
        { "unregister", cmd_unregister },
        { NULL, NULL},
index d9a79984492a8e40bdae51dc0f7aa112a6bae123..f93e3d00efdd135d7d6c1126a4416145618614ea 100644 (file)
@@ -8,6 +8,7 @@ scalar - an opinionated repository management tool
 SYNOPSIS
 --------
 [verse]
+scalar list
 scalar register [<enlistment>]
 scalar unregister [<enlistment>]
 
@@ -28,11 +29,19 @@ an existing Git worktree with Scalar whose name is not `src`, the enlistment
 will be identical to the worktree.
 
 The `scalar` command implements various subcommands, and different options
-depending on the subcommand.
+depending on the subcommand. With the exception of `list`, all subcommands
+expect to be run in an enlistment.
 
 COMMANDS
 --------
 
+List
+~~~~
+
+list::
+       List enlistments that are currently registered by Scalar. This
+       subcommand does not need to be run inside an enlistment.
+
 Register
 ~~~~~~~~