@@ -1763,7 +1763,6 @@ static int read_next_command(void)
1763
1763
} else {
1764
1764
struct recent_command * rc ;
1765
1765
1766
- strbuf_detach (& command_buf , NULL );
1767
1766
stdin_eof = strbuf_getline_lf (& command_buf , stdin );
1768
1767
if (stdin_eof )
1769
1768
return EOF ;
@@ -1784,7 +1783,7 @@ static int read_next_command(void)
1784
1783
free (rc -> buf );
1785
1784
}
1786
1785
1787
- rc -> buf = command_buf .buf ;
1786
+ rc -> buf = xstrdup ( command_buf .buf ) ;
1788
1787
rc -> prev = cmd_tail ;
1789
1788
rc -> next = cmd_hist .prev ;
1790
1789
rc -> prev -> next = rc ;
@@ -1833,7 +1832,6 @@ static int parse_data(struct strbuf *sb, uintmax_t limit, uintmax_t *len_res)
1833
1832
char * term = xstrdup (data );
1834
1833
size_t term_len = command_buf .len - (data - command_buf .buf );
1835
1834
1836
- strbuf_detach (& command_buf , NULL );
1837
1835
for (;;) {
1838
1836
if (strbuf_getline_lf (& command_buf , stdin ) == EOF )
1839
1837
die ("EOF in data (terminator '%s' not found)" , term );
@@ -2588,7 +2586,7 @@ static void parse_new_commit(const char *arg)
2588
2586
struct branch * b ;
2589
2587
char * author = NULL ;
2590
2588
char * committer = NULL ;
2591
- const char * encoding = NULL ;
2589
+ char * encoding = NULL ;
2592
2590
struct hash_list * merge_list = NULL ;
2593
2591
unsigned int merge_count ;
2594
2592
unsigned char prev_fanout , new_fanout ;
@@ -2611,8 +2609,10 @@ static void parse_new_commit(const char *arg)
2611
2609
}
2612
2610
if (!committer )
2613
2611
die ("Expected committer but didn't get one" );
2614
- if (skip_prefix (command_buf .buf , "encoding " , & encoding ))
2612
+ if (skip_prefix (command_buf .buf , "encoding " , & v )) {
2613
+ encoding = xstrdup (v );
2615
2614
read_next_command ();
2615
+ }
2616
2616
parse_data (& msg , 0 , NULL );
2617
2617
read_next_command ();
2618
2618
parse_from (b );
@@ -2686,6 +2686,7 @@ static void parse_new_commit(const char *arg)
2686
2686
strbuf_addbuf (& new_data , & msg );
2687
2687
free (author );
2688
2688
free (committer );
2689
+ free (encoding );
2689
2690
2690
2691
if (!store_object (OBJ_COMMIT , & new_data , NULL , & b -> oid , next_mark ))
2691
2692
b -> pack_id = pack_id ;
0 commit comments