Skip to content

Commit 766cb89

Browse files
committed
Merge pull request #301: Update 'git maintenance' to match upstream
This PR updates our `vfs-2.29.0` branch's version of `git maintenance` to match the latest in upstream. Unfortunately, not all of these commits made it to the `2.30` release candidate, but there are more commits from the series making it in. They will cause a conflict in the `vfs-2.30.0` rebase, so merge them in here. This also includes the `fixup!` reverts of the earlier versions. Finally, I also noticed that we started depending on `git maintenance start` in Scalar for macOS, but we never checked that this worked with the shared object cache. It doesn't! 😨 The very tip commit of this PR includes logic to make `git maintenance run` care about `gvfs.sharedCache`. Functional test updates in Scalar will follow.
2 parents 0c1d089 + 26cf4d5 commit 766cb89

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Update Homebrew Tap
2+
on:
3+
release:
4+
types: [released]
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- id: version
11+
name: Compute version number
12+
run: |
13+
echo "::set-output name=result::$(echo $GITHUB_REF | sed -e "s/^refs\/tags\/v//")"
14+
- id: hash
15+
name: Compute release asset hash
16+
uses: mjcheetham/asset-hash@v1
17+
with:
18+
asset: /git-(.*)\.pkg/
19+
hash: sha256
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
- name: Update scalar Cask
22+
uses: mjcheetham/[email protected]
23+
with:
24+
token: ${{ secrets.HOMEBREW_TOKEN }}
25+
tap: microsoft/git
26+
name: microsoft-git
27+
type: cask
28+
version: ${{ steps.version.outputs.result }}
29+
sha256: ${{ steps.hash.outputs.result }}
30+
alwaysUsePullRequest: true

builtin/gc.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -995,18 +995,23 @@ static int write_loose_object_to_stdin(const struct object_id *oid,
995995
return ++(d->count) > d->batch_size;
996996
}
997997

998+
static const char *object_dir = NULL;
999+
9981000
static int pack_loose(struct maintenance_run_opts *opts)
9991001
{
10001002
struct repository *r = the_repository;
10011003
int result = 0;
10021004
struct write_loose_object_data data;
10031005
struct child_process pack_proc = CHILD_PROCESS_INIT;
10041006

1007+
if (!object_dir)
1008+
object_dir = r->objects->odb->path;
1009+
10051010
/*
10061011
* Do not start pack-objects process
10071012
* if there are no loose objects.
10081013
*/
1009-
if (!for_each_loose_file_in_objdir(r->objects->odb->path,
1014+
if (!for_each_loose_file_in_objdir(object_dir,
10101015
bail_on_loose,
10111016
NULL, NULL, NULL))
10121017
return 0;
@@ -1016,7 +1021,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
10161021
strvec_push(&pack_proc.args, "pack-objects");
10171022
if (opts->quiet)
10181023
strvec_push(&pack_proc.args, "--quiet");
1019-
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->odb->path);
1024+
strvec_pushf(&pack_proc.args, "%s/pack/loose", object_dir);
10201025

10211026
pack_proc.in = -1;
10221027

@@ -1029,7 +1034,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
10291034
data.count = 0;
10301035
data.batch_size = 50000;
10311036

1032-
for_each_loose_file_in_objdir(r->objects->odb->path,
1037+
for_each_loose_file_in_objdir(object_dir,
10331038
write_loose_object_to_stdin,
10341039
NULL,
10351040
NULL,
@@ -1440,6 +1445,16 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
14401445
if (argc != 0)
14411446
usage_with_options(builtin_maintenance_run_usage,
14421447
builtin_maintenance_run_options);
1448+
1449+
/*
1450+
* To enable the VFS for Git/Scalar shared object cache, use
1451+
* the gvfs.sharedcache config option to redirect the
1452+
* maintenance to that location.
1453+
*/
1454+
if (!git_config_get_value("gvfs.sharedcache", &object_dir) &&
1455+
object_dir)
1456+
setenv(DB_ENVIRONMENT, object_dir, 1);
1457+
14431458
return maintenance_run_tasks(&opts);
14441459
}
14451460

0 commit comments

Comments
 (0)