From: Kousik Sanagavarapu <five231003@gmail.com>
To: git@vger.kernel.org
Cc: Kousik Sanagavarapu <five231003@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
Christian Couder <christian.couder@gmail.com>,
Hariom Verma <hariom18599@gmail.com>
Subject: [PATCH v2] t4205: correctly test %(describe:abbrev=...)
Date: Thu, 29 Jun 2023 18:48:08 +0530 [thread overview]
Message-ID: <20230629133841.18784-2-five231003@gmail.com> (raw)
In-Reply-To: <20230628181753.10384-1-five231003@gmail.com>
The pretty format %(describe:abbrev=<number>) tells describe to use
at least <number> digits of the oid to generate the human-readable
format of the commit-ish.
There are three things to test here:
- Check that we can describe a commit that is not tagged (that is,
for example our HEAD is at least one commit ahead of some reachable
commit which is tagged) with at least <number> digits of the oid
being used for describing it.
- Check that when using such a commit-ish, we always use at least
<number> digits of the oid to describe it.
- Check that we can describe a tag. This just gives the name of the
tag irrespective of abbrev (abbrev doesn't make sense here).
Do this, instead of the current test which only tests the last case.
Helped-by: Junio C Hamano <gitster@pobox.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Hariom Verma <hariom18599@gmail.com>
Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
---
Changes since v1:
- Changed the log message
- Added things to be tested as commented by Junio
Range-diff vs v1:
1: 2c10de6c11 ! 1: 76c3e38033 t4205: correctly test
%(describe:abbrev=...)
@@ Metadata
## Commit message ##
t4205: correctly test %(describe:abbrev=...)
- The pretty format %(describe:abbrev=<number>) tells describe to
use only
- <number> characters of the oid to generate the human-readable
format of
- the commit-ish.
+ The pretty format %(describe:abbrev=<number>) tells describe to
use
+ at least <number> digits of the oid to generate the
human-readable
+ format of the commit-ish.
- This is not apparent in the test for %(describe:abbrev=...)
because we
- directly tag HEAD and use that, in which case the
human-readable format
- is just the tag name. So, create a new commit and use that
instead.
+ There are three things to test here:
+ - Check that we can describe a commit that is not tagged
(that is,
+ for example our HEAD is at least one commit ahead of some
reachable
+ commit which is tagged) with at least <number> digits of
the oid
+ being used for describing it.
+ - Check that when using such a commit-ish, we always use at
least
+ <number> digits of the oid to describe it.
+
+ - Check that we can describe a tag. This just gives the name
of the
+ tag irrespective of abbrev (abbrev doesn't make sense
here).
+
+ Do this, instead of the current test which only tests the last
case.
+
+ Helped-by: Junio C Hamano <gitster@pobox.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Hariom Verma <hariom18599@gmail.com>
Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
## t/t4205-log-pretty-formats.sh ##
@@ t/t4205-log-pretty-formats.sh: test_expect_success
'%(describe:tags) vs git describe --tags' '
- '
test_expect_success '%(describe:abbrev=...) vs git describe
--abbrev=...' '
-- test_when_finished "git tag -d tagname" &&
-- git tag -a -m tagged tagname &&
+ test_when_finished "git tag -d tagname" &&
++
++ # Case 1: We have commits between HEAD and the most recent tag
++ # reachable from it
+ test_commit --no-tag file &&
++ git describe --abbrev=15 >expect &&
++ git log -1 --format="%(describe:abbrev=15)" >actual &&
++ test_cmp expect actual &&
++
++ # Make sure the hash used is at least 15 digits long
++ sed -e "s/^.*-g\([0-9a-f]*\)$/\1/" <actual >hexpart &&
++ test 16 -le $(wc -c <hexpart) &&
++
++ # Case 2: We have a tag at HEAD, describe directly gives the
++ # name of the tag
+ git tag -a -m tagged tagname &&
git describe --abbrev=15 >expect &&
git log -1 --format="%(describe:abbrev=15)" >actual &&
- test_cmp expect actual
+- test_cmp expect actual
++ test_cmp expect actual &&
++ test tagname = $(cat actual)
+ '
+
+ test_expect_success 'log --pretty with space stealing' '
t/t4205-log-pretty-formats.sh | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 4cf8a77667..dd9035aa38 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1012,10 +1012,25 @@ test_expect_success '%(describe:tags) vs git describe --tags' '
test_expect_success '%(describe:abbrev=...) vs git describe --abbrev=...' '
test_when_finished "git tag -d tagname" &&
+
+ # Case 1: We have commits between HEAD and the most recent tag
+ # reachable from it
+ test_commit --no-tag file &&
+ git describe --abbrev=15 >expect &&
+ git log -1 --format="%(describe:abbrev=15)" >actual &&
+ test_cmp expect actual &&
+
+ # Make sure the hash used is at least 15 digits long
+ sed -e "s/^.*-g\([0-9a-f]*\)$/\1/" <actual >hexpart &&
+ test 16 -le $(wc -c <hexpart) &&
+
+ # Case 2: We have a tag at HEAD, describe directly gives the
+ # name of the tag
git tag -a -m tagged tagname &&
git describe --abbrev=15 >expect &&
git log -1 --format="%(describe:abbrev=15)" >actual &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ test tagname = $(cat actual)
'
test_expect_success 'log --pretty with space stealing' '
--
2.41.0.29.g8148156d44.dirty
prev parent reply other threads:[~2023-06-29 13:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 18:16 [PATCH] t4205: correctly test %(describe:abbrev=...) Kousik Sanagavarapu
2023-06-28 21:30 ` Junio C Hamano
2023-06-29 9:12 ` Kousik Sanagavarapu
2023-06-29 13:18 ` Kousik Sanagavarapu [this message]
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=20230629133841.18784-2-five231003@gmail.com \
--to=five231003@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hariom18599@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 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.