Skip to content

Commit

Permalink
Merge pull request #301: Update 'git maintenance' to match upstream
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
derrickstolee committed Oct 31, 2021
2 parents 6e0ef24 + 242640e commit 5378e83
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/release-homebrew.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Update Homebrew Tap
on:
release:
types: [released]

jobs:
release:
runs-on: ubuntu-latest
steps:
- id: version
name: Compute version number
run: |
echo "::set-output name=result::$(echo $GITHUB_REF | sed -e "s/^refs\/tags\/v//")"
- id: hash
name: Compute release asset hash
uses: mjcheetham/asset-hash@v1
with:
asset: /git-(.*)\.pkg/
hash: sha256
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update scalar Cask
uses: mjcheetham/update-homebrew@v1.1
with:
token: ${{ secrets.HOMEBREW_TOKEN }}
tap: microsoft/git
name: microsoft-git
type: cask
version: ${{ steps.version.outputs.result }}
sha256: ${{ steps.hash.outputs.result }}
alwaysUsePullRequest: true
21 changes: 18 additions & 3 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,18 +995,23 @@ static int write_loose_object_to_stdin(const struct object_id *oid,
return ++(d->count) > d->batch_size;
}

static const char *object_dir = NULL;

static int pack_loose(struct maintenance_run_opts *opts)
{
struct repository *r = the_repository;
int result = 0;
struct write_loose_object_data data;
struct child_process pack_proc = CHILD_PROCESS_INIT;

if (!object_dir)
object_dir = r->objects->odb->path;

/*
* Do not start pack-objects process
* if there are no loose objects.
*/
if (!for_each_loose_file_in_objdir(r->objects->odb->path,
if (!for_each_loose_file_in_objdir(object_dir,
bail_on_loose,
NULL, NULL, NULL))
return 0;
Expand All @@ -1016,7 +1021,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
strvec_push(&pack_proc.args, "pack-objects");
if (opts->quiet)
strvec_push(&pack_proc.args, "--quiet");
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->odb->path);
strvec_pushf(&pack_proc.args, "%s/pack/loose", object_dir);

pack_proc.in = -1;

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

for_each_loose_file_in_objdir(r->objects->odb->path,
for_each_loose_file_in_objdir(object_dir,
write_loose_object_to_stdin,
NULL,
NULL,
Expand Down Expand Up @@ -1441,6 +1446,16 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
if (argc != 0)
usage_with_options(builtin_maintenance_run_usage,
builtin_maintenance_run_options);

/*
* To enable the VFS for Git/Scalar shared object cache, use
* the gvfs.sharedcache config option to redirect the
* maintenance to that location.
*/
if (!git_config_get_value("gvfs.sharedcache", &object_dir) &&
object_dir)
setenv(DB_ENVIRONMENT, object_dir, 1);

return maintenance_run_tasks(&opts);
}

Expand Down

0 comments on commit 5378e83

Please sign in to comment.