Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Make :/ accept a regex rather than a fixed pattern
author
Linus Torvalds
<torvalds@linux-foundation.org>
Fri, 23 Apr 2010 15:20:20 +0000
(08:20 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 14 Jun 2010 17:31:11 +0000
(10:31 -0700)
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 <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
6339f67
)
diff --git
a/sha1_name.c
b/sha1_name.c
index bf924178380c42a50b2fd7a02ff869dcc3ddff6a..8cf635af54568ce09685e79560d0038b3262f842 100644
(file)
--- a/
sha1_name.c
+++ b/
sha1_name.c
@@
-679,8
+679,8
@@
static int handle_one_ref(const char *path,
/*
* This interprets names like ':/Initial revision of "git"' by searching
/*
* This interprets names like ':/Initial revision of "git"' by searching
- * through history and returning the first commit whose message
start
s
- *
with the given string
.
+ * through history and returning the first commit whose message
matche
s
+ *
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 future extension, ':/!' is reserved. If you want to match a message
* beginning with a '!', you have to repeat the exclamation mark.
@@
-692,12
+692,17
@@
static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
struct commit_list *list = NULL, *backup = NULL, *l;
int retval = -1;
char *temp_commit_buffer = NULL;
struct commit_list *list = NULL, *backup = NULL, *l;
int retval = -1;
char *temp_commit_buffer = NULL;
+ regex_t regex;
if (prefix[0] == '!') {
if (prefix[1] != '!')
die ("Invalid search pattern: %s", prefix);
prefix++;
}
if (prefix[0] == '!') {
if (prefix[1] != '!')
die ("Invalid search pattern: %s", prefix);
prefix++;
}
+
+ if (regcomp(®ex, prefix, REG_EXTENDED))
+ die("Invalid search pattern: %s", prefix);
+
for_each_ref(handle_one_ref, &list);
for (l = list; l; l = l->next)
commit_list_insert(l->item, &backup);
for_each_ref(handle_one_ref, &list);
for (l = list; l; l = l->next)
commit_list_insert(l->item, &backup);
@@
-721,12
+726,13
@@
static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
}
if (!(p = strstr(p, "\n\n")))
continue;
}
if (!(p = strstr(p, "\n\n")))
continue;
- if (!
prefixcmp(p + 2, prefix
)) {
+ if (!
regexec(®ex, p + 2, 0, NULL, 0
)) {
hashcpy(sha1, commit->object.sha1);
retval = 0;
break;
}
}
hashcpy(sha1, commit->object.sha1);
retval = 0;
break;
}
}
+ regfree(®ex);
free(temp_commit_buffer);
free_commit_list(list);
for (l = backup; l; l = l->next)
free(temp_commit_buffer);
free_commit_list(list);
for (l = backup; l; l = l->next)