worktree: libify should_prune_worktree()
authorRafael Silva <rafaeloliveira.cs@gmail.com>
Tue, 19 Jan 2021 21:27:33 +0000 (22:27 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 30 Jan 2021 17:57:08 +0000 (09:57 -0800)
commita29a8b7574ab34026252691933f462eddc59146a
tree63f26ea5798bce6632dff33f04f949f4f3f8fc92
parent66e871b6647ffea61a77a0f82c7ef3415f1ee79c
worktree: libify should_prune_worktree()

As part of teaching "git worktree list" to annotate worktree that is a
candidate for pruning, let's move should_prune_worktree() from
builtin/worktree.c to worktree.c in order to make part of the worktree
public API.

should_prune_worktree() knows how to select the given worktree for
pruning based on an expiration date, however the expiration value is
stored in a static file-scope variable and it is not local to the
function. In order to move the function, teach should_prune_worktree()
to take the expiration date as an argument and document the new
parameter that is not immediately obvious.

Also, change the function comment to clearly state that the worktree's
path is returned in `wtpath` argument.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Rafael Silva <rafaeloliveira.cs@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/worktree.c
worktree.c
worktree.h