Skip to content

Commit

Permalink
Merge pull request #498: multi-pack-index: use real paths for --objec…
Browse files Browse the repository at this point in the history
…t-dir

This resolves #497.

Looking at this, it seems that VFS for Git users have not been getting all of the benefits of background maintenance for quite some time. This will probably justify a `v2.36.0.vfs.0.1` release for those users. We should wait for upstream feedback, first. I will prepare an upstream patch soon.
  • Loading branch information
derrickstolee authored and vdye committed May 11, 2022
2 parents dc356b7 + e974d8f commit c6886cd
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 19 deletions.
5 changes: 3 additions & 2 deletions .github/scripts/sign-debian-packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

esrp_tool = os.path.join("esrp", "tools", "EsrpClient.exe")

AAD_ID = "6db94d07-8532-429f-9080-5e889a85873c"
AAD_ID = os.environ['AZURE_AAD_ID'].strip()
AAD_ID_TEMP = os.environ['AZURE_AAD_ID_TEMP'].strip()
WORKSPACE = os.environ['GITHUB_WORKSPACE'].strip()
ARTIFACTS_DIR = os.environ['ARTIFACTS_DIR'].strip()

Expand All @@ -32,7 +33,7 @@ def main():
"TenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"ClientId": AAD_ID,
"AuthCert": {
"SubjectName": f"CN={AAD_ID}.microsoft.com",
"SubjectName": f"CN={AAD_ID_TEMP}.microsoft.com",
"StoreLocation": "LocalMachine",
"StoreName": "My",
},
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/build-git-installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,12 @@ jobs:
Import-PfxCertificate request_signing_cert.pfx -CertStoreLocation Cert:\LocalMachine\My
- uses: actions/setup-python@v2
- name: Run ESRP client
env:
AZURE_AAD_ID: ${{ secrets.AZURE_AAD_ID }}
# We temporarily need two AAD IDs, as we're using an SSL certificate associated
# with an older App Registration until we have the required hardware to approve
# the new certificate in SSL Admin.
AZURE_AAD_ID_TEMP: ${{ secrets.AAD_ID_TEMP }}
run: python .github/scripts/sign-debian-packages.py
- name: Upload signed artifact
uses: actions/upload-artifact@v2
Expand Down
45 changes: 34 additions & 11 deletions builtin/multi-pack-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,31 @@ static char const * const builtin_multi_pack_index_usage[] = {
};

static struct opts_multi_pack_index {
const char *object_dir;
char *object_dir;
const char *preferred_pack;
const char *refs_snapshot;
unsigned long batch_size;
unsigned flags;
int stdin_packs;
} opts;


static int parse_object_dir(const struct option *opt, const char *arg,
int unset)
{
free(opts.object_dir);
if (unset)
opts.object_dir = xstrdup(get_object_directory());
else
opts.object_dir = real_pathdup(arg, 1);
return 0;
}

static struct option common_opts[] = {
OPT_FILENAME(0, "object-dir", &opts.object_dir,
N_("object directory containing set of packfile and pack-index pairs")),
OPT_CALLBACK(0, "object-dir", &opts.object_dir,
N_("directory"),
N_("object directory containing set of packfile and pack-index pairs"),
parse_object_dir),
OPT_END(),
};

Expand Down Expand Up @@ -232,31 +246,40 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv)
int cmd_multi_pack_index(int argc, const char **argv,
const char *prefix)
{
int res;
struct option *builtin_multi_pack_index_options = common_opts;

git_config(git_default_config, NULL);

if (the_repository &&
the_repository->objects &&
the_repository->objects->odb)
opts.object_dir = xstrdup(the_repository->objects->odb->path);

argc = parse_options(argc, argv, prefix,
builtin_multi_pack_index_options,
builtin_multi_pack_index_usage,
PARSE_OPT_STOP_AT_NON_OPTION);

if (!opts.object_dir)
opts.object_dir = get_object_directory();

if (!argc)
goto usage;

if (!strcmp(argv[0], "repack"))
return cmd_multi_pack_index_repack(argc, argv);
res = cmd_multi_pack_index_repack(argc, argv);
else if (!strcmp(argv[0], "write"))
return cmd_multi_pack_index_write(argc, argv);
res = cmd_multi_pack_index_write(argc, argv);
else if (!strcmp(argv[0], "verify"))
return cmd_multi_pack_index_verify(argc, argv);
res = cmd_multi_pack_index_verify(argc, argv);
else if (!strcmp(argv[0], "expire"))
return cmd_multi_pack_index_expire(argc, argv);
res = cmd_multi_pack_index_expire(argc, argv);
else {
error(_("unrecognized subcommand: %s"), argv[0]);
goto usage;
}

free(opts.object_dir);
return res;

error(_("unrecognized subcommand: %s"), argv[0]);
usage:
usage_with_options(builtin_multi_pack_index_usage,
builtin_multi_pack_index_options);
Expand Down
2 changes: 1 addition & 1 deletion cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ extern char *git_work_tree_cfg;
int is_inside_work_tree(void);
const char *get_git_dir(void);
const char *get_git_common_dir(void);
char *get_object_directory(void);
const char *get_object_directory(void);
char *get_index_file(void);
char *get_graft_file(struct repository *r);
void set_git_dir(const char *path, int make_realpath);
Expand Down
2 changes: 1 addition & 1 deletion environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const char *get_git_work_tree(void)
return the_repository->worktree;
}

char *get_object_directory(void)
const char *get_object_directory(void)
{
if (!the_repository->objects->odb)
BUG("git environment hasn't been setup");
Expand Down
17 changes: 13 additions & 4 deletions midx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,17 +1132,26 @@ static int write_midx_bitmap(char *midx_name, unsigned char *midx_hash,
static struct multi_pack_index *lookup_multi_pack_index(struct repository *r,
const char *object_dir)
{
struct multi_pack_index *result = NULL;
struct multi_pack_index *cur;
char *obj_dir_real = real_pathdup(object_dir, 1);
struct strbuf cur_path_real = STRBUF_INIT;

/* Ensure the given object_dir is local, or a known alternate. */
find_odb(r, object_dir);
find_odb(r, obj_dir_real);

for (cur = get_multi_pack_index(r); cur; cur = cur->next) {
if (!strcmp(object_dir, cur->object_dir))
return cur;
strbuf_realpath(&cur_path_real, cur->object_dir, 1);
if (!strcmp(obj_dir_real, cur_path_real.buf)) {
result = cur;
goto cleanup;
}
}

return NULL;
cleanup:
free(obj_dir_real);
strbuf_release(&cur_path_real);
return result;
}

static int write_midx_internal(const char *object_dir,
Expand Down

0 comments on commit c6886cd

Please sign in to comment.