]> git.ipfire.org Git - thirdparty/git.git/commit - wt-status.c
wt-status: move strbuf into read_and_strip_branch()
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 16 Mar 2013 02:12:36 +0000 (09:12 +0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 17 Mar 2013 05:10:32 +0000 (22:10 -0700)
commit8b87cfd000c7c98f58279cff698f6e8c7892c059
tree377bf80b612912dca6462e9b10ec06f7dd0a2651
parentcdd76db373c23bbd637c76a605b3e7f571500103
wt-status: move strbuf into read_and_strip_branch()

The strbufs are placed outside read_and_strip_branch as a premature
optimization: when it reads "refs/heads/foo" to strbuf and wants to
return just "foo", it could do so without memory movement. In return
the caller must not use the returned pointer after releasing strbufs,
which own the buffers that contain the returned strings. It's a clumsy
design.

By moving strbufs into read_and_strip_branch(), the returned pointer
always points to a malloc'd buffer or NULL. The pointer can be passed
around and freed after use.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
wt-status.c
wt-status.h