git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jiang Xin <worldhello.net@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
	Patrick Steinhardt <ps@pks.im>,
	Michael Heemskerk <mheemskerk@atlassian.com>,
	Git List <git@vger.kernel.org>
Cc: Jiang Xin <zhiyou.jx@alibaba-inc.com>,
	Jiang Xin <worldhello.net@gmail.com>
Subject: [PATCH v2 2/9] refs: update missing old-oid in transaction from lockfile
Date: Fri, 19 Aug 2022 11:21:40 +0800	[thread overview]
Message-ID: <20220819032147.28841-3-worldhello.net@gmail.com> (raw)
In-Reply-To: <CANYiYbFw71bX827akAG87RSKOozPk313Hoe573O9dQ65_U6sLQ@mail.gmail.com>

From: Jiang Xin <zhiyou.jx@alibaba-inc.com>

For commands that update a reference without providing an old-oid, the
"reference-transaction" hook will receive a zero-oid instead of the
correct old-oid.

In order to provide the "reference-transaction" hook with a real old-oid
in any case, get proper old_oid from the lock file and propagate it to
the corresponding update entry of a transaction.

The behavior of the following git commands and five testcases have been
fixed in t1416:

 * git branch [-f] <ref> <new-oid>      # update branch
 * git cherry-pick <oid>
 * git rebase
 * git tag -d <tag>
 * git update-ref --stdin               # update refs
 * git update-ref -d <ref>
 * git update-ref <ref> <new-oid>       # update ref

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
---
 refs/files-backend.c             |  28 +++-
 t/t1416-ref-transaction-hooks.sh | 231 ++++++-------------------------
 2 files changed, 65 insertions(+), 194 deletions(-)

