This repository was archived by the owner on Nov 9, 2017. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -1804,17 +1804,17 @@ static int prepare_lines(struct scoreboard *sb)
1804
1804
static int read_ancestry (const char * graft_file )
1805
1805
{
1806
1806
FILE * fp = fopen (graft_file , "r" );
1807
- char buf [ 1024 ] ;
1807
+ struct strbuf buf = STRBUF_INIT ;
1808
1808
if (!fp )
1809
1809
return -1 ;
1810
- while (fgets ( buf , sizeof ( buf ), fp )) {
1810
+ while (! strbuf_getwholeline ( & buf , fp , '\n' )) {
1811
1811
/* The format is just "Commit Parent1 Parent2 ...\n" */
1812
- int len = strlen (buf );
1813
- struct commit_graft * graft = read_graft_line (buf , len );
1812
+ struct commit_graft * graft = read_graft_line (buf .buf , buf .len );
1814
1813
if (graft )
1815
1814
register_commit_graft (graft , 0 );
1816
1815
}
1817
1816
fclose (fp );
1817
+ strbuf_release (& buf );
1818
1818
return 0 ;
1819
1819
}
1820
1820
Original file line number Diff line number Diff line change @@ -196,19 +196,19 @@ struct commit_graft *read_graft_line(char *buf, int len)
196
196
static int read_graft_file (const char * graft_file )
197
197
{
198
198
FILE * fp = fopen (graft_file , "r" );
199
- char buf [ 1024 ] ;
199
+ struct strbuf buf = STRBUF_INIT ;
200
200
if (!fp )
201
201
return -1 ;
202
- while (fgets ( buf , sizeof ( buf ), fp )) {
202
+ while (! strbuf_getwholeline ( & buf , fp , '\n' )) {
203
203
/* The format is just "Commit Parent1 Parent2 ...\n" */
204
- int len = strlen (buf );
205
- struct commit_graft * graft = read_graft_line (buf , len );
204
+ struct commit_graft * graft = read_graft_line (buf .buf , buf .len );
206
205
if (!graft )
207
206
continue ;
208
207
if (register_commit_graft (graft , 1 ))
209
- error ("duplicate graft data: %s" , buf );
208
+ error ("duplicate graft data: %s" , buf . buf );
210
209
}
211
210
fclose (fp );
211
+ strbuf_release (& buf );
212
212
return 0 ;
213
213
}
214
214
You can’t perform that action at this time.
0 commit comments