diff options
author | Max Kirillov <max@max630.net> | 2015-03-30 22:47:47 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-03-31 20:02:11 +0200 |
commit | 562bc080934b1bd16099723e80cc82a0dc6356b7 (patch) | |
tree | 8ba6b41358d89bf301ad9c6782088be7a0440024 /builtin/prune.c | |
parent | t1501: fix test with split index (diff) | |
download | git-562bc080934b1bd16099723e80cc82a0dc6356b7.tar.xz git-562bc080934b1bd16099723e80cc82a0dc6356b7.zip |
prune --worktrees: fix expire vs worktree existence condition
`git prune --worktrees` was pruning worktrees which were non-existent OR
expired, while it rather should prune those which are orphaned AND
expired, as git-checkout documentation describes. Fix it.
Add test 'not prune proper checkouts', which uses valid but expired
worktree.
Modify test 'not prune recent checkouts' to remove the worktree before
pruning - link in worktrees still must survive. In older form it is
useless because would pass always when the other test passes.
Signed-off-by: Max Kirillov <max@max630.net>
Acked-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/prune.c')
-rw-r--r-- | builtin/prune.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/builtin/prune.c b/builtin/prune.c index f08670a984..86282b2447 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -120,11 +120,15 @@ static int prune_worktree(const char *id, struct strbuf *reason) if (!stat(git_path("worktrees/%s/link", id), &st_link) && st_link.st_nlink > 1) return 0; - strbuf_addf(reason, _("Removing worktrees/%s: gitdir file points to non-existent location"), id); - return 1; + if (st.st_mtime <= expire) { + strbuf_addf(reason, _("Removing worktrees/%s: gitdir file points to non-existent location"), id); + return 1; + } else { + return 0; + } } free(path); - return st.st_mtime <= expire; + return 0; } static void prune_worktrees(void) |