• Johannes Schindelin's avatar
    real_pathdup(): fix callsites that wanted it to die on error · ce83eadd
    Johannes Schindelin authored
    In 4ac9006f (real_path: have callers use real_pathdup and
    strbuf_realpath, 2016-12-12), we changed the xstrdup(real_path())
    pattern to use real_pathdup() directly.
    The problem with this change is that real_path() calls
    strbuf_realpath() with die_on_error = 1 while real_pathdup() calls
    it with die_on_error = 0. Meaning that in cases where real_path()
    causes Git to die() with an error message, real_pathdup() is silent
    and returns NULL instead.
    The callers, however, are ill-prepared for that change, as they expect
    the return value to be non-NULL (and otherwise the function died
    with an appropriate error message).
    Fix this by extending real_pathdup()'s signature to accept the
    die_on_error flag and simply pass it through to strbuf_realpath(),
    and then adjust all callers after a careful audit whether they would
    handle NULLs well.
    Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
worktree.c 10.2 KB