Re: [PATCH] sha1_name.c: update comment to mention :/foo syntax

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] sha1_name.c: update comment to mention :/foo syntax

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:49:35

Matthieu Moy [off-list ref] writes:
quoted
quoted
+	 * :/foo -> last commit whose subject starts with foo
Documenting what hasn't been is a good thing, but is it really up-to-date?

Isn't it "a randomly chosen recent commit whose subject contains regexp
foo" these days?
I don't know.
I was vaguely recalling this one when I wrote the above.

commit 57895105c4ff083d7c9bc59b2b88b9b5176c1915
Author: Linus Torvalds [off-list ref]
Date:   Fri Apr 23 08:20:20 2010 -0700

    Make :/ accept a regex rather than a fixed pattern
    
    This also makes it trigger anywhere in the commit message, rather than
    just at the beginning. Which tends to be a lot more useful.
    
    Signed-off-by: Linus Torvalds [off-list ref]
    Signed-off-by: Junio C Hamano [off-list ref]

[PATCH] update comment and documentation for :/foo syntax

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:49:36

The documentation in revisions.txt did not match the implementation, and
the comment in sha1_name.c was incomplete.

Signed-off-by: Matthieu Moy <redacted>
---
Junio wrote:
Isn't it "a randomly chosen recent commit whose subject contains regexp
foo" these days?
So, that's right. Here's an updated version. I've kept the comment
short and vague, to avoid duplicating the doc, it should be sufficient
as a reminder.

 Documentation/revisions.txt |    4 +++-
 sha1_name.c                 |    1 +
 2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
index fe846f0..3d4b79c 100644
--- a/Documentation/revisions.txt
+++ b/Documentation/revisions.txt
@@ -107,11 +107,13 @@ the `$GIT_DIR/refs` directory or from the `$GIT_DIR/packed-refs` file.
   found.
 
 * A colon, followed by a slash, followed by a text (e.g. `:/fix nasty bug`): this names
-  a commit whose commit message starts with the specified text.
+  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`.
 
 * A suffix ':' followed by a path (e.g. `HEAD:README`); this names the blob or tree
   at the given path in the tree-ish object named by the part
diff --git a/sha1_name.c b/sha1_name.c
index 5470a69..ba95a79 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1062,6 +1062,7 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
 	/* sha1:path --> object name of path in ent sha1
 	 * :path -> object name of path in index
 	 * :[0-3]:path -> object name of path in index at stage
+	 * :/foo -> recent commit matching foo
 	 */
 	if (name[0] == ':') {
 		int stage = 0;
-- 
1.7.3.2.g257b5f
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help