From 06b6b68ff943de9e5c2f537807c054cd536731d1 Mon Sep 17 00:00:00 2001 From: Will Palmer Date: Sat, 9 Jan 2016 19:22:29 -0700 Subject: test for '!' handling in rev-parse's named commits In anticipation of extending this behaviour, add tests verifying the handling of exclamation marks when looking up a commit "by name". Specifically, as documented: '^{/!Message}' should fail, as the '!' prefix is reserved; while '^{!!Message}' should search for a commit whose message contains the string "!Message". Signed-off-by: Will Palmer Signed-off-by: Stephen P. Smith Signed-off-by: Junio C Hamano --- t/t1511-rev-parse-caret.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index 15973f2094..b2f90bea6a 100755 --- a/t/t1511-rev-parse-caret.sh +++ b/t/t1511-rev-parse-caret.sh @@ -18,7 +18,15 @@ test_expect_success 'setup' ' git checkout master && echo modified >>a-blob && git add -u && - git commit -m Modified + git commit -m Modified && + git branch modref && + 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 +85,18 @@ 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^{/!}' ' + test_must_fail git rev-parse master^{/!} +' + +test_expect_success 'ref^{/!!Exp}' ' + git rev-parse expref >expected && + git rev-parse master^{/!!Exp} >actual && + test_cmp expected actual +' + test_done -- cgit v1.2.3 From 0769854f3db2c09c8b5993ea023ea07ddc1eb6eb Mon Sep 17 00:00:00 2001 From: Will Palmer Date: Sat, 30 Jan 2016 17:06:01 -0700 Subject: object name: introduce '^{/!-}' notation To name a commit, you can now use the :/!- regex style, and consequentially, say $ git rev-parse HEAD^{/!-foo} and it will return the hash of the first commit reachable from HEAD, whose commit message does not contain "foo". This is the opposite of the existing ^{/} syntax. The specific use-case this is intended for is to perform an operation, excluding the most-recent commits containing a particular marker. For example, if you tend to make "work in progress" commits, with messages beginning with "WIP", you work, then it could be useful to diff against "the most recent commit which was not a WIP commit". That sort of thing now possible, via commands such as: $ git diff @^{/!-^WIP} The leader '/!-', rather than simply '/!', to denote a negative match, is chosen to leave room for additional modifiers in the future. Signed-off-by: Will Palmer Signed-off-by: Stephen P. Smith Signed-off-by: Junio C Hamano --- t/t1511-rev-parse-caret.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index b2f90bea6a..8a5983fcd2 100755 --- a/t/t1511-rev-parse-caret.sh +++ b/t/t1511-rev-parse-caret.sh @@ -26,7 +26,10 @@ test_expect_success 'setup' ' git branch expref && echo changed >>a-blob && git add -u && - git commit -m Changed + git commit -m Changed && + echo changed-again >>a-blob && + git add -u && + git commit -m Changed-again ' test_expect_success 'ref^{non-existent}' ' @@ -99,4 +102,30 @@ test_expect_success 'ref^{/!!Exp}' ' test_cmp expected actual ' +test_expect_success 'ref^{/!-}' ' + test_must_fail git rev-parse master^{/!-} +' + +test_expect_success 'ref^{/!-.}' ' + test_must_fail git rev-parse master^{/!-.} +' + +test_expect_success 'ref^{/!-non-existent}' ' + git rev-parse master >expected && + git rev-parse master^{/!-non-existent} >actual && + test_cmp expected actual +' + +test_expect_success 'ref^{/!-Changed}' ' + git rev-parse expref >expected && + git rev-parse master^{/!-Changed} >actual && + test_cmp expected actual +' + +test_expect_success 'ref^{/!-!Exp}' ' + git rev-parse modref >expected && + git rev-parse expref^{/!-!Exp} >actual && + test_cmp expected actual +' + test_done -- cgit v1.2.3