All of lore.kernel.org
 help / color / mirror / Atom feed
From: Karthik Nayak <karthik.188@gmail.com>
To: karthik.188@gmail.com
Cc: git@vger.kernel.org, gitster@pobox.com, ps@pks.im
Subject: [PATCH v3 0/6] update-ref: add symref support for --stdin
Date: Thu, 30 May 2024 15:09:34 +0300	[thread overview]
Message-ID: <20240530120940.456817-1-knayak@gitlab.com> (raw)
In-Reply-To: <20240514124411.1037019-1-knayak@gitlab.com>

From: Karthik Nayak <karthik.188@gmail.com>

The 'update-ref' command is used to update refs using transactions. The
command allows users to also utilize a '--stdin' mode to provide a
batch of sub-commands which can be processed in a transaction.

Currently, the sub-commands involve {verify, delete, create, update}
and they allow users to work with regular refs in the repository. To
work with symrefs, users only have the option of using
'git-symbolic-ref', which doesn't provide transaction support to the
users eventhough it uses the same behind the hood.

Recently, we modified the reference backend to add symref support,
following which, 'git-symbolic-ref' also uses the transaction backend.
But, it doesn't expose this to the user. To allow users to work with
symrefs via transaction, this series adds support for new sub-commands
{symrer-verify, symref-delete, symref-create, symref-update} to the
'--stdin' mode of update-ref. These complement the existing
sub-commands.

The patches 1, 5 fix small issues in the reference backends. The other
patches 2, 3, 4 & 6, each add one of the new sub-commands.

The series is based off master, with 'kn/ref-transaction-symref' merged
in. There seem to be no conflicts with 'next' or 'seen'.

There was some discussion [1] also about adding `old_target` support to
the existing `update` command. I think its worthwhile to do this with
some tests cleanup, will follow that up as a separate series.

Changes since v2:
* Based off 'ps/fixleaks' (commit: ebdbefa4fe9f618347124b37d44e517e0c6a3e4c)
which brought to light two leaks, which have been fixed.
* Adding credit where it's due.

[1]: https://lore.kernel.org/r/CAOLa=ZQW-cCV5BP_fCvuZimfkjwAzjEiqXYRPft1Wf9kAX=_bw@mail.gmail.com

I used the '--range-diff' flag for 'git-format-patch(1)' this time.
Also I'm on vacation at the moment, so my responses are a bit slower than usual.

Karthik Nayak (6):
  refs: create and use `ref_update_expects_existing_old_ref()`
  update-ref: add support for 'symref-verify' command
  update-ref: add support for 'symref-delete' command
  update-ref: add support for 'symref-create' command
  reftable: pick either 'oid' or 'target' for new updates
  update-ref: add support for 'symref-update' command

 Documentation/git-update-ref.txt |  25 ++
 builtin/clone.c                  |   2 +-
 builtin/fetch.c                  |   2 +-
 builtin/receive-pack.c           |   3 +-
 builtin/update-ref.c             | 237 +++++++++++++++++-
 refs.c                           |  40 ++-
 refs.h                           |   6 +-
 refs/files-backend.c             |   3 +-
 refs/refs-internal.h             |   6 +
 refs/reftable-backend.c          |   7 +-
 t/t0600-reffiles-backend.sh      |  32 +++
 t/t1400-update-ref.sh            | 416 ++++++++++++++++++++++++++++++-
 t/t1416-ref-transaction-hooks.sh |  54 ++++
 t/t5605-clone-local.sh           |   2 +-
 14 files changed, 801 insertions(+), 34 deletions(-)

Range-diff against v2:
1:  2bbdeff798 ! 1:  cab5265c3c refs: create and use `ref_update_expects_existing_old_ref()`
    @@ Commit message
         `ref_update_expects_existing_old_ref()` and expose it internally via
         'refs-internal.h'.
     
    +    Helped-by: Patrick Steinhardt <ps@pks.im>
         Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
     
      ## refs.c ##
