2010-12-13 11:01:15 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='tests for ref^{stuff}'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
echo blob >a-blob &&
|
2015-12-22 23:05:49 +08:00
|
|
|
git tag -a -m blob blob-tag $(git hash-object -w a-blob) &&
|
2010-12-13 11:01:15 +08:00
|
|
|
mkdir a-tree &&
|
|
|
|
echo moreblobs >a-tree/another-blob &&
|
|
|
|
git add . &&
|
2015-12-22 23:05:49 +08:00
|
|
|
TREE_SHA1=$(git write-tree) &&
|
2010-12-13 11:01:15 +08:00
|
|
|
git tag -a -m tree tree-tag "$TREE_SHA1" &&
|
|
|
|
git commit -m Initial &&
|
|
|
|
git tag -a -m commit commit-tag &&
|
|
|
|
git branch ref &&
|
|
|
|
git checkout master &&
|
|
|
|
echo modified >>a-blob &&
|
|
|
|
git add -u &&
|
2016-01-10 10:22:29 +08:00
|
|
|
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 &&
|
object name: introduce '^{/!-<negative pattern>}' notation
To name a commit, you can now use the :/!-<negative pattern> 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 <rev>^{/<pattern>} 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 <wmpalmer@gmail.com>
Signed-off-by: Stephen P. Smith <ischis2@cox.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-01-31 08:06:01 +08:00
|
|
|
git commit -m Changed &&
|
|
|
|
echo changed-again >>a-blob &&
|
|
|
|
git add -u &&
|
|
|
|
git commit -m Changed-again
|
2010-12-13 11:01:15 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ref^{non-existent}' '
|
|
|
|
test_must_fail git rev-parse ref^{non-existent}
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ref^{}' '
|
|
|
|
git rev-parse ref >expected &&
|
|
|
|
git rev-parse ref^{} >actual &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
git rev-parse commit-tag^{} >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ref^{commit}' '
|
|
|
|
git rev-parse ref >expected &&
|
|
|
|
git rev-parse ref^{commit} >actual &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
git rev-parse commit-tag^{commit} >actual &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
test_must_fail git rev-parse tree-tag^{commit} &&
|
|
|
|
test_must_fail git rev-parse blob-tag^{commit}
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ref^{tree}' '
|
|
|
|
echo $TREE_SHA1 >expected &&
|
|
|
|
git rev-parse ref^{tree} >actual &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
git rev-parse commit-tag^{tree} >actual &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
git rev-parse tree-tag^{tree} >actual &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
test_must_fail git rev-parse blob-tag^{tree}
|
|
|
|
'
|
|
|
|
|
2013-09-04 03:50:16 +08:00
|
|
|
test_expect_success 'ref^{tag}' '
|
|
|
|
test_must_fail git rev-parse HEAD^{tag} &&
|
|
|
|
git rev-parse commit-tag >expected &&
|
|
|
|
git rev-parse commit-tag^{tag} >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2010-12-13 11:01:15 +08:00
|
|
|
test_expect_success 'ref^{/.}' '
|
|
|
|
git rev-parse master >expected &&
|
|
|
|
git rev-parse master^{/.} >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ref^{/non-existent}' '
|
|
|
|
test_must_fail git rev-parse master^{/non-existent}
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'ref^{/Initial}' '
|
|
|
|
git rev-parse ref >expected &&
|
|
|
|
git rev-parse master^{/Initial} >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2016-01-10 10:22:29 +08:00
|
|
|
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
|
|
|
|
'
|
|
|
|
|
object name: introduce '^{/!-<negative pattern>}' notation
To name a commit, you can now use the :/!-<negative pattern> 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 <rev>^{/<pattern>} 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 <wmpalmer@gmail.com>
Signed-off-by: Stephen P. Smith <ischis2@cox.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-01-31 08:06:01 +08:00
|
|
|
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
|
|
|
|
'
|
|
|
|
|
2010-12-13 11:01:15 +08:00
|
|
|
test_done
|