@@ -776,9 +776,14 @@ void wt_status_collect(struct wt_status *s)
776
776
777
777
void wt_status_collect_free_buffers (struct wt_status * s )
778
778
{
779
- free (s -> state .branch );
780
- free (s -> state .onto );
781
- free (s -> state .detached_from );
779
+ wt_status_state_free_buffers (& s -> state );
780
+ }
781
+
782
+ void wt_status_state_free_buffers (struct wt_status_state * state )
783
+ {
784
+ FREE_AND_NULL (state -> branch );
785
+ FREE_AND_NULL (state -> onto );
786
+ FREE_AND_NULL (state -> detached_from );
782
787
}
783
788
784
789
static void wt_longstatus_print_unmerged (struct wt_status * s )
@@ -1225,7 +1230,7 @@ static int split_commit_in_progress(struct wt_status *s)
1225
1230
* The function assumes that the line does not contain useless spaces
1226
1231
* before or after the command.
1227
1232
*/
1228
- static void abbrev_sha1_in_line (struct strbuf * line )
1233
+ static void abbrev_oid_in_line (struct strbuf * line )
1229
1234
{
1230
1235
struct strbuf * * split ;
1231
1236
int i ;
@@ -1275,7 +1280,7 @@ static int read_rebase_todolist(const char *fname, struct string_list *lines)
1275
1280
strbuf_trim (& line );
1276
1281
if (!line .len )
1277
1282
continue ;
1278
- abbrev_sha1_in_line (& line );
1283
+ abbrev_oid_in_line (& line );
1279
1284
string_list_append (lines , line .buf );
1280
1285
}
1281
1286
fclose (f );
@@ -1568,9 +1573,9 @@ static void wt_status_get_detached_from(struct repository *r,
1568
1573
}
1569
1574
1570
1575
if (dwim_ref (cb .buf .buf , cb .buf .len , & oid , & ref , 1 ) == 1 &&
1571
- /* sha1 is a commit? match without further lookup */
1576
+ /* oid is a commit? match without further lookup */
1572
1577
(oideq (& cb .noid , & oid ) ||
1573
- /* perhaps sha1 is a tag, try to dereference to a commit */
1578
+ /* perhaps oid is a tag, try to dereference to a commit */
1574
1579
((commit = lookup_commit_reference_gently (r , & oid , 1 )) != NULL &&
1575
1580
oideq (& cb .noid , & commit -> object .oid )))) {
1576
1581
const char * from = ref ;
@@ -1799,29 +1804,36 @@ static void wt_longstatus_print(struct wt_status *s)
1799
1804
; /* nothing */
1800
1805
else if (s -> workdir_dirty ) {
1801
1806
if (s -> hints )
1802
- printf (_ ("no changes added to commit "
1803
- "(use \"git add\" and/or \"git commit -a\")\n" ));
1807
+ fprintf (s -> fp , _ ("no changes added to commit "
1808
+ "(use \"git add\" and/or "
1809
+ "\"git commit -a\")\n" ));
1804
1810
else
1805
- printf (_ ("no changes added to commit\n" ));
1811
+ fprintf (s -> fp , _ ("no changes added to "
1812
+ "commit\n" ));
1806
1813
} else if (s -> untracked .nr ) {
1807
1814
if (s -> hints )
1808
- printf (_ ("nothing added to commit but untracked files "
1809
- "present (use \"git add\" to track)\n" ));
1815
+ fprintf (s -> fp , _ ("nothing added to commit but "
1816
+ "untracked files present (use "
1817
+ "\"git add\" to track)\n" ));
1810
1818
else
1811
- printf (_ ("nothing added to commit but untracked files present\n" ));
1819
+ fprintf (s -> fp , _ ("nothing added to commit but "
1820
+ "untracked files present\n" ));
1812
1821
} else if (s -> is_initial ) {
1813
1822
if (s -> hints )
1814
- printf (_ ("nothing to commit (create/copy files "
1815
- "and use \"git add\" to track)\n" ));
1823
+ fprintf (s -> fp , _ ("nothing to commit (create/"
1824
+ "copy files and use \"git "
1825
+ "add\" to track)\n" ));
1816
1826
else
1817
- printf ( _ ("nothing to commit\n" ));
1827
+ fprintf ( s -> fp , _ ("nothing to commit\n" ));
1818
1828
} else if (!s -> show_untracked_files ) {
1819
1829
if (s -> hints )
1820
- printf (_ ("nothing to commit (use -u to show untracked files)\n" ));
1830
+ fprintf (s -> fp , _ ("nothing to commit (use -u to "
1831
+ "show untracked files)\n" ));
1821
1832
else
1822
- printf ( _ ("nothing to commit\n" ));
1833
+ fprintf ( s -> fp , _ ("nothing to commit\n" ));
1823
1834
} else
1824
- printf (_ ("nothing to commit, working tree clean\n" ));
1835
+ fprintf (s -> fp , _ ("nothing to commit, working tree "
1836
+ "clean\n" ));
1825
1837
}
1826
1838
if (s -> show_stash )
1827
1839
wt_longstatus_print_stash_summary (s );
@@ -1844,12 +1856,12 @@ static void wt_shortstatus_unmerged(struct string_list_item *it,
1844
1856
}
1845
1857
color_fprintf (s -> fp , color (WT_STATUS_UNMERGED , s ), "%s" , how );
1846
1858
if (s -> null_termination ) {
1847
- fprintf (stdout , " %s%c" , it -> string , 0 );
1859
+ fprintf (s -> fp , " %s%c" , it -> string , 0 );
1848
1860
} else {
1849
1861
struct strbuf onebuf = STRBUF_INIT ;
1850
1862
const char * one ;
1851
1863
one = quote_path (it -> string , s -> prefix , & onebuf , QUOTE_PATH_QUOTE_SP );
1852
- printf ( " %s\n" , one );
1864
+ fprintf ( s -> fp , " %s\n" , one );
1853
1865
strbuf_release (& onebuf );
1854
1866
}
1855
1867
}
@@ -1862,28 +1874,28 @@ static void wt_shortstatus_status(struct string_list_item *it,
1862
1874
if (d -> index_status )
1863
1875
color_fprintf (s -> fp , color (WT_STATUS_UPDATED , s ), "%c" , d -> index_status );
1864
1876
else
1865
- putchar (' ' );
1877
+ fputc (' ' , s -> fp );
1866
1878
if (d -> worktree_status )
1867
1879
color_fprintf (s -> fp , color (WT_STATUS_CHANGED , s ), "%c" , d -> worktree_status );
1868
1880
else
1869
- putchar (' ' );
1870
- putchar (' ' );
1881
+ fputc (' ' , s -> fp );
1882
+ fputc (' ' , s -> fp );
1871
1883
if (s -> null_termination ) {
1872
- fprintf (stdout , "%s%c" , it -> string , 0 );
1884
+ fprintf (s -> fp , "%s%c" , it -> string , 0 );
1873
1885
if (d -> rename_source )
1874
- fprintf (stdout , "%s%c" , d -> rename_source , 0 );
1886
+ fprintf (s -> fp , "%s%c" , d -> rename_source , 0 );
1875
1887
} else {
1876
1888
struct strbuf onebuf = STRBUF_INIT ;
1877
1889
const char * one ;
1878
1890
1879
1891
if (d -> rename_source ) {
1880
1892
one = quote_path (d -> rename_source , s -> prefix , & onebuf ,
1881
1893
QUOTE_PATH_QUOTE_SP );
1882
- printf ( "%s -> " , one );
1894
+ fprintf ( s -> fp , "%s -> " , one );
1883
1895
strbuf_release (& onebuf );
1884
1896
}
1885
1897
one = quote_path (it -> string , s -> prefix , & onebuf , QUOTE_PATH_QUOTE_SP );
1886
- printf ( "%s\n" , one );
1898
+ fprintf ( s -> fp , "%s\n" , one );
1887
1899
strbuf_release (& onebuf );
1888
1900
}
1889
1901
}
@@ -1892,13 +1904,13 @@ static void wt_shortstatus_other(struct string_list_item *it,
1892
1904
struct wt_status * s , const char * sign )
1893
1905
{
1894
1906
if (s -> null_termination ) {
1895
- fprintf (stdout , "%s %s%c" , sign , it -> string , 0 );
1907
+ fprintf (s -> fp , "%s %s%c" , sign , it -> string , 0 );
1896
1908
} else {
1897
1909
struct strbuf onebuf = STRBUF_INIT ;
1898
1910
const char * one ;
1899
1911
one = quote_path (it -> string , s -> prefix , & onebuf , QUOTE_PATH_QUOTE_SP );
1900
1912
color_fprintf (s -> fp , color (WT_STATUS_UNTRACKED , s ), "%s" , sign );
1901
- printf ( " %s\n" , one );
1913
+ fprintf ( s -> fp , " %s\n" , one );
1902
1914
strbuf_release (& onebuf );
1903
1915
}
1904
1916
}
0 commit comments