• Jeff King's avatar
    archive: handle commits with an empty tree · bd54cf17
    Jeff King authored
    git-archive relies on get_pathspec to convert its argv into
    a list of pathspecs. When get_pathspec is given an empty
    argv list, it returns a single pathspec, the empty string,
    to indicate that everything matches. When we feed this to
    our path_exists function, we typically see that the pathspec
    turns up at least one item in the tree, and we are happy.
    But when our tree is empty, we erroneously think it is
    because the pathspec is too limited, when in fact it is
    simply that there is nothing to be found in the tree. This
    is a weird corner case, but the correct behavior is almost
    certainly to produce an empty archive, not to exit with an
    This patch teaches git-archive to create empty archives when
    there is no pathspec given (we continue to complain if a
    pathspec is given, since it obviously is not matched). It
    also confirms that the tar and zip writers produce sane
    output in this instance.
    Signed-off-by: default avatarJeff King <[email protected]>
    Signed-off-by: default avatarJunio C Hamano <[email protected]>
archive.c 11.9 KB