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

[PATCH 1/2] test for '!' handling in rev-parse's named commits

From
Will Palmer <wmpalmer@gmail.com>
Date
Jun 3, 2015, 20:54 UTC
Message-ID
<1433364854-30088-2-git-send-email-wmpalmer@gmail.com>
In-Reply-To
<1433364854-30088-1-git-send-email-wmpalmer@gmail.com>

In anticipation of modifying this behaviour, add a test verifying the handling of exclamation marks when looking up a commit "by name".

Specifically, as documented: '^{/!Message}' should fail, as this syntax is currently reserved; while '^{!!Message}' should search for a commit whose message contains the string "!Message".

Signed-off-by: Will Palmer <wmpalmer@gmail.com>
---
 t/t1511-rev-parse-caret.sh | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh
index 15973f2..0c46e5c 100755
--- a/t/t1511-rev-parse-caret.sh
+++ b/t/t1511-rev-parse-caret.sh
@@ -18,7 +18,14 @@ test_expect_success 'setup' '
 	git checkout master &&
 	echo modified >>a-blob &&
 	git add -u &&
-	git commit -m Modified
+	git commit -m Modified &&
+	echo changed! >>a-blob &&
+	git add -u &&
+	git commit -m !Exp &&
+	git branch expref &&
+	echo changed >>a-blob &&
+	git add -u &&
+	git commit -m Changed
 '
 
 test_expect_success 'ref^{non-existent}' '
@@ -77,4 +84,14 @@ test_expect_success 'ref^{/Initial}' '
 	test_cmp expected actual
 '
 
+test_expect_success 'ref^{/!Exp}' '
+	test_must_fail git rev-parse master^{/!Exp}
+'
+
+test_expect_success 'ref^{/!!Exp}' '
+	git rev-parse expref >expected &&
+	git rev-parse master^{/!!Exp} >actual &&
+	test_cmp expected actual
+'
+
 test_done
-- 
2.3.0.rc1
Previous: Will PalmerNext: Junio C Hamano
Message 2 of 7 in “specify commit by negative pattern”
  1. 0/2 specify commit by negative patternWill Palmer, Jun 3, 2015
  2. 1/2 test for '!' handling in rev-parse's named commitsWill Palmer, Jun 3, 2015
  3. Junio C HamanoJun 3, 2015
  4. Will PalmerJun 3, 2015
  5. Junio C HamanoJun 4, 2015
  6. Junio C HamanoJun 3, 2015
  7. 2/2 object name: introduce '^{/!<negative pattern>}' notationWill Palmer, Jun 3, 2015

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.