static int get_message(struct commit *commit, struct commit_message *out) { const char *abbrev, *subject; int abbrev_len, subject_len; char *q; if (!git_commit_encoding) git_commit_encoding = "UTF-8"; out->message = logmsg_reencode(commit, NULL, git_commit_encoding); abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV); abbrev_len = strlen(abbrev); subject_len = find_commit_subject(out->message, &subject); out->parent_label = xmalloc(strlen("parent of ") + abbrev_len + strlen("... ") + subject_len + 1); q = out->parent_label; q = mempcpy(q, "parent of ", strlen("parent of ")); out->label = q; q = mempcpy(q, abbrev, abbrev_len); q = mempcpy(q, "... ", strlen("... ")); out->subject = q; q = mempcpy(q, subject, subject_len); *q = '\0'; return 0; }
static void get_commit_info(struct commit *commit, struct commit_info *ret, int detailed) { int len; const char *subject, *encoding; const char *message; commit_info_init(ret); encoding = get_log_output_encoding(); message = logmsg_reencode(commit, NULL, encoding); get_ac_line(message, "\nauthor ", &ret->author, &ret->author_mail, &ret->author_time, &ret->author_tz); if (!detailed) { unuse_commit_buffer(commit, message); return; } get_ac_line(message, "\ncommitter ", &ret->committer, &ret->committer_mail, &ret->committer_time, &ret->committer_tz); len = find_commit_subject(message, &subject); if (len) strbuf_add(&ret->summary, subject, len); else strbuf_addf(&ret->summary, "(%s)", oid_to_hex(&commit->object.oid)); unuse_commit_buffer(commit, message); }
static int walk_revs_populate_todo(struct todo_list *todo_list, struct replay_opts *opts) { enum todo_command command = opts->action == REPLAY_PICK ? TODO_PICK : TODO_REVERT; const char *command_string = todo_command_strings[command]; struct commit *commit; if (prepare_revs(opts)) return -1; while ((commit = get_revision(opts->revs))) { struct todo_item *item = append_new_todo(todo_list); const char *commit_buffer = get_commit_buffer(commit, NULL); const char *subject; int subject_len; item->command = command; item->commit = commit; item->arg = NULL; item->arg_len = 0; item->offset_in_buf = todo_list->buf.len; subject_len = find_commit_subject(commit_buffer, &subject); strbuf_addf(&todo_list->buf, "%s %s %.*s\n", command_string, short_commit_name(commit), subject_len, subject); unuse_commit_buffer(commit, commit_buffer); } return 0; }
static int get_message(struct commit *commit, struct commit_message *out) { const char *abbrev, *subject; int subject_len; out->message = logmsg_reencode(commit, NULL, get_commit_output_encoding()); abbrev = find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV); subject_len = find_commit_subject(out->message, &subject); out->subject = xmemdupz(subject, subject_len); out->label = xstrfmt("%s... %s", abbrev, out->subject); out->parent_label = xstrfmt("parent of %s", out->label); return 0; }
static int format_todo(struct strbuf *buf, struct commit_list *todo_list, struct replay_opts *opts) { struct commit_list *cur = NULL; const char *sha1_abbrev = NULL; const char *action_str = opts->action == REPLAY_REVERT ? "revert" : "pick"; const char *subject; int subject_len; for (cur = todo_list; cur; cur = cur->next) { sha1_abbrev = find_unique_abbrev(cur->item->object.sha1, DEFAULT_ABBREV); subject_len = find_commit_subject(cur->item->buffer, &subject); strbuf_addf(buf, "%s %s %.*s\n", action_str, sha1_abbrev, subject_len, subject); } return 0; }
static int get_message(const char *raw_message, struct commit_message *out) { const char *encoding; const char *abbrev, *subject; int abbrev_len, subject_len; char *q; if (!raw_message) return -1; encoding = get_encoding(raw_message); if (!encoding) encoding = "UTF-8"; if (!git_commit_encoding) git_commit_encoding = "UTF-8"; out->reencoded_message = NULL; out->message = raw_message; if (strcmp(encoding, git_commit_encoding)) out->reencoded_message = reencode_string(raw_message, git_commit_encoding, encoding); if (out->reencoded_message) out->message = out->reencoded_message; else out->message = raw_message; abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV); abbrev_len = strlen(abbrev); subject_len = find_commit_subject(out->message, &subject); out->parent_label = xmalloc(strlen("parent of ") + abbrev_len + strlen("... ") + subject_len + 1); q = out->parent_label; q = mempcpy(q, "parent of ", strlen("parent of ")); out->label = q; q = mempcpy(q, abbrev, abbrev_len); q = mempcpy(q, "... ", strlen("... ")); out->subject = q; q = mempcpy(q, subject, subject_len); *q = '\0'; return 0; }
static void show_list(const char *debug, int counted, int nr, struct commit_list *list) { struct commit_list *p; fprintf(stderr, "%s (%d/%d)\n", debug, counted, nr); for (p = list; p; p = p->next) { struct commit_list *pp; struct commit *commit = p->item; unsigned flags = commit->object.flags; enum object_type type; unsigned long size; char *buf = read_sha1_file(commit->object.sha1, &type, &size); const char *subject_start; int subject_len; fprintf(stderr, "%c%c%c ", (flags & TREESAME) ? ' ' : 'T', (flags & UNINTERESTING) ? 'U' : ' ', (flags & COUNTED) ? 'C' : ' '); if (commit->util) fprintf(stderr, "%3d", weight(p)); else fprintf(stderr, "---"); fprintf(stderr, " %.*s", 8, sha1_to_hex(commit->object.sha1)); for (pp = commit->parents; pp; pp = pp->next) fprintf(stderr, " %.*s", 8, sha1_to_hex(pp->item->object.sha1)); subject_len = find_commit_subject(buf, &subject_start); if (subject_len) fprintf(stderr, " %.*s", subject_len, subject_start); fprintf(stderr, "\n"); } }