git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 01/15] run-job: create barebones builtin

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 3, 2020, 20:48 UTC
Message-ID
<665da239774419074a9bae49b9c92b340885bfa3.1585946894.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.597.git.1585946894.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>

The 'git run-job' command will be used to execute a short-lived set of maintenance activities by a background job manager. The intention is to perform small batches of work that reduce the foreground time taken by repository maintenance such as 'git gc --auto'.

This change does the absolute minimum to create the builtin and show the usage output.

Provide an explicit warning that this command is experimental. The set of jobs may change, and each job could alter its behavior in future versions.

RFC QUESTION: This builtin is based on the background maintenance in Scalar. Specifically, this builtin is based on the "scalar run <job>" command [1] [2]. My default thought was to make this a "git run <job>" command to maximize similarity. However, it seems like "git run" is too generic. Or, am I being overly verbose for no reason?

[1] https://github.com/microsoft/scalar/blob/master/docs/advanced.md#run-maintenance-in-the-foreground [2] https://github.com/microsoft/scalar/blob/master/Scalar/CommandLine/RunVerb.cs

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 .gitignore                    |  1 +
 Documentation/git-run-job.txt | 36 +++++++++++++++++++++++++++++++++++
 Makefile                      |  1 +
 builtin.h                     |  1 +
 builtin/run-job.c             | 28 +++++++++++++++++++++++++++
 command-list.txt              |  1 +
 git.c                         |  1 +
 t/t7900-run-job.sh            | 15 +++++++++++++++
 8 files changed, 84 insertions(+)
 create mode 100644 Documentation/git-run-job.txt
 create mode 100644 builtin/run-job.c
 create mode 100755 t/t7900-run-job.sh
diff --git a/.gitignore b/.gitignore
index 188bd1c3de1..5dea9d3b96b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -144,6 +144,7 @@
 /git-rev-parse
 /git-revert
 /git-rm
+/git-run-job
 /git-send-email
 /git-send-pack
 /git-serve
diff --git a/Documentation/git-run-job.txt b/Documentation/git-run-job.txt
new file mode 100644
index 00000000000..0627b3ed259
--- /dev/null
+++ b/Documentation/git-run-job.txt
@@ -0,0 +1,36 @@
+git-run-job(1)
+==============
+
+NAME
+----
+git-run-job - Run a maintenance job. Intended for background operation.
+
+
+SYNOPSIS
+--------
+[verse]
+'git run-job <job-name>'
+
+
+DESCRIPTION
+-----------
+
+Run a maintenance job on the current repository. This is available as a
+command for a few reasons. First, the background job feature can launch
+these commands on a schedule and each process will completely clear its
+memory when complete. Second, an expert user could create their own job
+schedule by running these jobs themselves.
+
+THIS COMMAND IS EXPERIMENTAL. THE SET OF AVAILABLE JOBS OR THEIR EXACT
+BEHAVIOR MAY BE ALTERED IN THE FUTURE.
+
+
+JOBS
+----
+
+TBD
+
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/Makefile b/Makefile
index ef1ff2228f0..f5f9c4d9e94 100644
--- a/Makefile
+++ b/Makefile
@@ -1125,6 +1125,7 @@ BUILTIN_OBJS += builtin/rev-list.o
 BUILTIN_OBJS += builtin/rev-parse.o
 BUILTIN_OBJS += builtin/revert.o
 BUILTIN_OBJS += builtin/rm.o
+BUILTIN_OBJS += builtin/run-job.o
 BUILTIN_OBJS += builtin/send-pack.o
 BUILTIN_OBJS += builtin/shortlog.o
 BUILTIN_OBJS += builtin/show-branch.o
diff --git a/builtin.h b/builtin.h
index 2b25a80cde3..3e0ddaaf67f 100644
--- a/builtin.h
+++ b/builtin.h
@@ -220,6 +220,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix);
 int cmd_rev_parse(int argc, const char **argv, const char *prefix);
 int cmd_revert(int argc, const char **argv, const char *prefix);
 int cmd_rm(int argc, const char **argv, const char *prefix);
+int cmd_run_job(int argc, const char **argv, const char *prefix);
 int cmd_send_pack(int argc, const char **argv, const char *prefix);
 int cmd_shortlog(int argc, const char **argv, const char *prefix);
 int cmd_show(int argc, const char **argv, const char *prefix);
diff --git a/builtin/run-job.c b/builtin/run-job.c
new file mode 100644
index 00000000000..2c78d053aa4
--- /dev/null
+++ b/builtin/run-job.c
@@ -0,0 +1,28 @@
+#include "builtin.h"
+#include "config.h"
+#include "parse-options.h"
+
+static char const * const builtin_run_job_usage[] = {
+	N_("git run-job"),
+	NULL
+};
+
+int cmd_run_job(int argc, const char **argv, const char *prefix)
+{
+	static struct option builtin_run_job_options[] = {
+		OPT_END(),
+	};
+
+	if (argc == 2 && !strcmp(argv[1], "-h"))
+		usage_with_options(builtin_run_job_usage,
+				   builtin_run_job_options);
+
+	git_config(git_default_config, NULL);
+	argc = parse_options(argc, argv, prefix,
+			     builtin_run_job_options,
+			     builtin_run_job_usage,
+			     PARSE_OPT_KEEP_UNKNOWN);
+
+	usage_with_options(builtin_run_job_usage,
+			   builtin_run_job_options);
+}
diff --git a/command-list.txt b/command-list.txt
index 20878946558..1cd2b415e46 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -156,6 +156,7 @@ git-revert                              mainporcelain
 git-rev-list                            plumbinginterrogators
 git-rev-parse                           plumbinginterrogators
 git-rm                                  mainporcelain           worktree