diff --git a/refs/files-backend.c b/refs/files-backend.c
index 8db7882aac..7c1c25a25c 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -2523,15 +2523,24 @@ static int lock_ref_for_update(struct files_ref_store *refs,
 	update->backend_data = lock;
 
 	if (update->type & REF_ISSYMREF) {
+		const char *ref;
+
+		/*
+		 * Read the referent even though we won't use it as part
+		 * of the transaction, because we want to set a proper
+		 * old_oid for this symref using the oid we got.
+		 */
+		ref = refs_resolve_ref_unsafe(&refs->base,
+					      referent.buf, 0,
+					      &lock->old_oid, NULL);
+
 		if (update->flags & REF_NO_DEREF) {
 			/*
 			 * We won't be reading the referent as part of
-			 * the transaction, so we have to read it here
-			 * to record and possibly check old_oid:
+			 * the transaction, so we may need to check
+			 * old_oid here:
 			 */
-			if (!refs_resolve_ref_unsafe(&refs->base,
-						     referent.buf, 0,
-						     &lock->old_oid, NULL)) {
+			if (!ref) {
 				if (update->flags & REF_HAVE_OLD) {
 					strbuf_addf(err, "cannot lock ref '%s': "
 						    "error reading reference",
@@ -2578,6 +2587,15 @@ static int lock_ref_for_update(struct files_ref_store *refs,
 		}
 	}
 
+	/*
+	 * Propagate old_oid from the lock to the update entry, so we can
+	 * provide a proper old-oid of to the "reference-transaction" hook.
+	 */
+	if (!(update->flags & REF_HAVE_OLD) && !is_null_oid(&lock->old_oid)) {
+		oidcpy(&update->old_oid, &lock->old_oid);
+		update->flags |= REF_HAVE_OLD;
+	}
+
 	if ((update->flags & REF_HAVE_NEW) &&
 	    !(update->flags & REF_DELETING) &&
 	    !(update->flags & REF_LOG_ONLY)) {
diff --git a/t/t1416-ref-transaction-hooks.sh b/t/t1416-ref-transaction-hooks.sh
index 84509cb6a4..1ae601a73d 100755
--- a/t/t1416-ref-transaction-hooks.sh
+++ b/t/t1416-ref-transaction-hooks.sh
@@ -52,8 +52,8 @@ test_expect_success 'hook gets all queued updates in prepared state' '
 		fi
 	EOF
 	cat >expect <<-EOF &&
-		$ZERO_OID $POST_OID HEAD
-		$ZERO_OID $POST_OID refs/heads/main
+		$PRE_OID $POST_OID HEAD
+		$PRE_OID $POST_OID refs/heads/main
 	EOF
 	git update-ref HEAD POST <<-EOF &&
 		update HEAD $ZERO_OID $POST_OID
@@ -75,8 +75,8 @@ test_expect_success 'hook gets all queued updates in committed state' '
 		fi
 	EOF
 	cat >expect <<-EOF &&
-		$ZERO_OID $POST_OID HEAD
-		$ZERO_OID $POST_OID refs/heads/main
+		$PRE_OID $POST_OID HEAD
+		$PRE_OID $POST_OID refs/heads/main
 	EOF
 	git update-ref HEAD POST &&
 	test_cmp expect actual
@@ -320,26 +320,7 @@ test_expect_success "update-ref: create new refs" '
 	test_cmp_heads_and_tags -C workdir expect
 '
 
-# Failed because the old-oids for the default branch and
-# HEAD which points to the default branch were not the
-# expected old-oids, but <ZERO-OID>.
-#
-# The differences are as follows:
-#
-#     @@ -5,8 +5,8 @@
-#      <COMMIT-A> <COMMIT-B> refs/heads/topic1
-#      <COMMIT-A> <COMMIT-B> HEAD
-#      ## Call hook: reference-transaction  prepared ##
-#     -<COMMIT-B> <COMMIT-A> refs/heads/topic1
-#     -<COMMIT-B> <COMMIT-A> HEAD
-#     +<ZERO-OID> <COMMIT-A> refs/heads/topic1
-#     +<ZERO-OID> <COMMIT-A> HEAD
-#      ## Call hook: reference-transaction committed ##
-#     -<COMMIT-B> <COMMIT-A> refs/heads/topic1
-#     -<COMMIT-B> <COMMIT-A> HEAD
-#     +<ZERO-OID> <COMMIT-A> refs/heads/topic1
-#     +<ZERO-OID> <COMMIT-A> HEAD
-test_expect_failure "update-ref: update default branch" '
+test_expect_success "update-ref: update default branch" '
 	test_when_finished "git switch main; rm -f $HOOK_OUTPUT" &&
 
 	cat >expect <<-\EOF &&
@@ -375,25 +356,7 @@ test_expect_failure "update-ref: update default branch" '
 	test_cmp_heads_and_tags -C workdir expect
 '
 
-# Failed because the old-oids for HEAD and the ref that the HEAD points
-# to were not the expected old-oids, but <ZERO-OID>.
-#
-# The differences are as follows:
-#
-#     @@ -5,8 +5,8 @@
-#      <COMMIT-A> <COMMIT-B> HEAD
-#      <COMMIT-A> <COMMIT-B> refs/heads/topic1
-#      ## Call hook: reference-transaction  prepared ##
-#     -<COMMIT-B> <COMMIT-A> HEAD
-#     -<COMMIT-B> <COMMIT-A> refs/heads/topic1
-#     +<ZERO-OID> <COMMIT-A> HEAD
-#     +<ZERO-OID> <COMMIT-A> refs/heads/topic1
-#      ## Call hook: reference-transaction committed ##
-#     -<COMMIT-B> <COMMIT-A> HEAD
-#     -<COMMIT-B> <COMMIT-A> refs/heads/topic1
-#     +<ZERO-OID> <COMMIT-A> HEAD
-#     +<ZERO-OID> <COMMIT-A> refs/heads/topic1
-test_expect_failure "update-ref: update HEAD" '
+test_expect_success "update-ref: update HEAD" '
 	test_when_finished "git switch main; rm -f $HOOK_OUTPUT" &&
 
 	cat >expect <<-\EOF &&
@@ -438,32 +401,7 @@ test_expect_failure "update-ref: prepare packed_ref_store using pack-refs" '
 	test_path_is_missing $HOOK_OUTPUT
 '
 
-# Failed because the old-oid was not the expected old-oid, but
-# <ZERO-OID> for updating a reference using git-update-refs
-# command without providing the old-oid parameter.
-#
-# The differences are as follows:
-#
-#     @@ -3,14 +3,14 @@
-#      ## Call hook: reference-transaction committed ##
-#      <COMMIT-A> <COMMIT-B> refs/heads/topic2
-#      ## Call hook: reference-transaction  prepared ##
-#     -<COMMIT-A> <COMMIT-C> refs/heads/topic3
-#     +<ZERO-OID> <COMMIT-C> refs/heads/topic3
-#      ## Call hook: reference-transaction committed ##
-#     -<COMMIT-A> <COMMIT-C> refs/heads/topic3
-#     +<ZERO-OID> <COMMIT-C> refs/heads/topic3
-#      ## Call hook: reference-transaction  prepared ##
-#      <ZERO-OID> <COMMIT-A> refs/heads/topic4
-#      ## Call hook: reference-transaction committed ##
-#      <ZERO-OID> <COMMIT-A> refs/heads/topic4
-#      ## Call hook: reference-transaction  prepared ##
-#     -<COMMIT-A> <COMMIT-C> refs/heads/topic4
-#     +<ZERO-OID> <COMMIT-C> refs/heads/topic4
-#      ## Call hook: reference-transaction committed ##
-#     -<COMMIT-A> <COMMIT-C> refs/heads/topic4
-#     +<ZERO-OID> <COMMIT-C> refs/heads/topic4
-test_expect_failure "update-ref: update refs already in packed_ref_store" '
+test_expect_success "update-ref: update refs already in packed_ref_store" '
 	test_when_finished "rm -f $HOOK_OUTPUT" &&
 
 	cat >expect <<-\EOF &&
@@ -510,9 +448,6 @@ test_expect_failure "update-ref: update refs already in packed_ref_store" '
 #  * The "reference-transaction committed" command was executed twice,
 #    once for packed ref-store, and once for loose ref-store.
 #
-#  * The old-oid was not the expected old-oid, but <ZERO-OID> when
-#    deleting a reference without providing the old-oid parameter.
-#
 #  * Unexpected execution of the "reference-transaction abort" command.
 #
 # The differences are as follows:
@@ -526,7 +461,7 @@ test_expect_failure "update-ref: update refs already in packed_ref_store" '
 #      <COMMIT-A> <ZERO-OID> refs/heads/topic1
 #      <COMMIT-A> <ZERO-OID> HEAD
 #      ## Call hook: reference-transaction  prepared ##
-#     @@ -11,14 +13,20 @@
+#     @@ -11,13 +13,19 @@
 #      ## Call hook: reference-transaction  prepared ##
 #      <COMMIT-B> <ZERO-OID> refs/heads/topic2
 #      ## Call hook: reference-transaction committed ##
@@ -536,21 +471,16 @@ test_expect_failure "update-ref: update refs already in packed_ref_store" '
 #      ## Call hook: reference-transaction  prepared ##
 #      <ZERO-OID> <ZERO-OID> refs/heads/topic3
 #      ## Call hook: reference-transaction  prepared ##
-#     -<COMMIT-C> <ZERO-OID> refs/heads/topic3
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic3
+#      <COMMIT-C> <ZERO-OID> refs/heads/topic3
 #      ## Call hook: reference-transaction committed ##
-#     -<COMMIT-C> <ZERO-OID> refs/heads/topic3
 #     +<ZERO-OID> <ZERO-OID> refs/heads/topic3
 #     +## Call hook: reference-transaction committed ##
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic3
+#      <COMMIT-C> <ZERO-OID> refs/heads/topic3
 #     +## Call hook: reference-transaction   aborted ##
 #     +<ZERO-OID> <ZERO-OID> refs/heads/topic4
 #      ## Call hook: reference-transaction  prepared ##
-#     -<COMMIT-C> <ZERO-OID> refs/heads/topic4
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic4
+#      <COMMIT-C> <ZERO-OID> refs/heads/topic4
 #      ## Call hook: reference-transaction committed ##
-#     -<COMMIT-C> <ZERO-OID> refs/heads/topic4
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic4
 test_expect_failure "update-ref: remove refs with mixed ref_stores" '
 	test_when_finished "rm -f $HOOK_OUTPUT" &&
 
@@ -638,24 +568,7 @@ test_expect_success "update-ref --stdin: prepare packed_ref_store using pack-ref
 	git -C workdir pack-refs --all
 '
 
-# Failed because the old-oid was not the expected old-oid, but
-# <ZERO-OID> when running "git update-ref --stdin" to update a
-# reference without providing an old-oid.
-#
-# The differences are as follows:
-#
-#     @@ -1,8 +1,8 @@
-#      ## Call hook: reference-transaction  prepared ##
-#      <COMMIT-A> <COMMIT-B> refs/heads/topic2
-#     -<COMMIT-A> <COMMIT-C> refs/heads/topic3
-#     +<ZERO-OID> <COMMIT-C> refs/heads/topic3
-#      <ZERO-OID> <COMMIT-C> refs/heads/topic4
-#      ## Call hook: reference-transaction committed ##
-#      <COMMIT-A> <COMMIT-B> refs/heads/topic2
-#     -<COMMIT-A> <COMMIT-C> refs/heads/topic3
-#     +<ZERO-OID> <COMMIT-C> refs/heads/topic3
-#      <ZERO-OID> <COMMIT-C> refs/heads/topic4
-test_expect_failure "update-ref --stdin: update refs" '
+test_expect_success "update-ref --stdin: update refs" '
 	test_when_finished "rm -f $HOOK_OUTPUT" &&
 
 	cat >expect <<-\EOF &&
@@ -699,39 +612,20 @@ test_expect_failure "update-ref --stdin: update refs" '
 #  * The "reference-transaction committed" command was executed twice,
 #    once for packed ref-store, and once for loose ref-store.
 #
-#  * The old-oid was not the expected old-oid, but <ZERO-OID> when
-#    deleting a ref without providing the old-oid parameter.
-#
 # The differences are as follows:
 #
-#     @@ -4,14 +4,19 @@
-#      <ZERO-OID> <ZERO-OID> refs/heads/topic3
-#      <ZERO-OID> <ZERO-OID> refs/heads/topic4
-#      ## Call hook: reference-transaction  prepared ##
-#     -<COMMIT-A> <ZERO-OID> refs/heads/topic1
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic1
-#      <COMMIT-B> <ZERO-OID> refs/heads/topic2
-#     -<COMMIT-C> <ZERO-OID> refs/heads/topic3
-#     -<COMMIT-C> <ZERO-OID> refs/heads/topic4
-#     -<COMMIT-A> <ZERO-OID> HEAD
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic3
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic4
-#     +<ZERO-OID> <ZERO-OID> HEAD
+#     @@ -10,6 +10,11 @@
+#      <COMMIT-C> <ZERO-OID> refs/heads/topic4
+#      <COMMIT-A> <ZERO-OID> HEAD
 #      ## Call hook: reference-transaction committed ##
-#     -<COMMIT-A> <ZERO-OID> refs/heads/topic1
 #     +<ZERO-OID> <ZERO-OID> refs/heads/topic1
 #     +<ZERO-OID> <ZERO-OID> refs/heads/topic2
 #     +<ZERO-OID> <ZERO-OID> refs/heads/topic3
 #     +<ZERO-OID> <ZERO-OID> refs/heads/topic4
 #     +## Call hook: reference-transaction committed ##
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic1
+#      <COMMIT-A> <ZERO-OID> refs/heads/topic1
 #      <COMMIT-B> <ZERO-OID> refs/heads/topic2
-#     -<COMMIT-C> <ZERO-OID> refs/heads/topic3
-#     -<COMMIT-C> <ZERO-OID> refs/heads/topic4
-#     -<COMMIT-A> <ZERO-OID> HEAD
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic3
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic4
-#     +<ZERO-OID> <ZERO-OID> HEAD
+#      <COMMIT-C> <ZERO-OID> refs/heads/topic3
 test_expect_failure "update-ref --stdin: delete refs" '
 	test_when_finished "rm -f $HOOK_OUTPUT" &&
 
@@ -852,23 +746,7 @@ test_expect_failure "branch: prepare packed_ref_store using gc" '
 	test_path_is_missing $HOOK_OUTPUT
 '
 
-# Failed because the old-oid was not the expected old-oid, but
-# <ZERO-OID> when running git-branch to update a branch without
-# providing an old-oid.
-#
-# The differences are as follows:
-#
-#     @@ -1,7 +1,7 @@
-#      ## Call hook: reference-transaction  prepared ##
-#     -<COMMIT-A> <COMMIT-B> refs/heads/topic2
-#     +<ZERO-OID> <COMMIT-B> refs/heads/topic2
-#      ## Call hook: reference-transaction committed ##
-#     -<COMMIT-A> <COMMIT-B> refs/heads/topic2
-#     +<ZERO-OID> <COMMIT-B> refs/heads/topic2
-#      ## Call hook: reference-transaction  prepared ##
-#      <ZERO-OID> <COMMIT-C> refs/heads/topic3
-#      ## Call hook: reference-transaction committed ##
-test_expect_failure "branch: update branch without old-oid" '
+test_expect_success "branch: update branch without old-oid" '
 	test_when_finished "rm -f $HOOK_OUTPUT" &&
 
 	cat >expect <<-\EOF &&
@@ -1007,9 +885,6 @@ test_expect_failure "branch: rename branches" '
 
 # Mismatched hook output for "git branch -d":
 #
-#  * The old-oid was not the expected old-oid, but <ZERO-OID> when
-#    deleting a branch without providing the old-oid parameter.
-#
 #  * The delete branches operation should be treated as one transaction,
 #    but was splitted into several transactions on loose references,
 #    and the "reference-transaction committed" command was executed
@@ -1029,28 +904,25 @@ test_expect_failure "branch: rename branches" '
 #     +<ZERO-OID> <ZERO-OID> refs/heads/topic3
 #     +## Call hook: reference-transaction   aborted ##
 #     +<ZERO-OID> <ZERO-OID> refs/heads/topic1
+#     +## Call hook: reference-transaction  prepared ##
+#     +<ZERO-OID> <ZERO-OID> refs/heads/topic1
+#     +## Call hook: reference-transaction committed ##
+#     +<ZERO-OID> <ZERO-OID> refs/heads/topic1
+#     +## Call hook: reference-transaction   aborted ##
+#     +<ZERO-OID> <ZERO-OID> refs/heads/topic2
 #      ## Call hook: reference-transaction  prepared ##
 #     -<COMMIT-A> <ZERO-OID> refs/heads/topic1
-#     -<COMMIT-B> <ZERO-OID> refs/heads/topic2
+#      <COMMIT-B> <ZERO-OID> refs/heads/topic2
 #     -<COMMIT-C> <ZERO-OID> refs/heads/topic3
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic1
 #      ## Call hook: reference-transaction committed ##
 #     -<COMMIT-A> <ZERO-OID> refs/heads/topic1
-#     -<COMMIT-B> <ZERO-OID> refs/heads/topic2
-#     -<COMMIT-C> <ZERO-OID> refs/heads/topic3
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic1
-#     +## Call hook: reference-transaction   aborted ##
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic2
-#     +## Call hook: reference-transaction  prepared ##
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic2
-#     +## Call hook: reference-transaction committed ##
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic2
+#      <COMMIT-B> <ZERO-OID> refs/heads/topic2
 #     +## Call hook: reference-transaction   aborted ##
 #     +<ZERO-OID> <ZERO-OID> refs/heads/topic3
 #     +## Call hook: reference-transaction  prepared ##
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic3
+#     +<COMMIT-C> <ZERO-OID> refs/heads/topic3
 #     +## Call hook: reference-transaction committed ##
-#     +<ZERO-OID> <ZERO-OID> refs/heads/topic3
+#      <COMMIT-C> <ZERO-OID> refs/heads/topic3
 test_expect_failure "branch: remove branches" '
 	test_when_finished "rm -f $HOOK_OUTPUT" &&
 
@@ -1184,9 +1056,6 @@ test_expect_success "tag: update refs to create loose refs" '
 
 # Mismatched hook output for "git tag -d":
 #
-#  * The old-oid was not the expected old-oid, but <ZERO-OID> when
-#    deleting a tag without providing the old-oid parameter.
-#
 #  * The delete tags operation should be treated as one transaction,
 #    but was splitted into several transactions on loose references,
 #    and the "reference-transaction committed" command was executed
@@ -1206,28 +1075,25 @@ test_expect_success "tag: update refs to create loose refs" '
 #     +<ZERO-OID> <ZERO-OID> refs/tags/v3
 #     +## Call hook: reference-transaction   aborted ##
 #     +<ZERO-OID> <ZERO-OID> refs/tags/v1
+#     +## Call hook: reference-transaction  prepared ##
+#     +<ZERO-OID> <ZERO-OID> refs/tags/v1
+#     +## Call hook: reference-transaction committed ##
+#     +<ZERO-OID> <ZERO-OID> refs/tags/v1
+#     +## Call hook: reference-transaction   aborted ##
+#     +<ZERO-OID> <ZERO-OID> refs/tags/v2
 #      ## Call hook: reference-transaction  prepared ##
 #     -<COMMIT-A> <ZERO-OID> refs/tags/v1
-#     -<COMMIT-B> <ZERO-OID> refs/tags/v2
+#      <COMMIT-B> <ZERO-OID> refs/tags/v2
 #     -<COMMIT-C> <ZERO-OID> refs/tags/v3
-#     +<ZERO-OID> <ZERO-OID> refs/tags/v1
 #      ## Call hook: reference-transaction committed ##
 #     -<COMMIT-A> <ZERO-OID> refs/tags/v1
-#     -<COMMIT-B> <ZERO-OID> refs/tags/v2
-#     -<COMMIT-C> <ZERO-OID> refs/tags/v3
-#     +<ZERO-OID> <ZERO-OID> refs/tags/v1
-#     +## Call hook: reference-transaction   aborted ##
-#     +<ZERO-OID> <ZERO-OID> refs/tags/v2
-#     +## Call hook: reference-transaction  prepared ##
-#     +<ZERO-OID> <ZERO-OID> refs/tags/v2
-#     +## Call hook: reference-transaction committed ##
-#     +<ZERO-OID> <ZERO-OID> refs/tags/v2
+#      <COMMIT-B> <ZERO-OID> refs/tags/v2
 #     +## Call hook: reference-transaction   aborted ##
 #     +<ZERO-OID> <ZERO-OID> refs/tags/v3
 #     +## Call hook: reference-transaction  prepared ##
-#     +<ZERO-OID> <ZERO-OID> refs/tags/v3
+#     +<COMMIT-C> <ZERO-OID> refs/tags/v3
 #     +## Call hook: reference-transaction committed ##
-#     +<ZERO-OID> <ZERO-OID> refs/tags/v3
+#      <COMMIT-C> <ZERO-OID> refs/tags/v3
 test_expect_failure "tag: remove tags with mixed ref_stores" '
 	test_when_finished "rm -f $HOOK_OUTPUT" &&
 
@@ -1374,24 +1240,19 @@ test_expect_success "worktree: topic2: merge" '
 
 # Mismatched hook output for git-cherry-pick:
 #
-#  * The old-oid was not the expected old-oid, but <ZERO-OID>.
-#
 #  * Unexpected execution of the "reference-transaction abort" command.
 #
 # The differences are as follows:
 #
-#     @@ -12,7 +12,9 @@
+#     @@ -12,6 +12,8 @@
 #      ## Call hook: reference-transaction committed ##
 #      <COMMIT-A> <COMMIT-F> HEAD
 #      <COMMIT-A> <COMMIT-F> refs/heads/topic3
 #     +## Call hook: reference-transaction   aborted ##
 #     +<ZERO-OID> <ZERO-OID> CHERRY_PICK_HEAD
 #      ## Call hook: reference-transaction  prepared ##
-#     -<COMMIT-C> <ZERO-OID> CHERRY_PICK_HEAD
-#     +<ZERO-OID> <ZERO-OID> CHERRY_PICK_HEAD
+#      <COMMIT-C> <ZERO-OID> CHERRY_PICK_HEAD
 #      ## Call hook: reference-transaction committed ##
-#     -<COMMIT-C> <ZERO-OID> CHERRY_PICK_HEAD
-#     +<ZERO-OID> <ZERO-OID> CHERRY_PICK_HEAD
 test_expect_failure "worktree: topic3: cherry-pick" '
 	test_when_finished "rm -f $HOOK_OUTPUT" &&
 
@@ -1438,8 +1299,6 @@ test_expect_failure "worktree: topic3: cherry-pick" '
 
 # Mismatched hook output for git-rebase:
 #
-#  * The old-oid was not the expected old-oid, but <ZERO-OID>.
-#
 #  * Unexpected execution of the "reference-transaction abort" command.
 #
 # The differences are as follows:
@@ -1453,20 +1312,14 @@ test_expect_failure "worktree: topic3: cherry-pick" '
 #      ## Call hook: reference-transaction  prepared ##
 #      <ZERO-OID> <ZERO-OID> REBASE_HEAD
 #      ## Call hook: reference-transaction committed ##
-#     @@ -18,10 +20,12 @@
+#     @@ -18,6 +20,8 @@
 #      <COMMIT-C> <COMMIT-H> HEAD
 #      ## Call hook: reference-transaction committed ##
 #      <COMMIT-C> <COMMIT-H> HEAD
 #     +## Call hook: reference-transaction   aborted ##
 #     +<ZERO-OID> <ZERO-OID> CHERRY_PICK_HEAD
 #      ## Call hook: reference-transaction  prepared ##
-#     -<COMMIT-G> <ZERO-OID> CHERRY_PICK_HEAD
-#     +<ZERO-OID> <ZERO-OID> CHERRY_PICK_HEAD
-#      ## Call hook: reference-transaction committed ##
-#     -<COMMIT-G> <ZERO-OID> CHERRY_PICK_HEAD
-#     +<ZERO-OID> <ZERO-OID> CHERRY_PICK_HEAD
-#      ## Call hook: reference-transaction  prepared ##
-#      <COMMIT-G> <COMMIT-H> refs/heads/topic4
+#      <COMMIT-G> <ZERO-OID> CHERRY_PICK_HEAD
 #      ## Call hook: reference-transaction committed ##
 test_expect_failure "worktree: topic4: rebase" '
 	test_when_finished "rm -f $HOOK_OUTPUT" &&
-- 
2.36.1.25.gc87d5ad63a.dirty


  parent reply	other threads:[~2022-08-19  3:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29 10:12 [PATCH 0/9] Fix issues of reference-transaction hook for various git commands Jiang Xin
2022-07-29 10:12 ` [PATCH 1/9] t1416: more testcases for reference-transaction hook Jiang Xin
2022-07-30  6:44   ` Eric Sunshine
2022-07-31  3:25     ` Jiang Xin
2022-07-29 10:12 ` [PATCH 2/9] refs: update missing old-oid in transaction from lockfile Jiang Xin
2022-07-29 10:12 ` [PATCH 3/9] refs: add new field in transaction for running transaction hook Jiang Xin
2022-07-29 10:12 ` [PATCH 4/9] refs: do not run transaction hook for git-pack-refs Jiang Xin
2022-07-29 10:12 ` [PATCH 5/9] refs: avoid duplicate running of the reference-transaction hook Jiang Xin
2022-08-02 12:18   ` Michael Heemskerk
2022-08-05  1:41     ` Jiang Xin
2022-08-19  3:21       ` [PATCH v2 0/9] Fix issues of refx-txn hook for various git commands Jiang Xin
2022-08-19  3:21       ` [PATCH v2 1/9] t1416: more testcases for reference-transaction hook Jiang Xin
2022-08-19  3:21       ` Jiang Xin [this message]
2022-08-19  3:21       ` [PATCH v2 3/9] refs: add new field in transaction for running transaction hook Jiang Xin
2022-08-19  3:21       ` [PATCH v2 4/9] refs: do not run transaction hook for git-pack-refs Jiang Xin
2022-08-19  3:21       ` [PATCH v2 5/9] refs: avoid duplicate running of the reference-transaction hook Jiang Xin
2022-08-19  3:21       ` [PATCH v2 6/9] refs: add reflog_info to hold more fields for reflog entry Jiang Xin
2022-08-19  3:21       ` [PATCH v2 7/9] refs: get error message via refs_update_ref_extended() Jiang Xin
2022-08-19  3:21       ` [PATCH v2 8/9] refs: reimplement files_copy_or_rename_ref() to run refs-txn hook Jiang Xin
2022-08-19  3:21       ` [PATCH v2 9/9] refs: reimplement refs_delete_refs() and run hook once Jiang Xin
2022-07-29 10:12 ` [PATCH 6/9] refs: add reflog_info to hold more fields for reflog entry Jiang Xin
2022-08-01 11:32   ` Jiang Xin
2022-07-29 10:12 ` [PATCH 7/9] refs: get error message via refs_update_ref_extended() Jiang Xin
2022-07-29 10:12 ` [PATCH 8/9] refs: reimplement files_copy_or_rename_ref() to run hook Jiang Xin
2022-07-29 10:12 ` [PATCH 9/9] refs: reimplement refs_delete_refs() and run hook once Jiang Xin
2022-08-02 12:42   ` Michael Heemskerk
2022-08-09 11:05     ` 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

  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=20220819032147.28841-3-worldhello.net@gmail.com \
    --to=worldhello.net@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mheemskerk@atlassian.com \
    --cc=ps@pks.im \
    --cc=zhiyou.jx@alibaba-inc.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.
Code repositories for project(s) associated with this public inbox

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

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 read-only IMAP folder(s) and NNTP newsgroup(s).