git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/4] t1506: rev-parse A..B and A...B

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 25, 2020, 05:59 UTC
Message-ID
<20200925055954.1111389-4-gitster@pobox.com>
In-Reply-To
<20200925055954.1111389-1-gitster@pobox.com>

Because these constructs can be used to parse user input to be passed to rev-list --objects, e.g.

	range=$(git rev-parse v1.0..v2.0) &&
	git rev-list --objects $range | git pack-objects --stdin

the endpoints (v1.0 and v2.0 in the example) are shown without peeling them to underlying commits, even when they are annotated tags. Make sure it stays that way.

While at it, ensure "rev-parse A...B" also keeps the endpoints A and B unpeeled, even though the negative side (i.e. the merge-base between A and B) has to become a commit.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t1506-rev-parse-diagnosis.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index dbf690b9c1..3e657e693b 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -190,6 +190,24 @@ test_expect_success 'dotdot is not an empty set' '
 	test_cmp expect actual
 '
 
+test_expect_success 'dotdot does not peel endpoints' '
+	git tag -a -m "annote" annotated HEAD &&
+	A=$(git rev-parse annotated) &&
+	H=$(git rev-parse annotated^0) &&
+	{
+		echo $A && echo ^$A
+	} >expect-with-two-dots &&
+	{
+		echo $A && echo $A && echo ^$H
+	} >expect-with-merge-base &&
+
+	git rev-parse annotated..annotated >actual-with-two-dots &&
+	test_cmp expect-with-two-dots actual-with-two-dots &&
+
+	git rev-parse annotated...annotated >actual-with-merge-base &&
+	test_cmp expect-with-merge-base actual-with-merge-base
+'
+
 test_expect_success 'arg before dashdash must be a revision (missing)' '
 	test_must_fail git rev-parse foobar -- 2>stderr &&
 	test_i18ngrep "bad revision" stderr
-- 
2.28.0-718-gd8d5e3da39
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 13 in “Clean-up around get_x_ish()”
  1. 0/4 Clean-up around get_x_ish()Junio C Hamano, Sep 25, 2020
  2. 4/4 sequencer: stop abbreviating stopped-sha fileJunio C Hamano, Sep 25, 2020
  3. 3/4 t1506: rev-parse A..B and A...BJunio C Hamano, Sep 25, 2020
  4. 2/4 blame: validate and peel the object names on the ignore listJunio C Hamano, Sep 25, 2020
  5. René ScharfeSep 26, 2020
  6. Junio C HamanoSep 26, 2020
  7. Junio C HamanoSep 26, 2020
  8. Barret RhodenSep 28, 2020
  9. René ScharfeOct 11, 2020
  10. Junio C HamanoOct 12, 2020
  11. Barret RhodenOct 12, 2020
  12. René ScharfeOct 13, 2020
  13. 1/4 t8013: minimum preparatory clean-upJunio C Hamano, Sep 25, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.