summaryrefslogtreecommitdiff
path: root/builtin-fmt-merge-msg.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin-fmt-merge-msg.c')
-rw-r--r--builtin-fmt-merge-msg.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index 65274824d3..485ede7cad 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -1,3 +1,4 @@
+#include "builtin.h"
#include "cache.h"
#include "commit.h"
#include "diff.h"
@@ -76,6 +77,7 @@ static int handle_line(char *line)
unsigned char *sha1;
char *src, *origin;
struct src_data *src_data;
+ int pulling_head = 0;
if (len < 43 || line[40] != '\t')
return 1;
@@ -101,8 +103,11 @@ static int handle_line(char *line)
if (src) {
*src = 0;
src += 4;
- } else
- src = "HEAD";
+ pulling_head = 0;
+ } else {
+ src = line;
+ pulling_head = 1;
+ }
i = find_in_list(&srcs, src);
if (i < 0) {
@@ -112,7 +117,10 @@ static int handle_line(char *line)
}
src_data = srcs.payload[i];
- if (!strncmp(line, "branch ", 7)) {
+ if (pulling_head) {
+ origin = strdup(src);
+ src_data->head_status |= 1;
+ } else if (!strncmp(line, "branch ", 7)) {
origin = strdup(line + 7);
append_to_list(&src_data->branch, origin, NULL);
src_data->head_status |= 2;
@@ -124,9 +132,6 @@ static int handle_line(char *line)
origin = strdup(line + 14);
append_to_list(&src_data->r_branch, origin, NULL);
src_data->head_status |= 2;
- } else if (!strcmp(line, "HEAD")) {
- origin = strdup(src);
- src_data->head_status |= 1;
} else {
origin = strdup(src);
append_to_list(&src_data->generic, strdup(line), NULL);
@@ -177,7 +182,7 @@ static void shortlog(const char *name, unsigned char *sha1,
int flags = UNINTERESTING | TREECHANGE | SEEN | SHOWN | ADDED;
branch = deref_tag(parse_object(sha1), sha1_to_hex(sha1), 40);
- if (!branch || branch->type != TYPE_COMMIT)
+ if (!branch || branch->type != OBJ_COMMIT)
return;
setup_revisions(0, NULL, rev, NULL);
@@ -238,7 +243,7 @@ static void shortlog(const char *name, unsigned char *sha1,
free_list(&subjects);
}
-int cmd_fmt_merge_msg(int argc, char **argv, char **envp)
+int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
{
int limit = 20, i = 0;
char line[1024];
@@ -338,7 +343,7 @@ int cmd_fmt_merge_msg(int argc, char **argv, char **envp)
struct rev_info rev;
head = lookup_commit(head_sha1);
- init_revisions(&rev);
+ init_revisions(&rev, prefix);
rev.commit_format = CMIT_FMT_ONELINE;
rev.ignore_merges = 1;
rev.limited = 1;