Thread (18 messages) flat view 18 messages, 5 authors, 2021-01-12

Re: [PATCH v2 2/2] refs: allow @{n} to work with n-sized reflog

From: SZEDER Gábor <hidden>
Date: 2021-01-06 10:00:48

On Wed, Jan 06, 2021 at 01:01:54AM -0800, Denton Liu wrote:
quoted hunk ↗ jump to hunk
diff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh
index 4a9964e9dc..15aac6e77a 100755
--- a/t/t1508-at-combinations.sh
+++ b/t/t1508-at-combinations.sh
@@ -99,4 +99,20 @@ test_expect_success 'create path with @' '
 check "@:normal" blob content
 check "@:fun@ny" blob content
 
+test_expect_success '@{1} works with only one reflog entry' '
+	git checkout -B newbranch master &&
+	git reflog expire --expire=now refs/heads/newbranch &&
+	git commit --allow-empty -m "first after expiration" &&
+	git rev-parse newbranch~ >expect &&
+	git rev-parse newbranch@{1} >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success '@{0} works with empty reflog' '
+	git checkout -B newbranch master &&
+	git reflog expire --expire=now refs/heads/newbranch &&
+	git rev-parse newbranch >expect &&
+	git rev-parse newbranch@{0} >actual &&
+	test_cmp expect actual
You could use 'test_cmp_rev' in these two tests to spare a few lines
and to get a bit friendlier error message on failure.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help