summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2019-09-30 13:19:25 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-09-30 13:19:26 +0900
commit991fd97b9ab1d15e11c5c9b867c5e32e4232559b (patch)
tree0553b823008bd245c27c9c151fa9e1b8532db6ef
parentMerge branch 'mh/notes-duplicate-entries' (diff)
parentfast-import: duplicate into history rather than passing ownership (diff)
downloadtgif-991fd97b9ab1d15e11c5c9b867c5e32e4232559b.tar.xz
Merge branch 'jk/fast-import-history-bugfix'
The memory ownership model of the "git fast-import" got straightened out. * jk/fast-import-history-bugfix: fast-import: duplicate into history rather than passing ownership fast-import: duplicate parsed encoding string
-rw-r--r--fast-import.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fast-import.c b/fast-import.c
index b44d6a467e..1f9160b645 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1763,7 +1763,6 @@ static int read_next_command(void)
} else {
struct recent_command *rc;
- strbuf_detach(&command_buf, NULL);
stdin_eof = strbuf_getline_lf(&command_buf, stdin);
if (stdin_eof)
return EOF;
@@ -1784,7 +1783,7 @@ static int read_next_command(void)
free(rc->buf);
}
- rc->buf = command_buf.buf;
+ rc->buf = xstrdup(command_buf.buf);
rc->prev = cmd_tail;
rc->next = cmd_hist.prev;
rc->prev->next = rc;
@@ -1833,7 +1832,6 @@ static int parse_data(struct strbuf *sb, uintmax_t limit, uintmax_t *len_res)
char *term = xstrdup(data);
size_t term_len = command_buf.len - (data - command_buf.buf);
- strbuf_detach(&command_buf, NULL);
for (;;) {
if (strbuf_getline_lf(&command_buf, stdin) == EOF)
die("EOF in data (terminator '%s' not found)", term);
@@ -2588,7 +2586,7 @@ static void parse_new_commit(const char *arg)
struct branch *b;
char *author = NULL;
char *committer = NULL;
- const char *encoding = NULL;
+ char *encoding = NULL;
struct hash_list *merge_list = NULL;
unsigned int merge_count;
unsigned char prev_fanout, new_fanout;
@@ -2611,8 +2609,10 @@ static void parse_new_commit(const char *arg)
}
if (!committer)
die("Expected committer but didn't get one");
- if (skip_prefix(command_buf.buf, "encoding ", &encoding))
+ if (skip_prefix(command_buf.buf, "encoding ", &v)) {
+ encoding = xstrdup(v);
read_next_command();
+ }
parse_data(&msg, 0, NULL);
read_next_command();
parse_from(b);
@@ -2686,6 +2686,7 @@ static void parse_new_commit(const char *arg)
strbuf_addbuf(&new_data, &msg);
free(author);
free(committer);
+ free(encoding);
if (!store_object(OBJ_COMMIT, &new_data, NULL, &b->oid, next_mark))
b->pack_id = pack_id;