2:  f509066cab ! 2:  ed54b0dfb9 update-ref: add support for 'symref-verify' command
    @@ Commit message
         divergence from behavior, but we never tested to ensure that reflog
         wasn't affected by the 'verify' command.
     
    +    Helped-by: Patrick Steinhardt <ps@pks.im>
         Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
     
      ## Documentation/git-update-ref.txt ##
3:  a11f4c1e48 ! 3:  b82b86ff40 update-ref: add support for 'symref-delete' command
    @@ Commit message
         within a transaction, which promises atomicity of the operation and can
         be batched with other commands.
     
    +    Helped-by: Patrick Steinhardt <ps@pks.im>
         Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
     
      ## Documentation/git-update-ref.txt ##
4:  9b71c9e07b ! 4:  ae127f7d52 update-ref: add support for 'symref-create' command
    @@ Commit message
         as a symlink. We fallback to creating a regular symref if creating the
         symlink is unsuccessful.
     
    +    Helped-by: Patrick Steinhardt <ps@pks.im>
         Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
     
      ## Documentation/git-update-ref.txt ##
5:  a9b1a31756 ! 5:  8889dcbf40 reftable: pick either 'oid' or 'target' for new updates
    @@ Commit message
         want to introduce the 'symref-update' command in the upcoming commit,
         which would use this flow, correct it.
     
    +    Helped-by: Patrick Steinhardt <ps@pks.im>
         Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
     
      ## refs/reftable-backend.c ##
