git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: "Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Han-Wen Nienhuys <hanwenn@gmail.com>
Subject: [PATCH v2 0/3] Remove special casing for PSEUDOREF updates
Date: Thu, 09 Jul 2020 21:11:45 +0000	[thread overview]
Message-ID: <pull.673.v2.git.1594329108.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.673.git.1594056572.gitgitgadget@gmail.com>

This gets rid of the special casing code for pseudorefs in refs.c

This is in preparation for reftable.

v2

 * remove special casing of non-HEAD pseudorefs; update t1400 and t1405
   accordingly
 * open question: should git-update-ref.txt be updated, when it talks about
   logAllRefUpdates?

Han-Wen Nienhuys (3):
  t1400: use git rev-parse for testing PSEUDOREF existence
  Modify pseudo refs through ref backend storage
  Make HEAD a PSEUDOREF rather than PER_WORKTREE.

 refs.c                    | 127 +++-----------------------------------
 t/t1400-update-ref.sh     |  30 ++++-----
 t/t1405-main-ref-store.sh |   5 +-
 3 files changed, 29 insertions(+), 133 deletions(-)


base-commit: 4a0fcf9f760c9774be77f51e1e88a7499b53d2e2
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-673%2Fhanwen%2Fpseudoref-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-673/hanwen/pseudoref-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/673

