* [PATCH v2 0/2] specify commit by negative pattern @ 2015-06-06 0:24 Will Palmer 2015-06-06 0:24 ` [PATCH v2 1/2] test for '!' handling in rev-parse's named commits Will Palmer 2015-06-06 0:24 ` [PATCH v2 2/2] object name: introduce '^{/!-<negative pattern>}' notation Will Palmer 0 siblings, 2 replies; 26+ messages in thread From: Will Palmer @ 2015-06-06 0:24 UTC (permalink / raw) To: git; +Cc: Will Palmer add support for negative pattern matching in @^{/<pattern>} style revision specifiers. So now you can find the first commit whose message doesn't match a pattern, complementing the existing positive matching. e.g.: $ git rebase -i @^{/!-^WIP} My use-case is in having a "work, work, work, rebase, push"-style workflow, which generates a lot of "WIP foo" commits. While rebasing is usually handled via "git rebase -i origin/master", occasionally I will already have several "good, but not yet ready to push" commits hanging around while I finish work on related commits. In these situations, the ability to quickly "git diff @^{/!-^WIP}" to get an overview of all changes "since the last one I was happy with", can be useful. This is the second version of the patch series. The previous attempt used the notation @^{/!WIP}, rather than @^{/!-WIP}, so the "modifier" was the '!' character. Now, '!' is taken as an indicator that the pattern is to be interpreted differently, and '-' is taken as an indicator of how it is to be interpreted differently. This follows recent discussion with "Junio C Hamano" <gitster@pobox.com> and much-less recent discussion archived at: http://thread.gmane.org/gmane.comp.version-control.git/40460/focus=40477 In summary, '!' is to be used as an "escape hatch", for further extension of the "name commit by pattern" functionality. Theorised future extensions indicated things like "what was to be searched", e.g.: @^{/!(a=author)}. With only two interpretations of the '!' leader, for now (including the '!!' literal notation), adding such a verbose form, such as '@^{/!(negative)foo}', seemed inappropriate at this time. In the event that such verbose forms are ever implemented, this new form may act as a shorthand, for a basic case. Will Palmer (2): test for '!' handling in rev-parse's named commits object name: introduce '^{/!-<negative pattern>}' notation Documentation/revisions.txt | 11 +++++----- sha1_name.c | 20 ++++++++++++----- t/t1511-rev-parse-caret.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 73 insertions(+), 11 deletions(-) -- 2.3.0.rc1 ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 1/2] test for '!' handling in rev-parse's named commits 2015-06-06 0:24 [PATCH v2 0/2] specify commit by negative pattern Will Palmer @ 2015-06-06 0:24 ` Will Palmer 2015-06-06 0:24 ` [PATCH v2 2/2] object name: introduce '^{/!-<negative pattern>}' notation Will Palmer 1 sibling, 0 replies; 26+ messages in thread From: Will Palmer @ 2015-06-06 0:24 UTC (permalink / raw) To: git; +Cc: Will Palmer In anticipation of extending this behaviour, add tests verifying the handling of exclamation marks when looking up a commit "by name". Specifically, as documented: '<rev>^{/!Message}' should fail, as the '!' prefix is reserved; while '<rev>^{!!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 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index 15973f2..e0fe102 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,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 -- 2.3.0.rc1 ^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 2/2] object name: introduce '^{/!-<negative pattern>}' notation 2015-06-06 0:24 [PATCH v2 0/2] specify commit by negative pattern Will Palmer 2015-06-06 0:24 ` [PATCH v2 1/2] test for '!' handling in rev-parse's named commits Will Palmer @ 2015-06-06 0:24 ` Will Palmer 2015-06-08 16:39 ` Junio C Hamano 1 sibling, 1 reply; 26+ messages in thread From: Will Palmer @ 2015-06-06 0:24 UTC (permalink / raw) To: git; +Cc: Will Palmer To name a commit, you can now 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> --- Documentation/revisions.txt | 11 ++++++----- sha1_name.c | 20 +++++++++++++++----- t/t1511-rev-parse-caret.sh | 32 +++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt index d85e303..0c84d4f 100644 --- a/Documentation/revisions.txt +++ b/Documentation/revisions.txt @@ -176,11 +176,12 @@ existing tag object. A colon, followed by a slash, followed by a text, names a commit whose commit message matches the specified regular expression. This name returns the youngest matching commit which is - reachable from any ref. If the commit message starts with a - '!' you have to repeat that; the special sequence ':/!', - followed by something else than '!', is reserved for now. - The regular expression can match any part of the commit message. To - match messages starting with a string, one can use e.g. ':/^foo'. + reachable from any ref. The regular expression can match any part of the + commit message. To match messages starting with a string, one can use + e.g. ':/^foo'. The special sequence ':/!' is reserved for modifiers to what + is matched. ':/!-foo' performs a negative match, while ':/!!foo' matches a + literal '!' character, followed by 'foo'. Any other sequence beginning with + ':/!' is reserved for now. '<rev>:<path>', e.g. 'HEAD:README', ':README', 'master:./README':: A suffix ':' followed by a path names the blob or tree diff --git a/sha1_name.c b/sha1_name.c index e57513e..82de2db 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -838,8 +838,12 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l * through history and returning the first commit whose message starts * the given regular expression. * - * For future extension, ':/!' is reserved. If you want to match a message - * beginning with a '!', you have to repeat the exclamation mark. + * For negative-matching, prefix the pattern-part with '!-', like: ':/!-WIP'. + * + * For a literal '!' character at the beginning of a pattern, you have to repeat + * that, like: ':/!!foo' + * + * For future extension, all other sequences beginning with ':/!' are reserved. */ /* Remember to update object flag allocation in object.h */ @@ -868,12 +872,18 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, { struct commit_list *backup = NULL, *l; int found = 0; + int negative = 0; regex_t regex; if (prefix[0] == '!') { - if (prefix[1] != '!') - die ("Invalid search pattern: %s", prefix); prefix++; + + if (prefix[0] == '-') { + prefix++; + negative = 1; + } else if (prefix[0] != '!') { + die ("Invalid search pattern: %s", prefix); + } } if (regcomp(®ex, prefix, REG_EXTENDED)) @@ -893,7 +903,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, continue; buf = get_commit_buffer(commit, NULL); p = strstr(buf, "\n\n"); - matches = p && !regexec(®ex, p + 2, 0, NULL, 0); + matches = p && (negative ^ !regexec(®ex, p + 2, 0, NULL, 0)); unuse_commit_buffer(commit, buf); if (matches) { diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index e0fe102..8a5983f 100755 --- a/t/t1511-rev-parse-caret.sh +++ b/t/t1511-rev-parse-caret.sh @@ -19,13 +19,17 @@ test_expect_success 'setup' ' echo modified >>a-blob && git add -u && 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 + git commit -m Changed && + echo changed-again >>a-blob && + git add -u && + git commit -m Changed-again ' test_expect_success 'ref^{non-existent}' ' @@ -98,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 -- 2.3.0.rc1 ^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH v2 2/2] object name: introduce '^{/!-<negative pattern>}' notation 2015-06-06 0:24 ` [PATCH v2 2/2] object name: introduce '^{/!-<negative pattern>}' notation Will Palmer @ 2015-06-08 16:39 ` Junio C Hamano 2015-06-09 18:14 ` Will Palmer 2016-01-08 6:04 ` [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation Stephen Smith 0 siblings, 2 replies; 26+ messages in thread From: Junio C Hamano @ 2015-06-08 16:39 UTC (permalink / raw) To: Will Palmer; +Cc: git Will Palmer <wmpalmer@gmail.com> writes: > - * For future extension, ':/!' is reserved. If you want to match a message > - * beginning with a '!', you have to repeat the exclamation mark. > + * For negative-matching, prefix the pattern-part with '!-', like: ':/!-WIP'. > + * > + * For a literal '!' character at the beginning of a pattern, you have to repeat > + * that, like: ':/!!foo' > + * > + * For future extension, all other sequences beginning with ':/!' are reserved. > */ Good. > diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh > index e0fe102..8a5983f 100755 > --- a/t/t1511-rev-parse-caret.sh > +++ b/t/t1511-rev-parse-caret.sh > @@ -19,13 +19,17 @@ test_expect_success 'setup' ' > echo modified >>a-blob && > git add -u && > git commit -m Modified && > + git branch modref && This probably belongs to the previous step, no? > +test_expect_success 'ref^{/!-}' ' > + test_must_fail git rev-parse master^{/!-} > +' Hmmmm, we must fail because...? We are looking for something that does not contain an empty string, which by definition does not exist. Funny, but is correct ;-). > +test_expect_success 'ref^{/!-.}' ' > + test_must_fail git rev-parse master^{/!-.} > +' Likewise. I however wonder if we catch a commit without any message (which you probably have to craft with either commit-tree or hash-object), but that falls into the "curiosity" not the "practicality" category. > +test_expect_success 'ref^{/!-non-existent}' ' > + git rev-parse master >expected && > + git rev-parse master^{/!-non-existent} >actual && > + test_cmp expected actual > +' OK. > +test_expect_success 'ref^{/!-Changed}' ' > + git rev-parse expref >expected && > + git rev-parse master^{/!-Changed} >actual && > + test_cmp expected actual > +' OK. > +test_expect_success 'ref^{/!-!Exp}' ' > + git rev-parse modref >expected && > + git rev-parse expref^{/!-!Exp} >actual && > + test_cmp expected actual > +' OK. > test_done ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 2/2] object name: introduce '^{/!-<negative pattern>}' notation 2015-06-08 16:39 ` Junio C Hamano @ 2015-06-09 18:14 ` Will Palmer 2015-10-28 17:52 ` Junio C Hamano 2016-01-08 6:04 ` [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation Stephen Smith 1 sibling, 1 reply; 26+ messages in thread From: Will Palmer @ 2015-06-09 18:14 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Mon, Jun 8, 2015 at 5:39 PM, Junio C Hamano <gitster@pobox.com> wrote: > Will Palmer <wmpalmer@gmail.com> writes: >> diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh >> index e0fe102..8a5983f 100755 >> --- a/t/t1511-rev-parse-caret.sh >> +++ b/t/t1511-rev-parse-caret.sh >> @@ -19,13 +19,17 @@ test_expect_success 'setup' ' >> echo modified >>a-blob && >> git add -u && >> git commit -m Modified && >> + git branch modref && > > This probably belongs to the previous step, no? As it isn't referenced until the "negative" tests, I didn't bother adding it in the "verify the way things are" tests. Funny that it was mentioned, as I *did* originally have it in the first commit, but I moved it to the commit in which it was first used, so that it would be easier to notice. > >> +test_expect_success 'ref^{/!-}' ' >> + test_must_fail git rev-parse master^{/!-} >> +' > > Hmmmm, we must fail because...? We are looking for something that > does not contain an empty string, which by definition does not > exist. > > Funny, but is correct ;-). This is left-over from the original patch's logic, which included a short-circuit to avoid an empty regex (as per 4322842 "get_sha1: handle special case $commit^{/}")... which I now realise perhaps should have been simply rephrased, rather than ommitted entirely. I feel like adding something like: 8<---------------------------------------------------------------------- --- a/sha1_name.c +++ b/sha1_name.c @@ -737,11 +737,15 @@ static int peel_onion(const char *name, int len, unsigned char *sha1) /* * $commit^{/}. Some regex implementation may reject. - * We don't need regex anyway. '' pattern always matches. + * We don't need regex anyway. '' pattern always matches, + * and '!' pattern never matches. */ if (sp[1] == '}') return 0; + if (sp[1] == '!' && sp[2] == '-' && sp[3] == '}') + return -1; + prefix = xstrndup(sp + 1, name + len - 1 - (sp + 1)); commit_list_insert((struct commit *)o, &list); ret = get_sha1_oneline(prefix, sha1, list); ---------------------------------------------------------------------->8 ...would be the wrong place for this short-circuit check, in light of discussion around extensibility; so, I'll see how it looks moving that into get_sha1_oneline(...) > > >> +test_expect_success 'ref^{/!-.}' ' >> + test_must_fail git rev-parse master^{/!-.} >> +' > > Likewise. I however wonder if we catch a commit without any message > (which you probably have to craft with either commit-tree or > hash-object), but that falls into the "curiosity" not the > "practicality" category. A commit with "no message" should indeed by returned by 'master^{/!-.}', or at least, that is the intent. This test is only meant to cover the result of there being "no matching commit", however. In summary: it looks like I'll be sending another one. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 2/2] object name: introduce '^{/!-<negative pattern>}' notation 2015-06-09 18:14 ` Will Palmer @ 2015-10-28 17:52 ` Junio C Hamano 0 siblings, 0 replies; 26+ messages in thread From: Junio C Hamano @ 2015-10-28 17:52 UTC (permalink / raw) To: Will Palmer; +Cc: git Will Palmer <wmpalmer@gmail.com> writes: > In summary: it looks like I'll be sending another one. Has anything happened to this topic since then? I am asking primarily because I want to decide if I should discard wp/sha1-name-negative-match topic from my tree [*1*]. I think what it attempts to do is a worthy thing, and it is shame to see the initial implementation and review cycles we have spent so far go to waste. [Footnote] *1* Not that my dropping a topic from 'pu' means very much; a dropped topic can still be submitted and requeued after all. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation 2015-06-08 16:39 ` Junio C Hamano 2015-06-09 18:14 ` Will Palmer @ 2016-01-08 6:04 ` Stephen Smith 2016-01-08 18:21 ` Junio C Hamano ` (2 more replies) 1 sibling, 3 replies; 26+ messages in thread From: Stephen Smith @ 2016-01-08 6:04 UTC (permalink / raw) To: git Junio C Hamano <gitster <at> pobox.com> writes: > > echo modified >>a-blob && > > git add -u && > > git commit -m Modified && > > + git branch modref && > > This probably belongs to the previous step, no? > What did you mean by this comment? I looked at the original patch and at Will's response to your comment and am not quite sure what was meant. > > +test_expect_success 'ref^{/!-}' ' > > + test_must_fail git rev-parse master^{/!-} > > +' > I plan on leaving this in. > > +test_expect_success 'ref^{/!-.}' ' > > + test_must_fail git rev-parse master^{/!-.} > > +' > I plan on leaving this in. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation 2016-01-08 6:04 ` [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation Stephen Smith @ 2016-01-08 18:21 ` Junio C Hamano 2016-01-10 2:20 ` [PATCH V3 0/2] specify commit by negative pattern Stephen P. Smith 2016-01-09 1:55 ` [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation Stephen & Linda Smith 2016-01-09 2:18 ` Duy Nguyen 2 siblings, 1 reply; 26+ messages in thread From: Junio C Hamano @ 2016-01-08 18:21 UTC (permalink / raw) To: Stephen Smith; +Cc: git Stephen Smith <ischis2@cox.net> writes: > Junio C Hamano <gitster <at> pobox.com> writes: >> > echo modified >>a-blob && >> > git add -u && >> > git commit -m Modified && >> > + git branch modref && >> >> This probably belongs to the previous step, no? >> > What did you mean by this comment? I looked at the original patch and at > Will's response to your comment and am not quite sure what was meant. Notice that the title is [2/2], so there is [1/2], which turns out to be http://article.gmane.org/gmane.comp.version-control.git/270898 That patch updates the preparatory steps of the test script so that [2/2] have more commits and refs to work with to perform more tests. Marking the result of that "Modified" commit so that it can be referenced later with a short name 'modref' is something that should have done in [1/2], which added that new invocation of "git commit" to record that "Modified" commit, not in [2/2] as an afterthought "Oh I created Modified commit in 1/2 so that I can use it in the test in 2/2, but I forgot to give it a name, so I am adding a new invocation of 'git branch' in this step". > >> > +test_expect_success 'ref^{/!-}' ' >> > + test_must_fail git rev-parse master^{/!-} >> > +' >> > I plan on leaving this in. > >> > +test_expect_success 'ref^{/!-.}' ' >> > + test_must_fail git rev-parse master^{/!-.} >> > +' >> > I plan on leaving this in. ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH V3 0/2] specify commit by negative pattern 2016-01-08 18:21 ` Junio C Hamano @ 2016-01-10 2:20 ` Stephen P. Smith 2016-01-10 2:22 ` [PATCH V3 1/2] test for '!' handling in rev-parse's named commits Stephen P. Smith ` (3 more replies) 0 siblings, 4 replies; 26+ messages in thread From: Stephen P. Smith @ 2016-01-10 2:20 UTC (permalink / raw) To: Git Mailing List; +Cc: Junio C Hamano, Duy Nguyen, Stephen P. Smith Add support for negative pattern matching in <at> ^{/<pattern>} style revision specifiers. So now you can find the first commit whose message doesn't match a pattern, complementing the existing positive matching. e.g.: $ git rebase -i <at> ^{/!-^WIP} My use-case is in having a "work, work, work, rebase, push"-style workflow, which generates a lot of "WIP foo" commits. While rebasing is usually handled via "git rebase -i origin/master", occasionally I will already have several "good, but not yet ready to push" commits hanging around while I finish work on related commits. In these situations, the ability to quickly "git diff <at> ^{/!-^WIP}" to get an overview of all changes "since the last one I was happy with", can be useful. This is the second version of the patch series. The previous attempt used the notation <at> ^{/!WIP}, rather than <at> ^{/!-WIP}, so the "modifier" was the '!' character. Now, '!' is taken as an indicator that the pattern is to be interpreted differently, and '-' is taken as an indicator of how it is to be interpreted differently. This follows recent discussion with "Junio C Hamano" <gitster <at> pobox.com> and much-less recent discussion archived at: http://thread.gmane.org/gmane.comp.version-control.git/40460/focus=40477 In summary, '!' is to be used as an "escape hatch", for further extension of the "name commit by pattern" functionality. Theorised future extensions indicated things like "what was to be searched", e.g.: <at> ^{/!(a=author)}. With only two interpretations of the '!' leader, for now (including the '!!' literal notation), adding such a verbose form, such as ' <at> ^{/!(negative)foo}', seemed inappropriate at this time. In the event that such verbose forms are ever implemented, this new form may act as a shorthand, for a basic case. Will Palmer (2): test for '!' handling in rev-parse's named commits object name: introduce '^{/!-<negative pattern>}' notation Documentation/revisions.txt | 11 +++++----- sha1_name.c | 20 ++++++++++++----- t/t1511-rev-parse-caret.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 73 insertions(+), 11 deletions(-) -- 2.7.0-rc2 ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH V3 1/2] test for '!' handling in rev-parse's named commits 2016-01-10 2:20 ` [PATCH V3 0/2] specify commit by negative pattern Stephen P. Smith @ 2016-01-10 2:22 ` Stephen P. Smith 2016-01-10 2:23 ` [PATCH V3 2/2] object name: introduce '^{/!-<negative pattern>}' notation Stephen P. Smith ` (2 subsequent siblings) 3 siblings, 0 replies; 26+ messages in thread From: Stephen P. Smith @ 2016-01-10 2:22 UTC (permalink / raw) To: Git Mailing List Cc: Junio C Hamano, Duy Nguyen, Will Palmer, Stephen P . Smith From: Will Palmer <wmpalmer@gmail.com> In anticipation of extending this behaviour, add tests verifying the handling of exclamation marks when looking up a commit "by name". Specifically, as documented: '<rev>^{/!Message}' should fail, as the '!' prefix is reserved; while '<rev>^{!!Message}' should search for a commit whose message contains the string "!Message". Signed-off-by: Will Palmer <wmpalmer@gmail.com> Signed-off-by: Stephen P. Smith <ischis2@cox.net> --- Notes: Moved modref branch from 2/2 to the 1/2 patch as discussed in [1] and [2]. In [3] the suggestion was made to change ^{!/... to ^{/!. The comment notes that anything after { is reserved and can be used. The v2 commit mesage (which has been retained) noted that !Message should fail as '!' is reserved where !!Message should search for a string that contains !Message. Because of the commit note, I chose not to make the change from ^{!/... to ^{/!.. [1] http://article.gmane.org/gmane.comp.version-control.git/271071 [2] http://article.gmane.org/gmane.comp.version-control.git/283573 [3] http://article.gmane.org/gmane.comp.version-control.git/283597 t/t1511-rev-parse-caret.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index 15973f2..b2f90be 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 -- 2.7.0-rc2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH V3 2/2] object name: introduce '^{/!-<negative pattern>}' notation 2016-01-10 2:20 ` [PATCH V3 0/2] specify commit by negative pattern Stephen P. Smith 2016-01-10 2:22 ` [PATCH V3 1/2] test for '!' handling in rev-parse's named commits Stephen P. Smith @ 2016-01-10 2:23 ` Stephen P. Smith 2016-01-11 18:10 ` Philip Oakley 2016-01-10 13:25 ` [PATCH V3 0/2] specify commit by negative pattern Philip Oakley 2016-01-10 14:14 ` Stephen & Linda Smith 3 siblings, 1 reply; 26+ messages in thread From: Stephen P. Smith @ 2016-01-10 2:23 UTC (permalink / raw) To: Git Mailing List Cc: Junio C Hamano, Duy Nguyen, Will Palmer, Stephen P . Smith From: Will Palmer <wmpalmer@gmail.com> To name a commit, you can now 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> --- Notes: Moved modref branch from 2/2 to the 1/2 patch as discussed in [1] and [2]. [1] http://article.gmane.org/gmane.comp.version-control.git/271071 [2] http://article.gmane.org/gmane.comp.version-control.git/283573 Documentation/revisions.txt | 11 ++++++----- sha1_name.c | 20 +++++++++++++++----- t/t1511-rev-parse-caret.sh | 31 ++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt index d85e303..0c84d4f 100644 --- a/Documentation/revisions.txt +++ b/Documentation/revisions.txt @@ -176,11 +176,12 @@ existing tag object. A colon, followed by a slash, followed by a text, names a commit whose commit message matches the specified regular expression. This name returns the youngest matching commit which is - reachable from any ref. If the commit message starts with a - '!' you have to repeat that; the special sequence ':/!', - followed by something else than '!', is reserved for now. - The regular expression can match any part of the commit message. To - match messages starting with a string, one can use e.g. ':/^foo'. + reachable from any ref. The regular expression can match any part of the + commit message. To match messages starting with a string, one can use + e.g. ':/^foo'. The special sequence ':/!' is reserved for modifiers to what + is matched. ':/!-foo' performs a negative match, while ':/!!foo' matches a + literal '!' character, followed by 'foo'. Any other sequence beginning with + ':/!' is reserved for now. '<rev>:<path>', e.g. 'HEAD:README', ':README', 'master:./README':: A suffix ':' followed by a path names the blob or tree diff --git a/sha1_name.c b/sha1_name.c index 892db21..a2c5303 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -848,8 +848,12 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l * through history and returning the first commit whose message starts * the given regular expression. * - * For future extension, ':/!' is reserved. If you want to match a message - * beginning with a '!', you have to repeat the exclamation mark. + * For negative-matching, prefix the pattern-part with '!-', like: ':/!-WIP'. + * + * For a literal '!' character at the beginning of a pattern, you have to repeat + * that, like: ':/!!foo' + * + * For future extension, all other sequences beginning with ':/!' are reserved. */ /* Remember to update object flag allocation in object.h */ @@ -878,12 +882,18 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, { struct commit_list *backup = NULL, *l; int found = 0; + int negative = 0; regex_t regex; if (prefix[0] == '!') { - if (prefix[1] != '!') - die ("Invalid search pattern: %s", prefix); prefix++; + + if (prefix[0] == '-') { + prefix++; + negative = 1; + } else if (prefix[0] != '!') { + die ("Invalid search pattern: %s", prefix); + } } if (regcomp(®ex, prefix, REG_EXTENDED)) @@ -903,7 +913,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, continue; buf = get_commit_buffer(commit, NULL); p = strstr(buf, "\n\n"); - matches = p && !regexec(®ex, p + 2, 0, NULL, 0); + matches = p && (negative ^ !regexec(®ex, p + 2, 0, NULL, 0)); unuse_commit_buffer(commit, buf); if (matches) { diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index b2f90be..8a5983f 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 -- 2.7.0-rc2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH V3 2/2] object name: introduce '^{/!-<negative pattern>}' notation 2016-01-10 2:23 ` [PATCH V3 2/2] object name: introduce '^{/!-<negative pattern>}' notation Stephen P. Smith @ 2016-01-11 18:10 ` Philip Oakley 2016-01-13 4:51 ` [PATCH V4 0/2] specify commit by negative pattern Stephen P. Smith ` (2 more replies) 0 siblings, 3 replies; 26+ messages in thread From: Philip Oakley @ 2016-01-11 18:10 UTC (permalink / raw) To: Stephen P. Smith, Git Mailing List Cc: Junio C Hamano, Duy Nguyen, Will Palmer, Stephen P . Smith From: "Stephen P. Smith" <ischis2@cox.net> > From: Will Palmer <wmpalmer@gmail.com> > > To name a commit, you can now say perhaps s|say|use the :/!-<negative pattern> regex style, and consequentially, say| Should the patch subject line also be updated to reflect the change? > > $ 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> > --- > > Notes: > Moved modref branch from 2/2 to the 1/2 patch as discussed in [1] and > [2]. > > [1] http://article.gmane.org/gmane.comp.version-control.git/271071 > [2] http://article.gmane.org/gmane.comp.version-control.git/283573 > > Documentation/revisions.txt | 11 ++++++----- > sha1_name.c | 20 +++++++++++++++----- > t/t1511-rev-parse-caret.sh | 31 ++++++++++++++++++++++++++++++- > 3 files changed, 51 insertions(+), 11 deletions(-) > > diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt > index d85e303..0c84d4f 100644 > --- a/Documentation/revisions.txt > +++ b/Documentation/revisions.txt > @@ -176,11 +176,12 @@ existing tag object. > A colon, followed by a slash, followed by a text, names > a commit whose commit message matches the specified regular expression. > This name returns the youngest matching commit which is > - reachable from any ref. If the commit message starts with a > - '!' you have to repeat that; the special sequence ':/!', > - followed by something else than '!', is reserved for now. > - The regular expression can match any part of the commit message. To > - match messages starting with a string, one can use e.g. ':/^foo'. > + reachable from any ref. The regular expression can match any part of > the > + commit message. To match messages starting with a string, one can use > + e.g. ':/^foo'. The special sequence ':/!' is reserved for modifiers to > what > + is matched. ':/!-foo' performs a negative match, while ':/!!foo' > matches a > + literal '!' character, followed by 'foo'. Any other sequence beginning > with > + ':/!' is reserved for now. > > '<rev>:<path>', e.g. 'HEAD:README', ':README', 'master:./README':: > A suffix ':' followed by a path names the blob or tree > diff --git a/sha1_name.c b/sha1_name.c > index 892db21..a2c5303 100644 > --- a/sha1_name.c > +++ b/sha1_name.c > @@ -848,8 +848,12 @@ static int get_sha1_1(const char *name, int len, > unsigned char *sha1, unsigned l > * through history and returning the first commit whose message starts > * the given regular expression. > * > - * For future extension, ':/!' is reserved. If you want to match a > message > - * beginning with a '!', you have to repeat the exclamation mark. > + * For negative-matching, prefix the pattern-part with '!-', like: > ':/!-WIP'. > + * > + * For a literal '!' character at the beginning of a pattern, you have to > repeat > + * that, like: ':/!!foo' > + * > + * For future extension, all other sequences beginning with ':/!' are > reserved. > */ > > /* Remember to update object flag allocation in object.h */ > @@ -878,12 +882,18 @@ static int get_sha1_oneline(const char *prefix, > unsigned char *sha1, > { > struct commit_list *backup = NULL, *l; > int found = 0; > + int negative = 0; > regex_t regex; > > if (prefix[0] == '!') { > - if (prefix[1] != '!') > - die ("Invalid search pattern: %s", prefix); > prefix++; > + > + if (prefix[0] == '-') { > + prefix++; > + negative = 1; > + } else if (prefix[0] != '!') { > + die ("Invalid search pattern: %s", prefix); > + } > } > > if (regcomp(®ex, prefix, REG_EXTENDED)) > @@ -903,7 +913,7 @@ static int get_sha1_oneline(const char *prefix, > unsigned char *sha1, > continue; > buf = get_commit_buffer(commit, NULL); > p = strstr(buf, "\n\n"); > - matches = p && !regexec(®ex, p + 2, 0, NULL, 0); > + matches = p && (negative ^ !regexec(®ex, p + 2, 0, NULL, 0)); > unuse_commit_buffer(commit, buf); > > if (matches) { > diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh > index b2f90be..8a5983f 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 > -- > 2.7.0-rc2 > > -- > To unsubscribe from this list: send the line "unsubscribe git" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH V4 0/2] specify commit by negative pattern 2016-01-11 18:10 ` Philip Oakley @ 2016-01-13 4:51 ` Stephen P. Smith 2016-01-13 4:51 ` [PATCH V4 1/2] test for '!' handling in rev-parse's named commits Stephen P. Smith 2016-01-13 4:52 ` [PATCH V4 2/2] object name: introduce '^{/!-<negative pattern>}' notation Stephen P. Smith 2 siblings, 0 replies; 26+ messages in thread From: Stephen P. Smith @ 2016-01-13 4:51 UTC (permalink / raw) To: Philip Oakley Cc: Junio C Hamano, Duy Nguyen, Git Mailing List, Stephen P. Smith Add support for negative pattern matching in the @^{/<pattern>} regex pattern style, and consequentially the style revision specifiers. So now you can find the first commit whose message doesn't match a pattern, complementing the existing positive matching. e.g.: $ git rebase -i @^{/!-^WIP} My use-case is in having a "work, work, work, rebase, push"-style workflow, which generates a lot of "WIP foo" commits. While rebasing is usually handled via "git rebase -i origin/master", occasionally I will already have several "good, but not yet ready to push" commits hanging around while I finish work on related commits. In these situations, the ability to quickly "git diff @^{/!-^WIP}" to get an overview of all changes "since the last one I was happy with", can be useful. This is the forth version of the patch series. The previous attempt used the notation @^{/!WIP}, rather than @^{/!-WIP}, so the "modifier" was the '!' character. Now, '!' is taken as an indicator that the pattern is to be interpreted differently, and '-' is taken as an indicator of how it is to be interpreted differently. This follows recent discussion with "Junio C Hamano" <gitster@pobox.com> and much-less recent discussion archived at: http://thread.gmane.org/gmane.comp.version-control.git/40460/focus=40477 In summary, '!' is to be used as an "escape hatch", for further extension of the "name commit by pattern" functionality. Theorised future extensions indicated things like "what was to be searched", e.g.: @^{/!(a=author)}. With only two interpretations of the '!' leader, for now (including the '!!' literal notation), adding such a verbose form, such as '@^{/!(negative)foo}', seemed inappropriate at this time. In the event that such verbose forms are ever implemented, this new form may act as a shorthand, for a basic case. Will Palmer (2): test for '!' handling in rev-parse's named commits object name: introduce '^{/!-<negative pattern>}' notation Documentation/revisions.txt | 11 +++++----- sha1_name.c | 20 ++++++++++++----- t/t1511-rev-parse-caret.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 73 insertions(+), 11 deletions(-) -- 2.7.0-rc2 ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH V4 1/2] test for '!' handling in rev-parse's named commits 2016-01-11 18:10 ` Philip Oakley 2016-01-13 4:51 ` [PATCH V4 0/2] specify commit by negative pattern Stephen P. Smith @ 2016-01-13 4:51 ` Stephen P. Smith 2016-01-13 4:52 ` [PATCH V4 2/2] object name: introduce '^{/!-<negative pattern>}' notation Stephen P. Smith 2 siblings, 0 replies; 26+ messages in thread From: Stephen P. Smith @ 2016-01-13 4:51 UTC (permalink / raw) To: Philip Oakley Cc: Junio C Hamano, Duy Nguyen, Git Mailing List, Will Palmer, Stephen P . Smith From: Will Palmer <wmpalmer@gmail.com> In anticipation of extending this behaviour, add tests verifying the handling of exclamation marks when looking up a commit "by name". Specifically, as documented: '<rev>^{/!Message}' should fail, as the '!' prefix is reserved; while '<rev>^{!!Message}' should search for a commit whose message contains the string "!Message". Signed-off-by: Will Palmer <wmpalmer@gmail.com> Signed-off-by: Stephen P. Smith <ischis2@cox.net> --- Notes: No actual changes made to this patch. Just re-sending to keep consistent with updates to the rest of the series. t/t1511-rev-parse-caret.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index 15973f2..b2f90be 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 -- 2.7.0-rc2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH V4 2/2] object name: introduce '^{/!-<negative pattern>}' notation 2016-01-11 18:10 ` Philip Oakley 2016-01-13 4:51 ` [PATCH V4 0/2] specify commit by negative pattern Stephen P. Smith 2016-01-13 4:51 ` [PATCH V4 1/2] test for '!' handling in rev-parse's named commits Stephen P. Smith @ 2016-01-13 4:52 ` Stephen P. Smith 2016-01-13 19:15 ` Junio C Hamano 2 siblings, 1 reply; 26+ messages in thread From: Stephen P. Smith @ 2016-01-13 4:52 UTC (permalink / raw) To: Philip Oakley Cc: Junio C Hamano, Duy Nguyen, Git Mailing List, Will Palmer, Stephen P . Smith From: Will Palmer <wmpalmer@gmail.com> 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> --- Notes: Changed |say|use the :/!-<negative pattern> regex style, and consequentially, say|. Chose not to chagne subject since it matches the end of git rev-parse HEAD^{/!-foo} Mailing list web interface is again not working; therefore, I don't have URLs for the earlier review comments. Documentation/revisions.txt | 11 ++++++----- sha1_name.c | 20 +++++++++++++++----- t/t1511-rev-parse-caret.sh | 31 ++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt index d85e303..0c84d4f 100644 --- a/Documentation/revisions.txt +++ b/Documentation/revisions.txt @@ -176,11 +176,12 @@ existing tag object. A colon, followed by a slash, followed by a text, names a commit whose commit message matches the specified regular expression. This name returns the youngest matching commit which is - reachable from any ref. If the commit message starts with a - '!' you have to repeat that; the special sequence ':/!', - followed by something else than '!', is reserved for now. - The regular expression can match any part of the commit message. To - match messages starting with a string, one can use e.g. ':/^foo'. + reachable from any ref. The regular expression can match any part of the + commit message. To match messages starting with a string, one can use + e.g. ':/^foo'. The special sequence ':/!' is reserved for modifiers to what + is matched. ':/!-foo' performs a negative match, while ':/!!foo' matches a + literal '!' character, followed by 'foo'. Any other sequence beginning with + ':/!' is reserved for now. '<rev>:<path>', e.g. 'HEAD:README', ':README', 'master:./README':: A suffix ':' followed by a path names the blob or tree diff --git a/sha1_name.c b/sha1_name.c index 892db21..a2c5303 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -848,8 +848,12 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l * through history and returning the first commit whose message starts * the given regular expression. * - * For future extension, ':/!' is reserved. If you want to match a message - * beginning with a '!', you have to repeat the exclamation mark. + * For negative-matching, prefix the pattern-part with '!-', like: ':/!-WIP'. + * + * For a literal '!' character at the beginning of a pattern, you have to repeat + * that, like: ':/!!foo' + * + * For future extension, all other sequences beginning with ':/!' are reserved. */ /* Remember to update object flag allocation in object.h */ @@ -878,12 +882,18 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, { struct commit_list *backup = NULL, *l; int found = 0; + int negative = 0; regex_t regex; if (prefix[0] == '!') { - if (prefix[1] != '!') - die ("Invalid search pattern: %s", prefix); prefix++; + + if (prefix[0] == '-') { + prefix++; + negative = 1; + } else if (prefix[0] != '!') { + die ("Invalid search pattern: %s", prefix); + } } if (regcomp(®ex, prefix, REG_EXTENDED)) @@ -903,7 +913,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, continue; buf = get_commit_buffer(commit, NULL); p = strstr(buf, "\n\n"); - matches = p && !regexec(®ex, p + 2, 0, NULL, 0); + matches = p && (negative ^ !regexec(®ex, p + 2, 0, NULL, 0)); unuse_commit_buffer(commit, buf); if (matches) { diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index b2f90be..8a5983f 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 -- 2.7.0-rc2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH V4 2/2] object name: introduce '^{/!-<negative pattern>}' notation 2016-01-13 4:52 ` [PATCH V4 2/2] object name: introduce '^{/!-<negative pattern>}' notation Stephen P. Smith @ 2016-01-13 19:15 ` Junio C Hamano 2016-01-31 0:06 ` [PATCH V5 " Stephen P. Smith 0 siblings, 1 reply; 26+ messages in thread From: Junio C Hamano @ 2016-01-13 19:15 UTC (permalink / raw) To: Stephen P. Smith; +Cc: Philip Oakley, Duy Nguyen, Git Mailing List, Will Palmer "Stephen P. Smith" <ischis2@cox.net> writes: > From: Will Palmer <wmpalmer@gmail.com> > > 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> > --- > > Notes: > Changed |say|use the :/!-<negative pattern> regex style, and consequentially, say|. > > Chose not to chagne subject since it matches the end of > git rev-parse HEAD^{/!-foo} > > Mailing list web interface is again not working; therefore, I don't > have URLs for the earlier review comments. Thanks, this looks good (and it looked good already at the previous round). > diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt > index d85e303..0c84d4f 100644 > --- a/Documentation/revisions.txt > +++ b/Documentation/revisions.txt > @@ -176,11 +176,12 @@ existing tag object. > A colon, followed by a slash, followed by a text, names > a commit whose commit message matches the specified regular expression. > This name returns the youngest matching commit which is > - reachable from any ref. If the commit message starts with a > - '!' you have to repeat that; the special sequence ':/!', > - followed by something else than '!', is reserved for now. > - The regular expression can match any part of the commit message. To > - match messages starting with a string, one can use e.g. ':/^foo'. > + reachable from any ref. The regular expression can match any part of the > + commit message. To match messages starting with a string, one can use > + e.g. ':/^foo'. The special sequence ':/!' is reserved for modifiers to what > + is matched. ':/!-foo' performs a negative match, while ':/!!foo' matches a > + literal '!' character, followed by 'foo'. Any other sequence beginning with > + ':/!' is reserved for now. The original text reads as if ":/foo" looks for 'foo' anywhere in the log message while ":/!!foo" looks for '!foo' at the beginning, which was incorrect as far as I can tell, but the updated text corrects it. Good. > @@ -903,7 +913,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, > continue; > buf = get_commit_buffer(commit, NULL); > p = strstr(buf, "\n\n"); > - matches = p && !regexec(®ex, p + 2, 0, NULL, 0); > + matches = p && (negative ^ !regexec(®ex, p + 2, 0, NULL, 0)); > unuse_commit_buffer(commit, buf); Hmph, without "negative pattern match", if you asked for ":/foo" and the commit did not have any body (which I do not think the current version of Git allows to create by default, but there may be such commits created by older versions of Git or reimplementation of Git made by others), p could be NULL. In such a case, any regex would not match, so I would expect that commit to be shown. In other words, I wonder if the above should be matches = negative ^ (p && !regexec(®ex, p + 2, 0, NULL, 0)); This would not make practical difference, but I would expect any change to introduce "negative patch" to an original logic that is matches = ORIGINAL_LOGIC_TO_COMPUTE_MATCH to become matches = negative ^ ORIGINAL_LOGIC_TO_COMPUTE_MATCH ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH V5 2/2] object name: introduce '^{/!-<negative pattern>}' notation 2016-01-13 19:15 ` Junio C Hamano @ 2016-01-31 0:06 ` Stephen P. Smith 2016-02-01 21:42 ` Junio C Hamano 0 siblings, 1 reply; 26+ messages in thread From: Stephen P. Smith @ 2016-01-31 0:06 UTC (permalink / raw) To: Philip Oakley Cc: Junio C Hamano, Duy Nguyen, Git Mailing List, Will Palmer, Stephen P . Smith From: Will Palmer <wmpalmer@gmail.com> 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> --- Notes: I agree that there may be commits that have an empty body which were made with older git releases. Even if the current git does check for empty bodied commits (by default), the git plumbing should be able to still create such commits. The tests show that the change from: matches = p && (negative ^ !regexec(®ex, p + 2, 0, NULL, 0)); to matches = negative ^ (p && !regexec(®ex, p + 2, 0, NULL, 0)); did not break the proposed patch. Documentation/revisions.txt | 11 ++++++----- sha1_name.c | 20 +++++++++++++++----- t/t1511-rev-parse-caret.sh | 31 ++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt index d85e303..0c84d4f 100644 --- a/Documentation/revisions.txt +++ b/Documentation/revisions.txt @@ -176,11 +176,12 @@ existing tag object. A colon, followed by a slash, followed by a text, names a commit whose commit message matches the specified regular expression. This name returns the youngest matching commit which is - reachable from any ref. If the commit message starts with a - '!' you have to repeat that; the special sequence ':/!', - followed by something else than '!', is reserved for now. - The regular expression can match any part of the commit message. To - match messages starting with a string, one can use e.g. ':/^foo'. + reachable from any ref. The regular expression can match any part of the + commit message. To match messages starting with a string, one can use + e.g. ':/^foo'. The special sequence ':/!' is reserved for modifiers to what + is matched. ':/!-foo' performs a negative match, while ':/!!foo' matches a + literal '!' character, followed by 'foo'. Any other sequence beginning with + ':/!' is reserved for now. '<rev>:<path>', e.g. 'HEAD:README', ':README', 'master:./README':: A suffix ':' followed by a path names the blob or tree diff --git a/sha1_name.c b/sha1_name.c index 892db21..89918ca 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -848,8 +848,12 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l * through history and returning the first commit whose message starts * the given regular expression. * - * For future extension, ':/!' is reserved. If you want to match a message - * beginning with a '!', you have to repeat the exclamation mark. + * For negative-matching, prefix the pattern-part with '!-', like: ':/!-WIP'. + * + * For a literal '!' character at the beginning of a pattern, you have to repeat + * that, like: ':/!!foo' + * + * For future extension, all other sequences beginning with ':/!' are reserved. */ /* Remember to update object flag allocation in object.h */ @@ -878,12 +882,18 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, { struct commit_list *backup = NULL, *l; int found = 0; + int negative = 0; regex_t regex; if (prefix[0] == '!') { - if (prefix[1] != '!') - die ("Invalid search pattern: %s", prefix); prefix++; + + if (prefix[0] == '-') { + prefix++; + negative = 1; + } else if (prefix[0] != '!') { + die ("Invalid search pattern: %s", prefix); + } } if (regcomp(®ex, prefix, REG_EXTENDED)) @@ -903,7 +913,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, continue; buf = get_commit_buffer(commit, NULL); p = strstr(buf, "\n\n"); - matches = p && !regexec(®ex, p + 2, 0, NULL, 0); + matches = negative ^ (p && !regexec(®ex, p + 2, 0, NULL, 0)); unuse_commit_buffer(commit, buf); if (matches) { diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index b2f90be..8a5983f 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 -- 2.7.0-rc2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH V5 2/2] object name: introduce '^{/!-<negative pattern>}' notation 2016-01-31 0:06 ` [PATCH V5 " Stephen P. Smith @ 2016-02-01 21:42 ` Junio C Hamano 0 siblings, 0 replies; 26+ messages in thread From: Junio C Hamano @ 2016-02-01 21:42 UTC (permalink / raw) To: Stephen P. Smith; +Cc: Philip Oakley, Duy Nguyen, Git Mailing List, Will Palmer Thanks. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH V3 0/2] specify commit by negative pattern 2016-01-10 2:20 ` [PATCH V3 0/2] specify commit by negative pattern Stephen P. Smith 2016-01-10 2:22 ` [PATCH V3 1/2] test for '!' handling in rev-parse's named commits Stephen P. Smith 2016-01-10 2:23 ` [PATCH V3 2/2] object name: introduce '^{/!-<negative pattern>}' notation Stephen P. Smith @ 2016-01-10 13:25 ` Philip Oakley 2016-01-11 0:08 ` Stephen P. Smith 2016-01-10 14:14 ` Stephen & Linda Smith 3 siblings, 1 reply; 26+ messages in thread From: Philip Oakley @ 2016-01-10 13:25 UTC (permalink / raw) To: Stephen P. Smith, Git Mailing List Cc: Junio C Hamano, Duy Nguyen, Stephen P. Smith From: "Stephen P. Smith" <ischis2@cox.net> > Add support for negative pattern matching in <at> ^{/<pattern>} style Has this become mangled by replacing the '@' with ' <at> ' ? When I look at the update to revisions.txt it doesn't look like its touching the '@' description. Is this '@^' a new (for the documenation) combination. Or has the example confused me? > revision specifiers. So now you can find the first commit whose message > doesn't match a pattern, complementing the existing positive matching. > e.g.: > > $ git rebase -i <at> ^{/!-^WIP} > > My use-case is in having a "work, work, work, rebase, push"-style > workflow, which generates a lot of "WIP foo" commits. While rebasing is > usually handled via "git rebase -i origin/master", occasionally I will > already have several "good, but not yet ready to push" commits hanging > around while I finish work on related commits. In these situations, the > ability to quickly "git diff <at> ^{/!-^WIP}" to get an overview of all > changes "since the last one I was happy with", can be useful. > > This is the second version of the patch series. The previous attempt > used the notation <at> ^{/!WIP}, rather than <at> ^{/!-WIP}, so the > "modifier" > was the '!' character. Now, '!' is taken as an indicator that the > pattern is to be interpreted differently, and '-' is taken as an > indicator of how it is to be interpreted differently. This follows > recent discussion with "Junio C Hamano" <gitster <at> pobox.com> and > much-less > recent discussion archived at: > > http://thread.gmane.org/gmane.comp.version-control.git/40460/focus=40477 > > In summary, '!' is to be used as an "escape hatch", for further > extension of the "name commit by pattern" functionality. Theorised future > extensions indicated things like "what was to be searched", > e.g.: <at> ^{/!(a=author)}. With only two interpretations of the '!' > leader, for now (including the '!!' literal notation), adding such a > verbose form, such as ' <at> ^{/!(negative)foo}', seemed inappropriate at > this > time. In the event that such verbose forms are ever implemented, this new > form may act as a shorthand, for a basic case. > > Will Palmer (2): > test for '!' handling in rev-parse's named commits > object name: introduce '^{/!-<negative pattern>}' notation > > Documentation/revisions.txt | 11 +++++----- > sha1_name.c | 20 ++++++++++++----- > t/t1511-rev-parse-caret.sh | 53 > ++++++++++++++++++++++++++++++++++++++++++++- > 3 files changed, 73 insertions(+), 11 deletions(-) > -- Philip ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH V3 0/2] specify commit by negative pattern 2016-01-10 13:25 ` [PATCH V3 0/2] specify commit by negative pattern Philip Oakley @ 2016-01-11 0:08 ` Stephen P. Smith 2016-01-11 18:04 ` Philip Oakley 0 siblings, 1 reply; 26+ messages in thread From: Stephen P. Smith @ 2016-01-11 0:08 UTC (permalink / raw) To: Philip Oakley Cc: Junio C Hamano, Duy Nguyen, Git Mailing List, Stephen P. Smith Add support for negative pattern matching in @^{/<pattern>} style revision specifiers. So now you can find the first commit whose message doesn't match a pattern, complementing the existing positive matching. e.g.: $ git rebase -i @^{/!-^WIP} My use-case is in having a "work, work, work, rebase, push"-style workflow, which generates a lot of "WIP foo" commits. While rebasing is usually handled via "git rebase -i origin/master", occasionally I will already have several "good, but not yet ready to push" commits hanging around while I finish work on related commits. In these situations, the ability to quickly "git diff @^{/!-^WIP}" to get an overview of all changes "since the last one I was happy with", can be useful. This is the second version of the patch series. The previous attempt used the notation @^{/!WIP}, rather than @^{/!-WIP}, so the "modifier" was the '!' character. Now, '!' is taken as an indicator that the pattern is to be interpreted differently, and '-' is taken as an indicator of how it is to be interpreted differently. This follows recent discussion with "Junio C Hamano" <gitster@pobox.com> and much-less recent discussion archived at: http://thread.gmane.org/gmane.comp.version-control.git/40460/focus=40477 In summary, '!' is to be used as an "escape hatch", for further extension of the "name commit by pattern" functionality. Theorised future extensions indicated things like "what was to be searched", e.g.: @^{/!(a=author)}. With only two interpretations of the '!' leader, for now (including the '!!' literal notation), adding such a verbose form, such as '@^{/!(negative)foo}', seemed inappropriate at this time. In the event that such verbose forms are ever implemented, this new form may act as a shorthand, for a basic case. Will Palmer (2): test for '!' handling in rev-parse's named commits object name: introduce '^{/!-<negative pattern>}' notation Documentation/revisions.txt | 11 +++++----- sha1_name.c | 20 ++++++++++++----- t/t1511-rev-parse-caret.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 73 insertions(+), 11 deletions(-) -- 2.7.0-rc2 ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH V3 0/2] specify commit by negative pattern 2016-01-11 0:08 ` Stephen P. Smith @ 2016-01-11 18:04 ` Philip Oakley 0 siblings, 0 replies; 26+ messages in thread From: Philip Oakley @ 2016-01-11 18:04 UTC (permalink / raw) To: Stephen P. Smith Cc: Junio C Hamano, Duy Nguyen, Git Mailing List, Stephen P. Smith From: "Stephen P. Smith" <ischis2@cox.net> > Add support for negative pattern matching in perhaps s!in!in the :/<text> regex pattern style, and consequentially the! Given that the documenation changes are there. > @^{/<pattern>} style > revision specifiers. So now you can find the first commit whose message > doesn't match a pattern, complementing the existing positive matching. > e.g.: > > $ git rebase -i @^{/!-^WIP} > > My use-case is in having a "work, work, work, rebase, push"-style > workflow, which generates a lot of "WIP foo" commits. While rebasing is > usually handled via "git rebase -i origin/master", occasionally I will > already have several "good, but not yet ready to push" commits hanging > around while I finish work on related commits. In these situations, the > ability to quickly "git diff @^{/!-^WIP}" to get an overview of all > changes "since the last one I was happy with", can be useful. > > This is the second version of the patch series. The previous attempt > used the notation @^{/!WIP}, rather than @^{/!-WIP}, so the "modifier" > was the '!' character. Now, '!' is taken as an indicator that the > pattern is to be interpreted differently, and '-' is taken as an > indicator of how it is to be interpreted differently. This follows > recent discussion with "Junio C Hamano" <gitster@pobox.com> and much-less > recent discussion archived at: > > http://thread.gmane.org/gmane.comp.version-control.git/40460/focus=40477 > > In summary, '!' is to be used as an "escape hatch", for further > extension of the "name commit by pattern" functionality. Theorised future > extensions indicated things like "what was to be searched", > e.g.: @^{/!(a=author)}. With only two interpretations of the '!' > leader, for now (including the '!!' literal notation), adding such a > verbose form, such as '@^{/!(negative)foo}', seemed inappropriate at this > time. In the event that such verbose forms are ever implemented, this new > form may act as a shorthand, for a basic case. > > Will Palmer (2): > test for '!' handling in rev-parse's named commits > object name: introduce '^{/!-<negative pattern>}' notation > > Documentation/revisions.txt | 11 +++++----- > sha1_name.c | 20 ++++++++++++----- > t/t1511-rev-parse-caret.sh | 53 > ++++++++++++++++++++++++++++++++++++++++++++- > 3 files changed, 73 insertions(+), 11 deletions(-) > > -- > 2.7.0-rc2 > > -- > To unsubscribe from this list: send the line "unsubscribe git" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH V3 0/2] specify commit by negative pattern 2016-01-10 2:20 ` [PATCH V3 0/2] specify commit by negative pattern Stephen P. Smith ` (2 preceding siblings ...) 2016-01-10 13:25 ` [PATCH V3 0/2] specify commit by negative pattern Philip Oakley @ 2016-01-10 14:14 ` Stephen & Linda Smith 2016-01-10 23:36 ` Philip Oakley 3 siblings, 1 reply; 26+ messages in thread From: Stephen & Linda Smith @ 2016-01-10 14:14 UTC (permalink / raw) To: Philip Oakley; +Cc: Git Mailing List, Junio C Hamano, Duy Nguyen On Sunday, January 10, 2016 01:25:42 PM Philip Oakley wrote: > From: "Stephen P. Smith" <ischis2@cox.net> > > Add support for negative pattern matching in <at> ^{/<pattern>} style > > Has this become mangled by replacing the '@' with ' <at> ' ? It looks like the cover letter got mangled. I will fix after I get any comments on the patches themselves. > > When I look at the update to revisions.txt it doesn't look like its touching > the '@' description. > Is this '@^' a new (for the documenation) combination. Or has the example > confused me? > > > revision specifiers. So now you can find the first commit whose message > > doesn't match a pattern, complementing the existing positive matching. > > e.g.: > > > > $ git rebase -i <at> ^{/!-^WIP} > > > > My use-case is in having a "work, work, work, rebase, push"-style > > workflow, which generates a lot of "WIP foo" commits. While rebasing is > > usually handled via "git rebase -i origin/master", occasionally I will > > already have several "good, but not yet ready to push" commits hanging > > around while I finish work on related commits. In these situations, the > > ability to quickly "git diff <at> ^{/!-^WIP}" to get an overview of all > > changes "since the last one I was happy with", can be useful. > > > > This is the second version of the patch series. The previous attempt > > used the notation <at> ^{/!WIP}, rather than <at> ^{/!-WIP}, so the > > "modifier" > > was the '!' character. Now, '!' is taken as an indicator that the > > pattern is to be interpreted differently, and '-' is taken as an > > indicator of how it is to be interpreted differently. This follows > > recent discussion with "Junio C Hamano" <gitster <at> pobox.com> and > > much-less > > recent discussion archived at: > > > > http://thread.gmane.org/gmane.comp.version-control.git/40460/focus=40477 > > > > In summary, '!' is to be used as an "escape hatch", for further > > extension of the "name commit by pattern" functionality. Theorised future > > extensions indicated things like "what was to be searched", > > e.g.: <at> ^{/!(a=author)}. With only two interpretations of the '!' > > leader, for now (including the '!!' literal notation), adding such a > > verbose form, such as ' <at> ^{/!(negative)foo}', seemed inappropriate at > > this > > time. In the event that such verbose forms are ever implemented, this new > > form may act as a shorthand, for a basic case. > > > > Will Palmer (2): > > test for '!' handling in rev-parse's named commits > > object name: introduce '^{/!-<negative pattern>}' notation > > > > Documentation/revisions.txt | 11 +++++----- > > sha1_name.c | 20 ++++++++++++----- > > t/t1511-rev-parse-caret.sh | 53 > > ++++++++++++++++++++++++++++++++++++++++++++- > > 3 files changed, 73 insertions(+), 11 deletions(-) > > > -- > Philip > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH V3 0/2] specify commit by negative pattern 2016-01-10 14:14 ` Stephen & Linda Smith @ 2016-01-10 23:36 ` Philip Oakley 0 siblings, 0 replies; 26+ messages in thread From: Philip Oakley @ 2016-01-10 23:36 UTC (permalink / raw) To: Stephen & Linda Smith; +Cc: Git Mailing List, Junio C Hamano, Duy Nguyen From: "Stephen & Linda Smith" <ischis2@cox.net> > On Sunday, January 10, 2016 01:25:42 PM Philip Oakley wrote: >> From: "Stephen P. Smith" <ischis2@cox.net> >> > Add support for negative pattern matching in <at> ^{/<pattern>} style >> >> Has this become mangled by replacing the '@' with ' <at> ' ? > It looks like the cover letter got mangled. I will fix after I get any > comments > on the patches themselves. > I think I was also confused between the extra ways of spelling @ (listed first in revisions.txt), and the extra was of spelling <rev>, i.e. the <rev>^{/<text>}, and then in patch 2/2 it actually being the :/<text> syntax. >> >> When I look at the update to revisions.txt it doesn't look like its >> touching >> the '@' description. >> Is this '@^' a new (for the documenation) combination. Or has the example >> confused me? >> >> > revision specifiers. So now you can find the first commit whose message >> > doesn't match a pattern, complementing the existing positive matching. >> > e.g.: >> > >> > $ git rebase -i <at> ^{/!-^WIP} >> > >> > My use-case is in having a "work, work, work, rebase, push"-style >> > workflow, which generates a lot of "WIP foo" commits. While rebasing is >> > usually handled via "git rebase -i origin/master", occasionally I will >> > already have several "good, but not yet ready to push" commits hanging >> > around while I finish work on related commits. In these situations, the >> > ability to quickly "git diff <at> ^{/!-^WIP}" to get an overview of >> > all >> > changes "since the last one I was happy with", can be useful. >> > >> > This is the second version of the patch series. The previous attempt >> > used the notation <at> ^{/!WIP}, rather than <at> ^{/!-WIP}, so the >> > "modifier" >> > was the '!' character. Now, '!' is taken as an indicator that the >> > pattern is to be interpreted differently, and '-' is taken as an >> > indicator of how it is to be interpreted differently. This follows >> > recent discussion with "Junio C Hamano" <gitster <at> pobox.com> and >> > much-less >> > recent discussion archived at: >> > >> > http://thread.gmane.org/gmane.comp.version-control.git/40460/focus=40477 >> > >> > In summary, '!' is to be used as an "escape hatch", for further >> > extension of the "name commit by pattern" functionality. Theorised >> > future >> > extensions indicated things like "what was to be searched", >> > e.g.: <at> ^{/!(a=author)}. With only two interpretations of the '!' >> > leader, for now (including the '!!' literal notation), adding such a >> > verbose form, such as ' <at> ^{/!(negative)foo}', seemed inappropriate >> > at >> > this >> > time. In the event that such verbose forms are ever implemented, this >> > new >> > form may act as a shorthand, for a basic case. >> > >> > Will Palmer (2): >> > test for '!' handling in rev-parse's named commits >> > object name: introduce '^{/!-<negative pattern>}' notation >> > >> > Documentation/revisions.txt | 11 +++++----- >> > sha1_name.c | 20 ++++++++++++----- >> > t/t1511-rev-parse-caret.sh | 53 >> > ++++++++++++++++++++++++++++++++++++++++++++- >> > 3 files changed, 73 insertions(+), 11 deletions(-) >> > >> -- >> Philip >> > > -- > To unsubscribe from this list: send the line "unsubscribe git" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation 2016-01-08 6:04 ` [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation Stephen Smith 2016-01-08 18:21 ` Junio C Hamano @ 2016-01-09 1:55 ` Stephen & Linda Smith 2016-01-09 2:18 ` Duy Nguyen 2 siblings, 0 replies; 26+ messages in thread From: Stephen & Linda Smith @ 2016-01-09 1:55 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Friday, January 08, 2016 10:21:48 AM Junio C Hamano wrote: > Stephen Smith <ischis2@cox.net> writes: > > > Junio C Hamano <gitster <at> pobox.com> writes: > >> > echo modified >>a-blob && > >> > git add -u && > >> > git commit -m Modified && > >> > + git branch modref && > >> > >> This probably belongs to the previous step, no? > >> > > What did you mean by this comment? I looked at the original patch and at > > Will's response to your comment and am not quite sure what was meant. > > Notice that the title is [2/2], so there is [1/2], which turns out > to be http://article.gmane.org/gmane.comp.version-control.git/270898 > I had that patch but didn't connect it to your comment. > That patch updates the preparatory steps of the test script so that > [2/2] have more commits and refs to work with to perform more tests. > > Marking the result of that "Modified" commit so that it can be > referenced later with a short name 'modref' is something that should > have done in [1/2], which added that new invocation of "git commit" > to record that "Modified" commit, not in [2/2] as an afterthought > "Oh I created Modified commit in 1/2 so that I can use it in the > test in 2/2, but I forgot to give it a name, so I am adding a new > invocation of 'git branch' in this step". Yep makes sense. > > > > >> > +test_expect_success 'ref^{/!-}' ' > >> > + test_must_fail git rev-parse master^{/!-} > >> > +' > >> > > I plan on leaving this in. > > > >> > +test_expect_success 'ref^{/!-.}' ' > >> > + test_must_fail git rev-parse master^{/!-.} > >> > +' > >> > > I plan on leaving this in. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation 2016-01-08 6:04 ` [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation Stephen Smith 2016-01-08 18:21 ` Junio C Hamano 2016-01-09 1:55 ` [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation Stephen & Linda Smith @ 2016-01-09 2:18 ` Duy Nguyen 2016-01-11 17:13 ` Junio C Hamano 2 siblings, 1 reply; 26+ messages in thread From: Duy Nguyen @ 2016-01-09 2:18 UTC (permalink / raw) To: Stephen Smith; +Cc: Git Mailing List On Fri, Jan 8, 2016 at 1:04 PM, Stephen Smith <ischis2@cox.net> wrote: >> > +test_expect_success 'ref^{/!-}' ' >> > + test_must_fail git rev-parse master^{/!-} >> > +' Shouldn't it be ^{!/... instead of ^{/!... ? People could have a pattern starting with "!" and /! will change its meaning. On the other hand, anything else after { is still reserved and can safely be used. -- Duy ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation 2016-01-09 2:18 ` Duy Nguyen @ 2016-01-11 17:13 ` Junio C Hamano 0 siblings, 0 replies; 26+ messages in thread From: Junio C Hamano @ 2016-01-11 17:13 UTC (permalink / raw) To: Duy Nguyen; +Cc: Stephen Smith, Git Mailing List Duy Nguyen <pclouds@gmail.com> writes: > On Fri, Jan 8, 2016 at 1:04 PM, Stephen Smith <ischis2@cox.net> wrote: >>> > +test_expect_success 'ref^{/!-}' ' >>> > + test_must_fail git rev-parse master^{/!-} >>> > +' > > Shouldn't it be ^{!/... instead of ^{/!... ? People could have a > pattern starting with "!" and /! will change its meaning. On the other > hand, anything else after { is still reserved and can safely be used. http://thread.gmane.org/gmane.comp.version-control.git/40460/focus=40477 clarifies the above, I think. Back then we seem to have been thinking only about ":" as the overall "search the history to name an object traversing from all tips" prefix, but the current one is described in terms of the more generally useful "<committish>^{/<pattern>}" syntax and the escape hatch applies--they are both handled by get_sha1_oneline() the same way. ^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2016-02-01 21:42 UTC | newest] Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-06-06 0:24 [PATCH v2 0/2] specify commit by negative pattern Will Palmer 2015-06-06 0:24 ` [PATCH v2 1/2] test for '!' handling in rev-parse's named commits Will Palmer 2015-06-06 0:24 ` [PATCH v2 2/2] object name: introduce '^{/!-<negative pattern>}' notation Will Palmer 2015-06-08 16:39 ` Junio C Hamano 2015-06-09 18:14 ` Will Palmer 2015-10-28 17:52 ` Junio C Hamano 2016-01-08 6:04 ` [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation Stephen Smith 2016-01-08 18:21 ` Junio C Hamano 2016-01-10 2:20 ` [PATCH V3 0/2] specify commit by negative pattern Stephen P. Smith 2016-01-10 2:22 ` [PATCH V3 1/2] test for '!' handling in rev-parse's named commits Stephen P. Smith 2016-01-10 2:23 ` [PATCH V3 2/2] object name: introduce '^{/!-<negative pattern>}' notation Stephen P. Smith 2016-01-11 18:10 ` Philip Oakley 2016-01-13 4:51 ` [PATCH V4 0/2] specify commit by negative pattern Stephen P. Smith 2016-01-13 4:51 ` [PATCH V4 1/2] test for '!' handling in rev-parse's named commits Stephen P. Smith 2016-01-13 4:52 ` [PATCH V4 2/2] object name: introduce '^{/!-<negative pattern>}' notation Stephen P. Smith 2016-01-13 19:15 ` Junio C Hamano 2016-01-31 0:06 ` [PATCH V5 " Stephen P. Smith 2016-02-01 21:42 ` Junio C Hamano 2016-01-10 13:25 ` [PATCH V3 0/2] specify commit by negative pattern Philip Oakley 2016-01-11 0:08 ` Stephen P. Smith 2016-01-11 18:04 ` Philip Oakley 2016-01-10 14:14 ` Stephen & Linda Smith 2016-01-10 23:36 ` Philip Oakley 2016-01-09 1:55 ` [PATCH v2 2/2] object name: introduce '^{/!-<negativepattern>}' notation Stephen & Linda Smith 2016-01-09 2:18 ` Duy Nguyen 2016-01-11 17:13 ` Junio C Hamano
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.