fmt-merge-msg: refactor merge title formatting
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
2234ec5422
commit
403994e83d
|
@ -202,36 +202,10 @@ static void shortlog(const char *name, unsigned char *sha1,
|
||||||
string_list_clear(&subjects, 0);
|
string_list_clear(&subjects, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_fmt_merge_msg(int merge_summary, struct strbuf *in,
|
static void do_fmt_merge_msg_title(struct strbuf *out,
|
||||||
struct strbuf *out) {
|
const char *current_branch) {
|
||||||
int limit = 20, i = 0, pos = 0;
|
int i = 0;
|
||||||
char *sep = "";
|
char *sep = "";
|
||||||
unsigned char head_sha1[20];
|
|
||||||
const char *current_branch;
|
|
||||||
|
|
||||||
/* get current branch */
|
|
||||||
current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
|
|
||||||
if (!current_branch)
|
|
||||||
die("No current branch");
|
|
||||||
if (!prefixcmp(current_branch, "refs/heads/"))
|
|
||||||
current_branch += 11;
|
|
||||||
|
|
||||||
/* get a line */
|
|
||||||
while (pos < in->len) {
|
|
||||||
int len;
|
|
||||||
char *newline, *p = in->buf + pos;
|
|
||||||
|
|
||||||
newline = strchr(p, '\n');
|
|
||||||
len = newline ? newline - p : strlen(p);
|
|
||||||
pos += len + !!newline;
|
|
||||||
i++;
|
|
||||||
p[len] = 0;
|
|
||||||
if (handle_line(p))
|
|
||||||
die ("Error in line %d: %.*s", i, len, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!srcs.nr)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
strbuf_addstr(out, "Merge ");
|
strbuf_addstr(out, "Merge ");
|
||||||
for (i = 0; i < srcs.nr; i++) {
|
for (i = 0; i < srcs.nr; i++) {
|
||||||
|
@ -279,6 +253,39 @@ static int do_fmt_merge_msg(int merge_summary, struct strbuf *in,
|
||||||
strbuf_addch(out, '\n');
|
strbuf_addch(out, '\n');
|
||||||
else
|
else
|
||||||
strbuf_addf(out, " into %s\n", current_branch);
|
strbuf_addf(out, " into %s\n", current_branch);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int do_fmt_merge_msg(int merge_summary, struct strbuf *in,
|
||||||
|
struct strbuf *out) {
|
||||||
|
int limit = 20, i = 0, pos = 0;
|
||||||
|
unsigned char head_sha1[20];
|
||||||
|
const char *current_branch;
|
||||||
|
|
||||||
|
/* get current branch */
|
||||||
|
current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
|
||||||
|
if (!current_branch)
|
||||||
|
die("No current branch");
|
||||||
|
if (!prefixcmp(current_branch, "refs/heads/"))
|
||||||
|
current_branch += 11;
|
||||||
|
|
||||||
|
/* get a line */
|
||||||
|
while (pos < in->len) {
|
||||||
|
int len;
|
||||||
|
char *newline, *p = in->buf + pos;
|
||||||
|
|
||||||
|
newline = strchr(p, '\n');
|
||||||
|
len = newline ? newline - p : strlen(p);
|
||||||
|
pos += len + !!newline;
|
||||||
|
i++;
|
||||||
|
p[len] = 0;
|
||||||
|
if (handle_line(p))
|
||||||
|
die ("Error in line %d: %.*s", i, len, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!srcs.nr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
do_fmt_merge_msg_title(out, current_branch);
|
||||||
|
|
||||||
if (merge_summary) {
|
if (merge_summary) {
|
||||||
struct commit *head;
|
struct commit *head;
|
||||||
|
|
Loading…
Reference in New Issue