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

Re: [PATCH 1/2] t1506: more test for @{upstream} syntax

From
Jeff King <peff@peff.net>
Date
Jan 26, 2010, 13:07 UTC
Message-ID
<20100126130745.GB28179@coredump.intra.peff.net>
In-Reply-To
<1263980322-4142-2-git-send-email-gitster@pobox.com>
On Wed, Jan 20, 2010 at 01:38:41AM -0800, Junio C Hamano wrote:
> This adds a few more tests that exercises @{upstream} syntax by commands
> that operate differently when they are given branch name as opposed to a
> refname (i.e. where "master" and "refs/heads/master" makes a difference).

Overall this looks good, but there are a few minor defects. I haven't had a chance to fix them yet, but here are tests showing them. I hope to get to them pre-1.7.0, but please feel free to take a crack at them if you want.

The first one is that @{usptream} silently becomes @{0}. I think we need to double-check whether approxidate found absolutely nothing, and complain if that is the case.

diff --git a/t/t0101-at-syntax.sh b/t/t0101-at-syntax.sh
new file mode 100755
index 0000000..da43386
--- /dev/null
+++ b/t/t0101-at-syntax.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+test_description='various @{whatever} syntax tests'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+	test_commit one &&
+	test_commit two
+'
+
+check_at() {
+	echo "$2" >expect &&
+	git log -1 --format=%s "$1" >actual &&
+	test_cmp expect actual
+}
+
+test_expect_success '@{0} shows current' '
+	check_at @{0} two
+'
+
+test_expect_success '@{1} shows old' '
+	check_at @{1} one
+'
+
+test_expect_success '@{now} shows current' '
+	check_at @{now} two
+'
+
+test_expect_success '@{30.years.ago} shows old' '
+	check_at @{30.years.ago} one
+'
+
+test_expect_success 'silly approxidates work' '
+	check_at @{3.hot.dogs.and.30.years.ago} one
+'
+
+test_expect_failure 'complain about total nonsense' '
+	test_must_fail git log -1 --format=%s @{utter.bogosity}
+'
+
+test_done

The second one is that "log -g branch@{u}" shows the correct commits
(from the upstream of "branch"), but displays the incorrect reflog
information (it shows information for "branch", not for its upstream).

diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
index 95c9b09..cbe1b25 100755
--- a/t/t1507-rev-parse-upstream.sh
+++ b/t/t1507-rev-parse-upstream.sh
@@ -107,4 +107,18 @@ test_expect_success 'checkout other@{u}' '
 	test_cmp expect actual
 '
 
+cat >expect <<EOF
+commit 8f489d01d0cc65c3b0f09504ec50b5ed02a70bd5
+Reflog: refs/heads/master@{0} (C O Mitter <committer@example.com>)
+Reflog message: branch: Created from HEAD
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:15:13 2005 -0700
+
+    3
+EOF
+test_expect_failure 'log -g other@{u}' '
+	git log -1 -g other@{u} >actual &&
+	test_cmp expect actual
+'
+
 test_done
Previous: Junio C HamanoNext: Junio C Hamano
Message 15 of 30 in “default behaviour for `gitmerge` (no arguments)”
  1. Gareth AdamsJan 11, 2010
  2. Junio C HamanoJan 11, 2010
  3. Jeff KingJan 12, 2010
  4. Junio C HamanoJan 12, 2010
  5. Jeff KingJan 12, 2010
  6. Junio C HamanoJan 13, 2010
  7. Johannes SchindelinJan 13, 2010
  8. Junio C HamanoJan 13, 2010
  9. Johannes SchindelinJan 13, 2010
  10. Junio C HamanoJan 13, 2010
  11. Johannes SchindelinJan 13, 2010
  12. Junio C HamanoJan 13, 2010
  13. 0/2 @{u} updatesJunio C Hamano, Jan 20, 2010
  14. 1/2 t1506: more test for @{upstream} syntaxJunio C Hamano, Jan 20, 2010
  15. Jeff KingJan 26, 2010
  16. Junio C HamanoJan 26, 2010
  17. Jeff KingJan 27, 2010
  18. Junio C HamanoJan 27, 2010
  19. Jeff KingJan 28, 2010
  20. Junio C HamanoJan 26, 2010
  21. Jeff KingJan 27, 2010
  22. Junio C HamanoJan 27, 2010
  23. Jeff KingJan 28, 2010
  24. 1/3 test combinations of @{} syntaxJeff King, Jan 28, 2010
  25. 2/3 fix parsing of @{-1}@{u} combinationJeff King, Jan 28, 2010
  26. 3/3 reject @{-1} not at beginning of object nameJeff King, Jan 28, 2010
  27. Junio C HamanoJan 28, 2010
  28. Jeff KingJan 29, 2010
  29. 2/2 Teach @{upstream} syntax to strbuf_branchanme()Junio C Hamano, Jan 20, 2010
  30. Johannes SchindelinJan 20, 2010

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.