+ commit_formats_len = ARRAY_SIZE(builtin_formats);
+ commit_formats = xmalloc(commit_formats_len *
+ sizeof(*builtin_formats));
+ memcpy(commit_formats, builtin_formats,
+ sizeof(*builtin_formats)*ARRAY_SIZE(builtin_formats));
+}
+
+static struct cmt_fmt_map *find_commit_format(const char *sought)
+{
+ struct cmt_fmt_map *found = NULL;
+ size_t found_match_len = 0;
+ int i;
+
+ if (!commit_formats)
+ setup_commit_formats();
+
+ for (i = 0; i < commit_formats_len; i++) {
+ size_t match_len;
+
+ if (prefixcmp(commit_formats[i].name, sought))
+ continue;
+
+ match_len = strlen(commit_formats[i].name);
+ if (found == NULL || found_match_len > match_len) {
+ found = &commit_formats[i];
+ found_match_len = match_len;
+ }
+ }
+ return found;
+}
+
+void get_commit_format(const char *arg, struct rev_info *rev)
+{
+ struct cmt_fmt_map *commit_format;