git worktree prune improvements
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest3 patches 3 repliesIn review
- v13 patches 4 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | gc.txt: more details about what gc doesDocumentation/ | +19 | 0 replies | |
| 2/3 | worktree: delete dead codeDocumentation/ builtin/ | +0 | 1 reply | |
| 3/3 | worktree prune: improve prune logic when worktree is movedbuiltin/ t/ | +5 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/3] git worktree prune improvements
v2 fixes comments from Eric and rebases on 'master' since 'worktree move' has been merged. Commit messages are updated to reflect this.
There's one thing I didn't do is moving the new paragraph up [1]. I still feel this it's not right to put it there since it starts with 'gc --auto' introduction, then goes to loose objects and packs. Inserting a note between the loose objects paragraph and the packs one does not make much sense.
Interdiff
-- 8< --
Documentation/git-gc.txt +16 -14
@@ -17,7 +17,7 @@ Runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance), removing unreachable objects which may have been created from prior invocations of 'git add', packing refs, pruning -reflog, rerere or stale working trees. +reflog, rerere metadata or stale working trees. Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good
@@ -46,14 +46,14 @@ OPTIONS With this option, 'git gc' checks whether any housekeeping is required; if not, it exits without performing any work. Some git commands run `git gc --auto` after performing - operations that could create many loose objects. + operations that could create many loose objects. Housekeeping + is required if there are too many loose objects or too many + packs in the repository. + -Housekeeping is required if there are too many loose objects or -too many packs in the repository. If the number of loose objects -exceeds the value of the `gc.auto` configuration variable, then -all loose objects are combined into a single pack using -`git repack -d -l`. Setting the value of `gc.auto` to 0 -disables automatic packing of loose objects. +If the number of loose objects exceeds the value of the `gc.auto` +configuration variable, then all loose objects are combined into a +single pack using `git repack -d -l`. Setting the value of `gc.auto` +to 0 disables automatic packing of loose objects. + If the number of packs exceeds the value of `gc.autoPackLimit`, then existing packs (except those marked with a `.keep` file)
@@ -61,9 +61,10 @@ are consolidated into a single pack by using the `-A` option of 'git repack'. Setting `gc.autoPackLimit` to 0 disables automatic consolidation of packs. + -If `git gc --auto` goes ahead because of either too loose objects or -packs, all other housekeeping tasks (e.g. rerere, working trees, -reflog...) will also be be performed. +If houskeeping is required due to many loose objects or packs, all +other housekeeping tasks (e.g. rerere, working trees, reflog...) will +be performed as well. + --prune=<date>:: Prune loose objects older than date (default is 2 weeks ago,
@@ -138,9 +139,10 @@ The optional configuration variable `gc.pruneExpire` controls how old the unreferenced loose objects have to be before they are pruned. The default is "2 weeks ago". -The optional gc.worktreePruneExpire controls how old a stale working -tree before `git worktree prune` deletes it. The default is "3 months -ago". +Optional configuration variable `gc.worktreePruneExpire` controls how +old a stale working tree should be before `git worktree prune` deletes +it. Default is "3 months ago". + Notes -----
builtin/worktree.c +2 -4
@@ -100,10 +100,8 @@ static int prune_worktree(const char *id, struct strbuf *reason) path[len] ='\0' ;if (!file_exists (path)) {free (path); -if (st.st_mtime <= expire) { -if (!stat (git_path ("worktrees/%s/index" , id), &st) && - st.st_mtime > expire) -return 0 ; +if (stat (git_path ("worktrees/%s/index" , id), &st) || + st.st_mtime <= expire) {strbuf_addf (reason,_ ("Removing worktrees/%s: gitdir file points to non-existent location" ), id);return 1 ; }else {
t/t2026-worktree-prune.sh +3 -4
@@ -78,10 +78,9 @@ test_expect_success 'not prune locked checkout' ' test_expect_success 'not prune recent checkouts' ' test_when_finished rm -r .git/worktrees && - mkdir zz && - mkdir -p .git/worktrees/jlm && - echo "$(pwd)"/zz >.git/worktrees/jlm/gitdir && - rmdir zz && + git worktree add jlm HEAD && + test -d .git/worktrees/jlm && + rm -rf jlm && git worktree prune --verbose --expire=2.days.ago && test -d .git/worktrees/jlm '
-- 8< --
[1] https://public-inbox.org/git/CAPig+cSo_n7y3-qDT92+NYspTB+yF+NUL19MLvfztLJ_qZhXnw@mail.gmail.com/
Nguyễn Thái Ngọc Duy (3):
gc.txt: more details about what gc does
worktree: delete dead code
worktree prune: improve prune logic when worktree is moved
Documentation/git-gc.txt | 28 +++++++++++++++++--------- Documentation/gitrepository-layout.txt | 5 ----- builtin/worktree.c | 11 ++-------- t/t2026-worktree-prune.sh | 7 +++---- 4 files changed, 24 insertions(+), 27 deletions(-)
Signature · 1 line
2.16.2.903.gd04caf5039