diff options
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/sha1_name.c b/sha1_name.c index 6fca8692d2..c2c938c4e1 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -819,6 +819,8 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l * For future extension, ':/!' is reserved. If you want to match a message * beginning with a '!', you have to repeat the exclamation mark. */ + +/* Remember to update object flag allocation in object.h */ #define ONELINE_SEEN (1u<<20) static int handle_one_ref(const char *path, @@ -860,27 +862,17 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, commit_list_insert(l->item, &backup); } while (list) { - char *p, *to_free = NULL; + const char *p, *buf; struct commit *commit; - enum object_type type; - unsigned long size; int matches; commit = pop_most_recent_commit(&list, ONELINE_SEEN); if (!parse_object(commit->object.sha1)) continue; - if (commit->buffer) - p = commit->buffer; - else { - p = read_sha1_file(commit->object.sha1, &type, &size); - if (!p) - continue; - to_free = p; - } - - p = strstr(p, "\n\n"); + buf = get_commit_buffer(commit, NULL); + p = strstr(buf, "\n\n"); matches = p && !regexec(®ex, p + 2, 0, NULL, 0); - free(to_free); + unuse_commit_buffer(commit, buf); if (matches) { hashcpy(sha1, commit->object.sha1); |