| 145 | } |
| 146 | |
| 147 | static struct cmt_fmt_map *find_commit_format_recursive(const char *sought, |
| 148 | const char *original, |
| 149 | int num_redirections) |
| 150 | { |
| 151 | struct cmt_fmt_map *found = NULL; |
| 152 | size_t found_match_len = 0; |
| 153 | int i; |
| 154 | |
| 155 | if (num_redirections >= commit_formats_len) |
| 156 | die("invalid --pretty format: " |
| 157 | "'%s' references an alias which points to itself", |
| 158 | original); |
| 159 | |
| 160 | for (i = 0; i < commit_formats_len; i++) { |
| 161 | size_t match_len; |
| 162 | |
| 163 | if (!istarts_with(commit_formats[i].name, sought)) |
| 164 | continue; |
| 165 | |
| 166 | match_len = strlen(commit_formats[i].name); |
| 167 | if (found == NULL || found_match_len > match_len) { |
| 168 | found = &commit_formats[i]; |
| 169 | found_match_len = match_len; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | if (found && found->is_alias) { |
| 174 | found = find_commit_format_recursive(found->user_format, |
| 175 | original, |
| 176 | num_redirections+1); |
| 177 | } |
| 178 | |
| 179 | return found; |
| 180 | } |
| 181 | |
| 182 | static struct cmt_fmt_map *find_commit_format(const char *sought) |
| 183 | { |
no test coverage detected