From: "Kyle J. McKay" <mackyle@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
Git mailing list <git@vger.kernel.org>
Subject: [PATCH 1/2] t/t1417: test symbolic-ref effects on ref logs
Date: Sat, 30 Jan 2021 03:19:08 -0700 [thread overview]
Message-ID: <fec7ef37962da584a89012234ae4a1a@72481c9465c8b2c4aaff8b77ab5e23c> (raw)
In-Reply-To: <7c7e8679f2da7e1475606d698b2da8c@72481c9465c8b2c4aaff8b77ab5e23c>
The git command `git symbolic-ref <refname1> <refname2>` updates
<refname1> to be a "symbolic" pointer to <refname2>. No matter
what future value <refname2> takes on, <refname1> will continue
to refer to that future value since it's "symbolic".
Since commit 523fa69c36744ae6 ("reflog: cleanse messages in the refs.c
layer", 2020-07-10, v2.29.0), the effect of using the aforementioned
"symbolic-ref" command on ref logs has changed in an unexpected way.
Add a new set of tests to exercise and demonstrate this change
in preparation for correcting it (at which point the failing tests
will be flipped from `test_expect_failure` to `test_expect_success`).
The new test file can be used unchanged to examine this behavior
in much older Git versions (likely to as far back as v2.6.0).
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
---
t/t1417-reflog-symref.sh | 91 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 91 insertions(+)
create mode 100755 t/t1417-reflog-symref.sh
diff --git a/t/t1417-reflog-symref.sh b/t/t1417-reflog-symref.sh
new file mode 100755
index 00000000..6149531f
--- /dev/null
+++ b/t/t1417-reflog-symref.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+#
+# Copyright (c) 2021 Kyle J. McKay
+#
+
+test_description='Test symbolic-ref effects on reflogs'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ test_commit 'initial' &&
+ git checkout -b unu &&
+ test_commit 'one' &&
+ git checkout -b du &&
+ test_commit 'two' &&
+ git checkout -b tri &&
+ test_commit 'three' &&
+ git checkout du &&
+ test_commit 'twofour' &&
+ git checkout -b KVAR du &&
+ test_commit 'four' &&
+ unu="$(git rev-parse --verify unu)" &&
+ du="$(git rev-parse --verify du)" &&
+ tri="$(git rev-parse --verify tri)" &&
+ kvar="$(git rev-parse --verify KVAR)" &&
+ test -n "$unu" &&
+ test -n "$du" &&
+ test -n "$tri" &&
+ test -n "$kvar" &&
+ test "$unu" != "$du" &&
+ test "$unu" != "$tri" &&
+ test "$unu" != "$kvar" &&
+ test "$du" != "$tri" &&
+ test "$du" != "$kvar" &&
+ test "$tri" != "$kvar" &&
+ git symbolic-ref refs/heads/KVAR refs/heads/du &&
+ kvarsym="$(git rev-parse --verify KVAR)" &&
+ test "$kvarsym" = "$du" &&
+ test "$kvarsym" != "$kvar" &&
+ git reflog exists HEAD &&
+ git reflog exists refs/heads/KVAR &&
+ git symbolic-ref HEAD >/dev/null &&
+ git symbolic-ref refs/heads/KVAR &&
+ git checkout unu &&
+ hcnt=$(git reflog show HEAD | wc -l) &&
+ kcnt=$(git reflog show refs/heads/KVAR | wc -l) &&
+ test -n "$hcnt" &&
+ test -n "$kcnt" &&
+ test $hcnt -gt 1 &&
+ test $kcnt -gt 1 &&
+ test $hcnt -ne $kcnt
+'
+
+test_expect_failure 'HEAD reflog symbolic-ref' '
+ hcnt1=$(git reflog show HEAD | wc -l) &&
+ git symbolic-ref HEAD refs/heads/unu &&
+ git symbolic-ref HEAD refs/heads/du &&
+ git symbolic-ref HEAD refs/heads/tri &&
+ hcnt2=$(git reflog show HEAD | wc -l) &&
+ test $hcnt1 = $hcnt2
+'
+
+test_expect_failure 'refs/heads/KVAR reflog symbolic-ref' '
+ kcnt1=$(git reflog show refs/heads/KVAR | wc -l) &&
+ git symbolic-ref refs/heads/KVAR refs/heads/tri &&
+ git symbolic-ref refs/heads/KVAR refs/heads/du &&
+ git symbolic-ref refs/heads/KVAR refs/heads/unu &&
+ kcnt2=$(git reflog show refs/heads/KVAR | wc -l) &&
+ test $kcnt1 = $kcnt2
+'
+
+test_expect_failure 'double symref reflog symbolic-ref' '
+ hcnt1=$(git reflog show HEAD | wc -l) &&
+ kcnt1=$(git reflog show refs/heads/KVAR | wc -l) &&
+ git symbolic-ref HEAD refs/heads/KVAR &&
+ git symbolic-ref refs/heads/KVAR refs/heads/du &&
+ git symbolic-ref refs/heads/KVAR refs/heads/unu &&
+ git symbolic-ref refs/heads/KVAR refs/heads/tri &&
+ git symbolic-ref HEAD refs/heads/du &&
+ git symbolic-ref HEAD refs/heads/tri &&
+ git symbolic-ref HEAD refs/heads/unu &&
+ hcnt2=$(git reflog show HEAD | wc -l) &&
+ kcnt2=$(git reflog show refs/heads/KVAR | wc -l) &&
+ test $hcnt1 = $hcnt2 &&
+ test $kcnt1 = $kcnt2 &&
+ test $hcnt2 != $kcnt2
+'
+
+test_done
--
next prev parent reply other threads:[~2021-01-30 10:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-30 10:19 [PATCH 0/2] Eliminate extraneous ref log entries Kyle J. McKay
2021-01-30 10:19 ` Kyle J. McKay [this message]
2021-01-30 18:56 ` [PATCH 1/2] t/t1417: test symbolic-ref effects on ref logs Junio C Hamano
2021-01-30 23:02 ` Kyle J. McKay
2021-01-30 23:48 ` Junio C Hamano
2021-02-01 11:09 ` Han-Wen Nienhuys
2021-01-30 23:26 ` Kyle J. McKay
2021-01-31 0:11 ` Junio C Hamano
2021-01-30 10:19 ` [PATCH 2/2] refs.c: avoid creating extra unwanted reflog entries Kyle J. McKay
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=fec7ef37962da584a89012234ae4a1a@72481c9465c8b2c4aaff8b77ab5e23c \
--to=mackyle@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).