Skip to content
  • Duy Nguyen's avatar
    wt-status: move strbuf into read_and_strip_branch() · 8b87cfd0
    Duy Nguyen authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    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: default avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    8b87cfd0