git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Karthik Nayak <karthik.188@gmail.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 00/12] Introduce `refStorage` extension
Date: Thu, 28 Dec 2023 10:57:23 +0100	[thread overview]
Message-ID: <cover.1703753910.git.ps@pks.im> (raw)
In-Reply-To: <cover.1703067989.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 12827 bytes --]

Hi,

this is the second version of my patch series that introduces the new
`refStorage` extension. This extension will be used for the upcoming
reftable backend.

Changes compared to v2:

  - Fixed various typos in commit messages.

  - Fixed redundant information when the refstorage extension's value
    isn't understood.

  - Introduced `repo_set_ref_storage_format()`.

Thanks for the feedback so far!

Patrick

Patrick Steinhardt (12):
  t: introduce DEFAULT_REPO_FORMAT prereq
  worktree: skip reading HEAD when repairing worktrees
  refs: refactor logic to look up storage backends
  setup: start tracking ref storage format
  setup: set repository's formats on init
  setup: introduce "extensions.refStorage" extension
  setup: introduce GIT_DEFAULT_REF_FORMAT envvar
  t: introduce GIT_TEST_DEFAULT_REF_FORMAT envvar
  builtin/rev-parse: introduce `--show-ref-format` flag
  builtin/init: introduce `--ref-format=` value flag
  builtin/clone: introduce `--ref-format=` value flag
  t9500: write "extensions.refstorage" into config

 Documentation/config/extensions.txt           | 11 +++
 Documentation/git-clone.txt                   |  6 ++
 Documentation/git-init.txt                    |  7 ++
 Documentation/git-rev-parse.txt               |  3 +
 Documentation/git.txt                         |  5 ++
 Documentation/ref-storage-format.txt          |  1 +
 .../technical/repository-version.txt          |  5 ++
 builtin/clone.c                               | 17 ++++-
 builtin/init-db.c                             | 15 +++-
 builtin/rev-parse.c                           |  4 ++
 refs.c                                        | 34 ++++++---
 refs.h                                        |  3 +
 refs/debug.c                                  |  1 -
 refs/files-backend.c                          |  1 -
 refs/packed-backend.c                         |  1 -
 refs/refs-internal.h                          |  1 -
 repository.c                                  |  6 ++
 repository.h                                  |  7 ++
 setup.c                                       | 63 +++++++++++++++--
 setup.h                                       |  9 ++-
 t/README                                      |  3 +
 t/t0001-init.sh                               | 70 +++++++++++++++++++
 t/t1500-rev-parse.sh                          | 17 +++++
 t/t3200-branch.sh                             |  2 +-
 t/t5601-clone.sh                              | 17 +++++
 t/t9500-gitweb-standalone-no-errors.sh        |  5 ++
 t/test-lib-functions.sh                       |  5 ++
 t/test-lib.sh                                 | 15 +++-
 worktree.c                                    | 24 ++++---
 29 files changed, 323 insertions(+), 35 deletions(-)
 create mode 100644 Documentation/ref-storage-format.txt