+git-run-job                             plumbingmanipulators
 git-send-email                          foreignscminterface             complete
 git-send-pack                           synchingrepositories
 git-shell                               synchelpers
diff --git a/git.c b/git.c
index b07198fe036..db5a43c8687 100644
--- a/git.c
+++ b/git.c
@@ -566,6 +566,7 @@ static struct cmd_struct commands[] = {
 	{ "rev-parse", cmd_rev_parse, NO_PARSEOPT },
 	{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
 	{ "rm", cmd_rm, RUN_SETUP },
+	{ "run-job", cmd_run_job, RUN_SETUP },
 	{ "send-pack", cmd_send_pack, RUN_SETUP },
 	{ "shortlog", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER },
 	{ "show", cmd_show, RUN_SETUP },
diff --git a/t/t7900-run-job.sh b/t/t7900-run-job.sh
new file mode 100755
index 00000000000..1eac80b7ed3
--- /dev/null
+++ b/t/t7900-run-job.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+test_description='git run-job
+
+Testing the background jobs, in the foreground
+'
+
+. ./test-lib.sh
+
+test_expect_success 'help text' '
+	test_must_fail git run-job -h 2>err &&
+	test_i18ngrep "usage: git run-job" err
+'
+
+test_done
-- 
gitgitgadget
Previous: Derrick Stolee via GitGitGadgetNext: Phillip Wood
Message 2 of 55 in “[RFC] Maintenance jobs and job runner”
  1. 00/15 [RFC] Maintenance jobs and job runnerDerrick Stolee via GitGitGadget, Apr 3, 2020
  2. 01/15 run-job: create barebones builtinDerrick Stolee via GitGitGadget, Apr 3, 2020
  3. Phillip WoodApr 5, 2020
  4. Junio C HamanoApr 5, 2020
  5. Derrick StoleeApr 6, 2020
  6. Danh DoanApr 7, 2020
  7. Derrick StoleeApr 7, 2020
  8. Danh DoanApr 7, 2020
  9. Johannes SchindelinApr 7, 2020
  10. 02/15 run-job: implement commit-graph jobDerrick Stolee via GitGitGadget, Apr 3, 2020
  11. Josh SteadmonMay 20, 2020
  12. 05/15 run-job: implement pack-files jobDerrick Stolee via GitGitGadget, Apr 3, 2020
  13. Josh SteadmonMay 27, 2020
  14. 03/15 run-job: implement fetch jobDerrick Stolee via GitGitGadget, Apr 3, 2020
  15. Phillip WoodApr 5, 2020
  16. Derrick StoleeApr 6, 2020
  17. Junio C HamanoApr 5, 2020
  18. Derrick StoleeApr 6, 2020
  19. Josh SteadmonMay 20, 2020
  20. 06/15 run-job: auto-size or use custom pack-files batchDerrick Stolee via GitGitGadget, Apr 3, 2020
  21. 04/15 run-job: implement loose-objects jobDerrick Stolee via GitGitGadget, Apr 3, 2020
  22. Junio C HamanoApr 5, 2020
  23. 09/15 job-runner: load repos from config by defaultDerrick Stolee via GitGitGadget, Apr 3, 2020
  24. Phillip WoodApr 5, 2020
  25. Derrick StoleeApr 6, 2020
  26. Phillip WoodApr 5, 2020
  27. Derrick StoleeApr 6, 2020
  28. 08/15 job-runner: create builtin for job loopDerrick Stolee via GitGitGadget, Apr 3, 2020
  29. 11/15 job-runner: use config for loop intervalDerrick Stolee via GitGitGadget, Apr 3, 2020
  30. 10/15 job-runner: use config to limit job frequencyDerrick Stolee via GitGitGadget, Apr 3, 2020
  31. Phillip WoodApr 5, 2020
  32. 13/15 job-runner: skip a job if job.<job-name>.enabled is falseDerrick Stolee via GitGitGadget, Apr 3, 2020
  33. 14/15 job-runner: add --daemonize optionDerrick Stolee via GitGitGadget, Apr 3, 2020
  34. 12/15 job-runner: add --interval=<span> optionDerrick Stolee via GitGitGadget, Apr 3, 2020
  35. 07/15 config: add job.pack-files.batchSize optionDerrick Stolee via GitGitGadget, Apr 3, 2020
  36. 15/15 runjob: customize the loose-objects batch sizeDerrick Stolee via GitGitGadget, Apr 3, 2020
  37. Junio C HamanoApr 3, 2020
  38. Derrick StoleeApr 4, 2020
  39. Danh DoanApr 7, 2020
  40. Derrick StoleeApr 7, 2020
  41. Danh DoanApr 7, 2020
  42. Johannes SchindelinApr 7, 2020
  43. brian m. carlsonApr 7, 2020
  44. Junio C HamanoApr 7, 2020
  45. Johannes SchindelinApr 7, 2020
  46. brian m. carlsonApr 8, 2020
  47. Josh SteadmonMay 27, 2020
  48. Junio C HamanoMay 28, 2020
  49. Johannes SchindelinMay 27, 2020
  50. Junio C HamanoMay 28, 2020
  51. Jonathan NiederMay 28, 2020
  52. Junio C HamanoMay 28, 2020
  53. Jonathan NiederMay 28, 2020
  54. Derrick StoleeMay 28, 2020
  55. Johannes SchindelinMay 28, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.