Range-diff vs v1:

 -:  ---------- > 1:  9c3dc4b2cb t1400: use git rev-parse for testing PSEUDOREF existence
 1:  6821f57bdf ! 2:  871b411517 Modify pseudo refs through ref backend storage
     @@ Commit message
          well. Tooling that works directly on files under .git should be
          updated to use git commands to read refs instead.
      
     -    This needs the following fixes
     +    The following behaviors change:
      
     -    * Only write log for HEAD pseudo ref. Fixes t1400
     -      'core.logAllRefUpdates=always creates no reflog for ORIG_HEAD'
     +    * Updates to pseudorefs (eg. ORIG_HEAD) with
     +      core.logAllRefUpdates=always will create reflogs for the pseudoref.
      
     -    * t1400: change hard coded error messages to check for.
     -
     -    * don't deref non-HEAD pseudoref symrefs. This fixes t1405. Without
     -      this, a deleting a FOO symref pointing to refs/heads/master will remove
     -      master too.
     +    * non-HEAD pseudoref symrefs are also dereferenced on deletion. Update
     +      t1405 accordingly.
      
          Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
      
     @@ refs.c: int refs_update_ref(struct ref_store *refs, const char *msg,
       	if (ret) {
       		const char *str = _("update_ref failed for ref '%s': %s");
      
     - ## refs/files-backend.c ##
     -@@ refs/files-backend.c: static int files_delete_refs(struct ref_store *ref_store, const char *msg,
     - 
     - 	for (i = 0; i < refnames->nr; i++) {
     - 		const char *refname = refnames->items[i].string;
     --
     - 		if (refs_delete_ref(&refs->base, msg, refname, NULL, flags))
     - 			result |= error(_("could not remove reference %s"), refname);
     - 	}
     -@@ refs/files-backend.c: static int lock_ref_for_update(struct files_ref_store *refs,
     - 	update->backend_data = lock;
     + ## t/t1400-update-ref.sh ##
     +@@ t/t1400-update-ref.sh: test_expect_success 'core.logAllRefUpdates=always creates reflog by default' '
     + 	git reflog exists $outside
     + '
       
     - 	if (update->type & REF_ISSYMREF) {
     --		if (update->flags & REF_NO_DEREF) {
     -+		if (update->flags & REF_NO_DEREF ||
     -+		    (ref_type(update->refname) == REF_TYPE_PSEUDOREF &&
     -+		     strcmp(update->refname, "HEAD"))) {
     - 			/*
     - 			 * We won't be reading the referent as part of
     - 			 * the transaction, so we have to read it here
     -@@ refs/files-backend.c: static int files_transaction_finish(struct ref_store *ref_store,
     - 		struct ref_update *update = transaction->updates[i];
     - 		struct ref_lock *lock = update->backend_data;
     +-test_expect_success 'core.logAllRefUpdates=always creates no reflog for ORIG_HEAD' '
     ++test_expect_success 'core.logAllRefUpdates=always creates reflog for ORIG_HEAD' '
     + 	test_config core.logAllRefUpdates always &&
     + 	git update-ref ORIG_HEAD $A &&
     +-	test_must_fail git reflog exists ORIG_HEAD
     ++	git reflog exists ORIG_HEAD
     + '
       
     --		if (update->flags & REF_NEEDS_COMMIT ||
     --		    update->flags & REF_LOG_ONLY) {
     -+		if ((ref_type(lock->ref_name) != REF_TYPE_PSEUDOREF ||
     -+		     !strcmp(lock->ref_name, "HEAD")) &&
     -+		    (update->flags & REF_NEEDS_COMMIT ||
     -+		     update->flags & REF_LOG_ONLY)) {
     - 			if (files_log_ref_write(refs,
     - 						lock->ref_name,
     - 						&lock->old_oid,
     -
     - ## t/t1400-update-ref.sh ##
     + test_expect_success '--no-create-reflog overrides core.logAllRefUpdates=always' '
      @@ t/t1400-update-ref.sh: test_expect_success 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER
       test_expect_success 'given old value for missing pseudoref, do not create' '
       	test_must_fail git update-ref PSEUDOREF $A $B 2>err &&
     - 	test_path_is_missing .git/PSEUDOREF &&
     + 	test_must_fail git rev-parse PSEUDOREF &&
      -	test_i18ngrep "could not read ref" err
      +	test_i18ngrep "unable to resolve reference" err
       '
     @@ t/t1400-update-ref.sh: test_expect_success 'git cat-file blob master@{2005-05-26
      @@ t/t1400-update-ref.sh: test_expect_success 'overwrite pseudoref with correct old value' '
       test_expect_success 'do not overwrite pseudoref with wrong old value' '
       	test_must_fail git update-ref PSEUDOREF $D $E 2>err &&
     - 	test $C = $(cat .git/PSEUDOREF) &&
     + 	test $C = $(git rev-parse PSEUDOREF) &&
      -	test_i18ngrep "unexpected object ID" err
      +	test_i18ngrep "cannot lock ref.*expected" err
       '
     @@ t/t1400-update-ref.sh: test_expect_success 'overwrite pseudoref with correct old
      @@ t/t1400-update-ref.sh: test_expect_success 'do not delete pseudoref with wrong old value' '
       	git update-ref PSEUDOREF $A &&
       	test_must_fail git update-ref -d PSEUDOREF $B 2>err &&
     - 	test $A = $(cat .git/PSEUDOREF) &&
     + 	test $A = $(git rev-parse PSEUDOREF) &&
      -	test_i18ngrep "unexpected object ID" err
      +	test_i18ngrep "cannot lock ref.*expected" err
       '
       
       test_expect_success 'delete pseudoref with correct old value' '
     +
     + ## t/t1405-main-ref-store.sh ##
     +@@ t/t1405-main-ref-store.sh: test_expect_success 'create_symref(FOO, refs/heads/master)' '
     + test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' '
     + 	git rev-parse FOO -- &&
     + 	git rev-parse refs/tags/new-tag -- &&
     ++	m=$(git rev-parse master) &&
     + 	$RUN delete-refs 0 nothing FOO refs/tags/new-tag &&
     + 	test_must_fail git rev-parse FOO -- &&
     +-	test_must_fail git rev-parse refs/tags/new-tag --
     ++	test_must_fail git rev-parse refs/tags/new-tag --&&
     ++	test_must_fail git rev-parse master -- &&
     ++	git update-ref refs/heads/master $m
     + '
     + 
     + test_expect_success 'rename_refs(master, new-master)' '
 2:  470821dc6d = 3:  1c2b9d5f17 Make HEAD a PSEUDOREF rather than PER_WORKTREE.

-- 
gitgitgadget

  parent reply	other threads:[~2020-07-09 21:11 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 17:29 [PATCH 0/2] " Han-Wen Nienhuys via GitGitGadget
2020-07-06 17:29 ` [PATCH 1/2] Modify pseudo refs through ref backend storage Han-Wen Nienhuys via GitGitGadget
2020-07-06 20:26   ` Junio C Hamano
2020-07-07 13:56     ` Han-Wen Nienhuys
2020-07-07 15:20       ` Junio C Hamano
2020-07-07 17:15         ` Han-Wen Nienhuys
2020-07-07 18:14           ` Junio C Hamano
2020-07-06 17:29 ` [PATCH 2/2] Make HEAD a PSEUDOREF rather than PER_WORKTREE Han-Wen Nienhuys via GitGitGadget
2020-07-06 20:30   ` Junio C Hamano
2020-07-07  9:24     ` Han-Wen Nienhuys
2020-07-09 21:11 ` Han-Wen Nienhuys via GitGitGadget [this message]
2020-07-09 21:11   ` [PATCH v2 1/3] t1400: use git rev-parse for testing PSEUDOREF existence Han-Wen Nienhuys via GitGitGadget
2020-07-09 21:11   ` [PATCH v2 2/3] Modify pseudo refs through ref backend storage Han-Wen Nienhuys via GitGitGadget
2020-07-09 21:11   ` [PATCH v2 3/3] Make HEAD a PSEUDOREF rather than PER_WORKTREE Han-Wen Nienhuys via GitGitGadget
2020-07-10 19:25   ` [PATCH v2 0/3] Remove special casing for PSEUDOREF updates Junio C Hamano
2020-07-16 18:45   ` [PATCH v3 " Han-Wen Nienhuys via GitGitGadget
2020-07-16 18:45     ` [PATCH v3 1/3] t1400: use git rev-parse for testing PSEUDOREF existence Han-Wen Nienhuys via GitGitGadget
2020-07-16 18:45     ` [PATCH v3 2/3] Modify pseudo refs through ref backend storage Han-Wen Nienhuys via GitGitGadget
2020-07-17  8:52       ` Johannes Schindelin
2020-07-27 15:41         ` Han-Wen Nienhuys
2020-07-16 18:45     ` [PATCH v3 3/3] Make HEAD a PSEUDOREF rather than PER_WORKTREE Han-Wen Nienhuys via GitGitGadget
2020-07-16 22:09     ` [PATCH v3 0/3] Remove special casing for PSEUDOREF updates Junio C Hamano
2020-07-27  8:50       ` Han-Wen Nienhuys
2020-07-27 16:20         ` Junio C Hamano
2020-08-03 19:07           ` Han-Wen Nienhuys
2020-08-03 20:07             ` Junio C Hamano
2020-08-05  1:45               ` Junio C Hamano
2020-08-05 10:48                 ` Han-Wen Nienhuys
2020-08-05 15:54                   ` Junio C Hamano
2020-08-10 14:27                     ` Han-Wen Nienhuys
2020-08-10 16:04                       ` Junio C Hamano
2020-08-11 10:49                         ` Han-Wen Nienhuys
2020-08-11 18:38                           ` Junio C Hamano
2020-08-19 13:19                     ` Han-Wen Nienhuys
2020-08-19 15:52                       ` Junio C Hamano
2020-07-27 16:25     ` [PATCH v4 " Han-Wen Nienhuys via GitGitGadget
2020-07-27 16:25       ` [PATCH v4 1/3] t1400: use git rev-parse for testing PSEUDOREF existence Han-Wen Nienhuys via GitGitGadget
2020-07-27 16:25       ` [PATCH v4 2/3] Modify pseudo refs through ref backend storage Han-Wen Nienhuys via GitGitGadget
2020-07-27 16:25       ` [PATCH v4 3/3] Make HEAD a PSEUDOREF rather than PER_WORKTREE Han-Wen Nienhuys via GitGitGadget

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=pull.673.v2.git.1594329108.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=hanwenn@gmail.com \
    --subject='Re: [PATCH v2 0/3] Remove special casing for PSEUDOREF updates' \
    /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

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git