Range-diff against v1:
 1:  239ca38efd !  1:  3613439cb7 t: introduce DEFAULT_REPO_FORMAT prereq
    @@ Commit message
         repository format or otherwise they would fail to run, e.g. because they
         fail to detect the correct hash function. While the hash function is the
         only extension right now that creates problems like this, we are about
    -    to add a second extensions for the ref format.
    +    to add a second extension for the ref format.
     
         Introduce a new DEFAULT_REPO_FORMAT prereq that can easily be amended
         whenever we add new format extensions. Next to making any such changes
 2:  e895091025 !  2:  ecf4f1ddee worktree: skip reading HEAD when repairing worktrees
    @@ Commit message
         worktree: skip reading HEAD when repairing worktrees
     
         When calling `git init --separate-git-dir=<new-path>` on a preexisting
    -    repository, then we move the Git directory of that repository to the new
    -    path specified by the user. If there are worktrees present in the Git
    -    repository, we need to repair the worktrees so that their gitlinks point
    -    to the new location of the repository.
    +    repository, we move the Git directory of that repository to the new path
    +    specified by the user. If there are worktrees present in the repository,
    +    we need to repair the worktrees so that their gitlinks point to the new
    +    location of the repository.
     
         This repair logic will load repositories via `get_worktrees()`, which
         will enumerate up and initialize all worktrees. Part of initialization
    @@ Commit message
         format, which does not work.
     
         We do not require the worktree HEADs at all to repair worktrees. So
    -    let's fix issue this by skipping over the step that reads them.
    +    let's fix this issue by skipping over the step that reads them.
     
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
 3:  f712d5ef5b !  3:  12329b99b7 refs: refactor logic to look up storage backends
    @@ refs.c
     -	for (be = refs_backends; be; be = be->next)
     -		if (!strcmp(be->name, name))
     -			return be;
    -+	if (ref_storage_format && ref_storage_format < ARRAY_SIZE(refs_backends))
    ++	if (ref_storage_format < ARRAY_SIZE(refs_backends))
     +		return refs_backends[ref_storage_format];
      	return NULL;
      }
    @@ refs.c: static struct ref_store *ref_store_init(struct repository *repo,
      
      	if (!be)
     -		BUG("reference backend %s is unknown", be_name);
    -+		BUG("reference backend %s is unknown", ref_storage_format_to_name(format));
    ++		BUG("reference backend is unknown");
      
      	refs = be->init(repo, gitdir, flags);
      	return refs;
 4:  6564659d40 !  4:  ddd099fbaf setup: start tracking ref storage format when
    @@ Metadata
     Author: Patrick Steinhardt <ps@pks.im>
     
      ## Commit message ##
    -    setup: start tracking ref storage format when
    +    setup: start tracking ref storage format
     
         In order to discern which ref storage format a repository is supposed to
         use we need to start setting up and/or discovering the format. This
    @@ Commit message
           - The first path is when we create a repository via `init_db()`. When
             we are re-initializing a preexisting repository we need to retain
             the previously used ref storage format -- if the user asked for a
    -        different format then this indicates an erorr and we error out.
    +        different format then this indicates an error and we error out.
             Otherwise we either initialize the repository with the format asked
             for by the user or the default format, which currently is the
             "files" backend.
    @@ refs.c: static struct ref_store *ref_store_init(struct repository *repo,
      
     +	be = find_ref_storage_backend(repo->ref_storage_format);
      	if (!be)
    --		BUG("reference backend %s is unknown", ref_storage_format_to_name(format));
    -+		BUG("reference backend is unknown");
    - 
    - 	refs = be->init(repo, gitdir, flags);
    - 	return refs;
    -
    - ## refs.h ##
    -@@ refs.h: struct string_list;
    - struct string_list_item;
    - struct worktree;
    - 
    -+int default_ref_storage_format(void);
    - int ref_storage_format_by_name(const char *name);
    - const char *ref_storage_format_to_name(int ref_storage_format);
    + 		BUG("reference backend is unknown");
      
     
      ## repository.c ##
    +@@ repository.c: void repo_set_hash_algo(struct repository *repo, int hash_algo)
    + 	repo->hash_algo = &hash_algos[hash_algo];
    + }
    + 
    ++void repo_set_ref_storage_format(struct repository *repo, int format)
    ++{
    ++	repo->ref_storage_format = format;
    ++}
    ++
    + /*
    +  * Attempt to resolve and set the provided 'gitdir' for repository 'repo'.
    +  * Return 0 upon success and a non-zero value upon failure.
     @@ repository.c: int repo_init(struct repository *repo,
      		goto error;
      
      	repo_set_hash_algo(repo, format.hash_algo);
    -+	repo->ref_storage_format = format.ref_storage_format;
    ++	repo_set_ref_storage_format(repo, format.ref_storage_format);
      	repo->repository_format_worktree_config = format.worktree_config;
      
      	/* take ownership of format.partial_clone */
    @@ repository.h: struct repository {
      	/* A unique-id for tracing purposes. */
      	int trace2_repo_id;
      
    +@@ repository.h: void repo_set_gitdir(struct repository *repo, const char *root,
    + 		     const struct set_gitdir_args *extra_args);
    + void repo_set_worktree(struct repository *repo, const char *path);
    + void repo_set_hash_algo(struct repository *repo, int algo);
    ++void repo_set_ref_storage_format(struct repository *repo, int format);
    + void initialize_the_repository(void);
    + RESULT_MUST_BE_USED
    + int repo_init(struct repository *r, const char *gitdir, const char *worktree);
     
      ## setup.c ##
     @@ setup.c: const char *setup_git_directory_gently(int *nongit_ok)
      		}
      		if (startup_info->have_repository) {
      			repo_set_hash_algo(the_repository, repo_fmt.hash_algo);
    -+			the_repository->ref_storage_format =
    -+				repo_fmt.ref_storage_format;
    ++			repo_set_ref_storage_format(the_repository,
    ++						    repo_fmt.ref_storage_format);
      			the_repository->repository_format_worktree_config =
      				repo_fmt.worktree_config;
      			/* take ownership of repo_fmt.partial_clone */
    @@ setup.c: void check_repository_format(struct repository_format *fmt)
      	check_repository_format_gently(get_git_dir(), fmt, NULL);
      	startup_info->have_repository = 1;
      	repo_set_hash_algo(the_repository, fmt->hash_algo);
    -+	the_repository->ref_storage_format =
    -+		fmt->ref_storage_format;
    ++	repo_set_ref_storage_format(the_repository,
    ++				    fmt->ref_storage_format);
      	the_repository->repository_format_worktree_config =
      		fmt->worktree_config;
      	the_repository->repository_format_partial_clone =
    @@ setup.c: void create_reference_database(const char *initial_branch, int quiet)
      	safe_create_dir(git_path("refs"), 1);
      	adjust_shared_perm(git_path("refs"));
      
    -+	the_repository->ref_storage_format = ref_storage_format;
    ++	repo_set_ref_storage_format(the_repository, ref_storage_format);
      	if (refs_init_db(&err))
      		die("failed to set up refs db: %s", err.buf);
      
 5:  f90a63d63c !  5:  01a1e58a97 setup: set repository's formats on init
    @@ setup.c: int init_db(const char *git_dir, const char *real_git_dir,
     +	 * Now that we have set up both the hash algorithm and the ref storage
     +	 * format we can update the repository's settings accordingly.
     +	 */
    -+	the_repository->hash_algo = &hash_algos[repo_fmt.hash_algo];
    -+	the_repository->ref_storage_format = repo_fmt.ref_storage_format;
    ++	repo_set_hash_algo(the_repository, repo_fmt.hash_algo);
    ++	repo_set_ref_storage_format(the_repository, repo_fmt.ref_storage_format);
     +
      	if (!(flags & INIT_DB_SKIP_REFDB))
      		create_reference_database(repo_fmt.ref_storage_format,
 6:  beeb182f28 =  6:  0a586fa648 setup: introduce "extensions.refStorage" extension
 7:  dd91a75da4 =  7:  6d8754f73a setup: introduce GIT_DEFAULT_REF_FORMAT envvar
 8:  ed3bf008cd =  8:  c645932f3d t: introduce GIT_TEST_DEFAULT_REF_FORMAT envvar
 9:  8a3d950d69 =  9:  761d647770 builtin/rev-parse: introduce `--show-ref-format` flag
10:  4d98b53553 = 10:  e382b5bf08 builtin/init: introduce `--ref-format=` value flag
11:  71cf0ce827 = 11:  257233658d builtin/clone: introduce `--ref-format=` value flag
12:  bbe2fbb154 ! 12:  b8cd06ec53 t9500: write "extensions.refstorage" into config
    @@ Commit message
         t9500: write "extensions.refstorage" into config
     
         In t9500 we're writing a custom configuration that sets up gitweb. This
    -    requires us manually ensure that the repository format is configured as
    -    required, including both the repository format version and extensions.
    -    With the introduction of the "extensions.refStorage" extension we need
    -    to update the test to also write this new one.
    +    requires us to manually ensure that the repository format is configured
    +    as required, including both the repository format version and
    +    extensions. With the introduction of the "extensions.refStorage"
    +    extension we need to update the test to also write this new one.
     
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     

base-commit: e79552d19784ee7f4bbce278fe25f93fbda196fa
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2023-12-28  9:57 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20 10:54 [PATCH 00/12] Introduce `refStorage` extension Patrick Steinhardt
2023-12-20 10:54 ` [PATCH 01/12] t: introduce DEFAULT_REPO_FORMAT prereq Patrick Steinhardt
2023-12-22 11:41   ` Karthik Nayak
2023-12-28  8:55     ` Patrick Steinhardt
2023-12-20 10:54 ` [PATCH 02/12] worktree: skip reading HEAD when repairing worktrees Patrick Steinhardt
2023-12-22 12:23   ` Karthik Nayak
2023-12-20 10:55 ` [PATCH 03/12] refs: refactor logic to look up storage backends Patrick Steinhardt
2023-12-22 12:38   ` Karthik Nayak
2023-12-28  8:56     ` Patrick Steinhardt
2023-12-20 10:55 ` [PATCH 04/12] setup: start tracking ref storage format when Patrick Steinhardt
2023-12-20 18:30   ` Junio C Hamano
2023-12-28  8:56     ` Patrick Steinhardt
2023-12-28 17:15       ` Junio C Hamano
2023-12-28 20:01         ` Patrick Steinhardt
2023-12-22 13:09   ` Karthik Nayak
2023-12-28  8:56     ` Patrick Steinhardt
2023-12-20 10:55 ` [PATCH 05/12] setup: set repository's formats on init Patrick Steinhardt
2023-12-20 10:55 ` [PATCH 06/12] setup: introduce "extensions.refStorage" extension Patrick Steinhardt
2023-12-20 10:55 ` [PATCH 07/12] setup: introduce GIT_DEFAULT_REF_FORMAT envvar Patrick Steinhardt
2023-12-20 10:55 ` [PATCH 08/12] t: introduce GIT_TEST_DEFAULT_REF_FORMAT envvar Patrick Steinhardt
2023-12-20 10:55 ` [PATCH 09/12] builtin/rev-parse: introduce `--show-ref-format` flag Patrick Steinhardt
2023-12-20 10:55 ` [PATCH 10/12] builtin/init: introduce `--ref-format=` value flag Patrick Steinhardt
2023-12-20 10:55 ` [PATCH 11/12] builtin/clone: " Patrick Steinhardt
2023-12-20 10:55 ` [PATCH 12/12] t9500: write "extensions.refstorage" into config Patrick Steinhardt
2023-12-22 13:43   ` Karthik Nayak
2023-12-22 13:43 ` [PATCH 00/12] Introduce `refStorage` extension Karthik Nayak
2023-12-26 20:56   ` Junio C Hamano
2023-12-28  9:57 ` Patrick Steinhardt [this message]
2023-12-28  9:57   ` [PATCH v2 01/12] t: introduce DEFAULT_REPO_FORMAT prereq Patrick Steinhardt
2023-12-28  9:57   ` [PATCH v2 02/12] worktree: skip reading HEAD when repairing worktrees Patrick Steinhardt
2023-12-28 18:08     ` Eric Sunshine
2023-12-28 18:13       ` Eric Sunshine
2023-12-28 20:18         ` Patrick Steinhardt
2023-12-28  9:57   ` [PATCH v2 03/12] refs: refactor logic to look up storage backends Patrick Steinhardt
2023-12-28 17:25     ` Junio C Hamano
2023-12-28 20:11       ` Patrick Steinhardt
2023-12-28 20:42         ` Junio C Hamano
2023-12-28  9:57   ` [PATCH v2 04/12] setup: start tracking ref storage format Patrick Steinhardt
2023-12-28  9:57   ` [PATCH v2 05/12] setup: set repository's formats on init Patrick Steinhardt
2023-12-28  9:57   ` [PATCH v2 06/12] setup: introduce "extensions.refStorage" extension Patrick Steinhardt
2023-12-28  9:57   ` [PATCH v2 07/12] setup: introduce GIT_DEFAULT_REF_FORMAT envvar Patrick Steinhardt
2023-12-28  9:57   ` [PATCH v2 08/12] t: introduce GIT_TEST_DEFAULT_REF_FORMAT envvar Patrick Steinhardt
2023-12-28  9:58   ` [PATCH v2 09/12] builtin/rev-parse: introduce `--show-ref-format` flag Patrick Steinhardt
2023-12-28  9:58   ` [PATCH v2 10/12] builtin/init: introduce `--ref-format=` value flag Patrick Steinhardt
2023-12-28  9:58   ` [PATCH v2 11/12] builtin/clone: " Patrick Steinhardt
2023-12-28  9:58   ` [PATCH v2 12/12] t9500: write "extensions.refstorage" into config Patrick Steinhardt
2023-12-29  7:26 ` [PATCH v3 00/12] Introduce `refStorage` extension Patrick Steinhardt
2023-12-29  7:26   ` [PATCH v3 01/12] t: introduce DEFAULT_REPO_FORMAT prereq Patrick Steinhardt
2023-12-29  7:26   ` [PATCH v3 02/12] worktree: skip reading HEAD when repairing worktrees Patrick Steinhardt
2023-12-29  7:26   ` [PATCH v3 03/12] refs: refactor logic to look up storage backends Patrick Steinhardt
2023-12-29  7:26   ` [PATCH v3 04/12] setup: start tracking ref storage format Patrick Steinhardt
2023-12-29  7:26   ` [PATCH v3 05/12] setup: set repository's formats on init Patrick Steinhardt
2023-12-29  7:26   ` [PATCH v3 06/12] setup: introduce "extensions.refStorage" extension Patrick Steinhardt
2023-12-29  7:26   ` [PATCH v3 07/12] setup: introduce GIT_DEFAULT_REF_FORMAT envvar Patrick Steinhardt
2023-12-29  7:26   ` [PATCH v3 08/12] t: introduce GIT_TEST_DEFAULT_REF_FORMAT envvar Patrick Steinhardt
2023-12-29  7:27   ` [PATCH v3 09/12] builtin/rev-parse: introduce `--show-ref-format` flag Patrick Steinhardt
2023-12-29  7:27   ` [PATCH v3 10/12] builtin/init: introduce `--ref-format=` value flag Patrick Steinhardt
2023-12-29  7:27   ` [PATCH v3 11/12] builtin/clone: " Patrick Steinhardt
2023-12-29  7:27   ` [PATCH v3 12/12] t9500: write "extensions.refstorage" into config Patrick Steinhardt
2023-12-29  8:44   ` [PATCH v3 00/12] Introduce `refStorage` extension Eric Sunshine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1703753910.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karthik.188@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).