6:  1bbbe86743 ! 6:  19d85d56c4 update-ref: add support for 'symref-update' command
    @@ Commit message
         This command supports deref mode, to ensure that we can update
         dereferenced regular refs to symrefs.
     
    +    Helped-by: Patrick Steinhardt <ps@pks.im>
    +    Helped-by: Junio C Hamano <gitster@pobox.com>
         Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
     
      ## Documentation/git-update-ref.txt ##
    @@ builtin/update-ref.c: static char *parse_next_refname(const char **next)
     +
     +	if (arg.len)
     +		return strbuf_detach(&arg, NULL);
    ++
    ++	strbuf_release(&arg);
     +	return NULL;
     +}
      
    @@ builtin/update-ref.c: static void parse_cmd_update(struct ref_transaction *trans
     +			if (repo_get_oid(the_repository, old_target, &old_oid))
     +				die("symref-update %s: invalid oid: %s", refname, old_target);
     +
    -+			old_target = NULL;
     +			have_old_oid = 1;
     +		} else if (!strcmp(old_arg, "ref")) {
     +			if (check_refname_format(old_target, REFNAME_ALLOW_ONELEVEL))
    @@ builtin/update-ref.c: static void parse_cmd_update(struct ref_transaction *trans
     +
     +	if (ref_transaction_update(transaction, refname, NULL,
     +				   have_old_oid ? &old_oid : NULL,
    -+				   new_target, old_target,
    ++				   new_target,
    ++				   have_old_oid ? NULL : old_target,
     +				   update_flags | create_reflog_flag,
     +				   msg, &err))
     +		die("%s", err.buf);
-- 
2.43.GIT


  parent reply	other threads:[~2024-05-30 12:09 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 12:44 [PATCH 0/6] update-ref: add symref support for --stdin Karthik Nayak
2024-05-14 12:44 ` [PATCH 1/6] refs: create and use `ref_update_ref_must_exist()` Karthik Nayak
2024-05-16 11:09   ` Patrick Steinhardt
2024-05-17 13:08     ` Karthik Nayak
2024-05-14 12:44 ` [PATCH 2/6] update-ref: add support for 'symref-verify' command Karthik Nayak
2024-05-16 11:09   ` Patrick Steinhardt
2024-05-17 16:21     ` Karthik Nayak
2024-05-21  6:41       ` Patrick Steinhardt
2024-05-14 12:44 ` [PATCH 3/6] update-ref: add support for 'symref-delete' command Karthik Nayak
2024-05-16 11:09   ` Patrick Steinhardt
2024-05-14 12:44 ` [PATCH 4/6] update-ref: add support for 'symref-create' command Karthik Nayak
2024-05-16 11:09   ` Patrick Steinhardt
2024-05-19 14:01     ` Karthik Nayak
2024-05-14 12:44 ` [PATCH 5/6] reftable: pick either 'oid' or 'target' for new updates Karthik Nayak
2024-05-14 12:44 ` [PATCH 6/6] update-ref: add support for 'symref-update' command Karthik Nayak
2024-05-16 11:09   ` Patrick Steinhardt
2024-05-21  9:49     ` Karthik Nayak
2024-05-22  7:59       ` Karthik Nayak
2024-05-22  9:03 ` [PATCH v2 0/6] update-ref: add symref support for --stdin Karthik Nayak
2024-05-22  9:03   ` [PATCH v2 1/6] refs: create and use `ref_update_expects_existing_old_ref()` Karthik Nayak
2024-05-22  9:03   ` [PATCH v2 2/6] update-ref: add support for 'symref-verify' command Karthik Nayak
2024-05-22  9:03   ` [PATCH v2 3/6] update-ref: add support for 'symref-delete' command Karthik Nayak
2024-05-22  9:03   ` [PATCH v2 4/6] update-ref: add support for 'symref-create' command Karthik Nayak
2024-05-22  9:03   ` [PATCH v2 5/6] reftable: pick either 'oid' or 'target' for new updates Karthik Nayak
2024-05-22  9:03   ` [PATCH v2 6/6] update-ref: add support for 'symref-update' command Karthik Nayak
2024-05-25 23:00     ` Junio C Hamano
2024-05-29  8:29       ` Karthik Nayak
2024-05-23 15:02   ` [PATCH v2 0/6] update-ref: add symref support for --stdin Junio C Hamano
2024-05-23 15:52     ` Karthik Nayak
2024-05-23 16:29       ` Junio C Hamano
2024-05-23 17:50         ` Karthik Nayak
2024-05-23 17:59         ` Eric Sunshine
2024-05-23 18:08           ` Junio C Hamano
2024-05-23 18:50             ` Eric Sunshine
2024-05-23 19:06               ` Junio C Hamano
2024-05-23 21:46           ` Junio C Hamano
2024-05-23 16:03     ` Junio C Hamano
2024-05-30 12:09 ` Karthik Nayak [this message]
2024-06-05  8:02   ` [PATCH v3 " Patrick Steinhardt
2024-05-30 12:09 ` [PATCH v3 1/6] refs: create and use `ref_update_expects_existing_old_ref()` Karthik Nayak
2024-05-30 12:09 ` [PATCH v3 2/6] update-ref: add support for 'symref-verify' command Karthik Nayak
2024-05-30 12:09 ` [PATCH v3 3/6] update-ref: add support for 'symref-delete' command Karthik Nayak
2024-06-05  8:02   ` Patrick Steinhardt
2024-06-05  9:31     ` Karthik Nayak
2024-06-05 16:22     ` Junio C Hamano
2024-05-30 12:09 ` [PATCH v3 4/6] update-ref: add support for 'symref-create' command Karthik Nayak
2024-06-05  8:02   ` Patrick Steinhardt
2024-05-30 12:09 ` [PATCH v3 5/6] reftable: pick either 'oid' or 'target' for new updates Karthik Nayak
2024-05-30 12:09 ` [PATCH v3 6/6] update-ref: add support for 'symref-update' command Karthik Nayak
2024-06-05  8:02   ` Patrick Steinhardt

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=20240530120940.456817-1-knayak@gitlab.com \
    --to=karthik.188@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ps@pks.im \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.