Skip to content

Commit

Permalink
Merge branch 'sb/object-store-grafts' into sb/object-store-lookup
Browse files Browse the repository at this point in the history
* sb/object-store-grafts:
  commit: allow lookup_commit_graft to handle arbitrary repositories
  commit: allow prepare_commit_graft to handle arbitrary repositories
  shallow: migrate shallow information into the object parser
  path.c: migrate global git_path_* to take a repository argument
  cache: convert get_graft_file to handle arbitrary repositories
  commit: convert read_graft_file to handle arbitrary repositories
  commit: convert register_commit_graft to handle arbitrary repositories
  commit: convert commit_graft_pos() to handle arbitrary repositories
  shallow: add repository argument to is_repository_shallow
  shallow: add repository argument to check_shallow_file_for_update
  shallow: add repository argument to register_shallow
  shallow: add repository argument to set_alternate_shallow_file
  commit: add repository argument to lookup_commit_graft
  commit: add repository argument to prepare_commit_graft
  commit: add repository argument to read_graft_file
  commit: add repository argument to register_commit_graft
  commit: add repository argument to commit_graft_pos
  object: move grafts to object parser
  object-store: move object access functions to object-store.h
  • Loading branch information
gitster committed Jun 29, 2018
2 parents e333175 + b9dbddf commit b16b60f
Show file tree
Hide file tree
Showing 95 changed files with 463 additions and 328 deletions.
1 change: 1 addition & 0 deletions apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "cache.h"
#include "config.h"
#include "object-store.h"
#include "blob.h"
#include "delta.h"
#include "diff.h"
Expand Down
1 change: 1 addition & 0 deletions archive-tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "config.h"
#include "tar.h"
#include "archive.h"
#include "object-store.h"
#include "streaming.h"
#include "run-command.h"

Expand Down
1 change: 1 addition & 0 deletions archive-zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "archive.h"
#include "streaming.h"
#include "utf8.h"
#include "object-store.h"
#include "userdiff.h"
#include "xdiff-interface.h"

Expand Down
1 change: 1 addition & 0 deletions archive.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "cache.h"
#include "config.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "tree-walk.h"
#include "attr.h"
Expand Down
9 changes: 6 additions & 3 deletions blame.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "cache.h"
#include "refs.h"
#include "object-store.h"
#include "cache-tree.h"
#include "mergesort.h"
#include "diff.h"
Expand Down Expand Up @@ -129,17 +130,19 @@ static void append_merge_parents(struct commit_list **tail)
int merge_head;
struct strbuf line = STRBUF_INIT;

merge_head = open(git_path_merge_head(), O_RDONLY);
merge_head = open(git_path_merge_head(the_repository), O_RDONLY);
if (merge_head < 0) {
if (errno == ENOENT)
return;
die("cannot open '%s' for reading", git_path_merge_head());
die("cannot open '%s' for reading",
git_path_merge_head(the_repository));
}

while (!strbuf_getwholeline_fd(&line, merge_head, '\n')) {
struct object_id oid;
if (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid))
die("unknown line in '%s': %s", git_path_merge_head(), line.buf);
die("unknown line in '%s': %s",
git_path_merge_head(the_repository), line.buf);
tail = append_parent(tail, &oid);
}
close(merge_head);
Expand Down
14 changes: 7 additions & 7 deletions branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,13 @@ void create_branch(const char *name, const char *start_name,

void remove_branch_state(void)
{
unlink(git_path_cherry_pick_head());
unlink(git_path_revert_head());
unlink(git_path_merge_head());
unlink(git_path_merge_rr());
unlink(git_path_merge_msg());
unlink(git_path_merge_mode());
unlink(git_path_squash_msg());
unlink(git_path_cherry_pick_head(the_repository));
unlink(git_path_revert_head(the_repository));
unlink(git_path_merge_head(the_repository));
unlink(git_path_merge_rr(the_repository));
unlink(git_path_merge_msg(the_repository));
unlink(git_path_merge_mode(the_repository));
unlink(git_path_squash_msg(the_repository));
}

void die_if_checked_out(const char *branch, int ignore_current_worktree)
Expand Down
4 changes: 3 additions & 1 deletion builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "config.h"
#include "color.h"
#include "builtin.h"
#include "repository.h"
#include "commit.h"
#include "diff.h"
#include "revision.h"
Expand All @@ -23,6 +24,7 @@
#include "line-log.h"
#include "dir.h"
#include "progress.h"
#include "object-store.h"
#include "blame.h"
#include "string-list.h"

Expand Down Expand Up @@ -576,7 +578,7 @@ static int read_ancestry(const char *graft_file)
/* The format is just "Commit Parent1 Parent2 ...\n" */
struct commit_graft *graft = read_graft_line(&buf);
if (graft)
register_commit_graft(graft, 0);
register_commit_graft(the_repository, graft, 0);
}
fclose(fp);
strbuf_release(&buf);
Expand Down
1 change: 1 addition & 0 deletions builtin/cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "tree-walk.h"
#include "sha1-array.h"
#include "packfile.h"
#include "object-store.h"

struct batch_options {
int enabled;
Expand Down
1 change: 1 addition & 0 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "lockfile.h"
#include "parse-options.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "fetch-pack.h"
#include "refs.h"
#include "refspec.h"
#include "object-store.h"
#include "tree.h"
#include "tree-walk.h"
#include "unpack-trees.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
#include "cache.h"
#include "config.h"
#include "object-store.h"
#include "commit.h"
#include "tree.h"
#include "builtin.h"
Expand Down
38 changes: 19 additions & 19 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ static int opt_parse_rename_score(const struct option *opt, const char *arg, int

static void determine_whence(struct wt_status *s)
{
if (file_exists(git_path_merge_head()))
if (file_exists(git_path_merge_head(the_repository)))
whence = FROM_MERGE;
else if (file_exists(git_path_cherry_pick_head())) {
else if (file_exists(git_path_cherry_pick_head(the_repository))) {
whence = FROM_CHERRY_PICK;
if (file_exists(git_path_seq_dir()))
sequencer_in_use = 1;
Expand Down Expand Up @@ -718,21 +718,21 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
if (have_option_m)
strbuf_addbuf(&sb, &message);
hook_arg1 = "message";
} else if (!stat(git_path_merge_msg(), &statbuf)) {
} else if (!stat(git_path_merge_msg(the_repository), &statbuf)) {
/*
* prepend SQUASH_MSG here if it exists and a
* "merge --squash" was originally performed
*/
if (!stat(git_path_squash_msg(), &statbuf)) {
if (strbuf_read_file(&sb, git_path_squash_msg(), 0) < 0)
if (!stat(git_path_squash_msg(the_repository), &statbuf)) {
if (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)
die_errno(_("could not read SQUASH_MSG"));
hook_arg1 = "squash";
} else
hook_arg1 = "merge";
if (strbuf_read_file(&sb, git_path_merge_msg(), 0) < 0)
if (strbuf_read_file(&sb, git_path_merge_msg(the_repository), 0) < 0)
die_errno(_("could not read MERGE_MSG"));
} else if (!stat(git_path_squash_msg(), &statbuf)) {
if (strbuf_read_file(&sb, git_path_squash_msg(), 0) < 0)
} else if (!stat(git_path_squash_msg(the_repository), &statbuf)) {
if (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)
die_errno(_("could not read SQUASH_MSG"));
hook_arg1 = "squash";
} else if (template_file) {
Expand Down Expand Up @@ -813,8 +813,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
" %s\n"
"and try again.\n"),
whence == FROM_MERGE ?
git_path_merge_head() :
git_path_cherry_pick_head());
git_path_merge_head(the_repository) :
git_path_cherry_pick_head(the_repository));
}

fprintf(s->fp, "\n");
Expand Down Expand Up @@ -1564,7 +1564,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (!reflog_msg)
reflog_msg = "commit (merge)";
pptr = commit_list_append(current_head, pptr);
fp = xfopen(git_path_merge_head(), "r");
fp = xfopen(git_path_merge_head(the_repository), "r");
while (strbuf_getline_lf(&m, fp) != EOF) {
struct commit *parent;

Expand All @@ -1575,8 +1575,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
}
fclose(fp);
strbuf_release(&m);
if (!stat(git_path_merge_mode(), &statbuf)) {
if (strbuf_read_file(&sb, git_path_merge_mode(), 0) < 0)
if (!stat(git_path_merge_mode(the_repository), &statbuf)) {
if (strbuf_read_file(&sb, git_path_merge_mode(the_repository), 0) < 0)
die_errno(_("could not read MERGE_MODE"));
if (!strcmp(sb.buf, "no-ff"))
allow_fast_forward = 0;
Expand Down Expand Up @@ -1639,12 +1639,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
die("%s", err.buf);
}

unlink(git_path_cherry_pick_head());
unlink(git_path_revert_head());
unlink(git_path_merge_head());
unlink(git_path_merge_msg());
unlink(git_path_merge_mode());
unlink(git_path_squash_msg());
unlink(git_path_cherry_pick_head(the_repository));
unlink(git_path_revert_head(the_repository));
unlink(git_path_merge_head(the_repository));
unlink(git_path_merge_msg(the_repository));
unlink(git_path_merge_mode(the_repository));
unlink(git_path_squash_msg(the_repository));

if (commit_index_files())
die (_("Repository has been updated, but unable to write\n"
Expand Down
1 change: 1 addition & 0 deletions builtin/describe.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "hashmap.h"
#include "argv-array.h"
#include "run-command.h"
#include "object-store.h"
#include "revision.h"
#include "list-objects.h"
#include "commit-slab.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/difftool.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "argv-array.h"
#include "strbuf.h"
#include "lockfile.h"
#include "object-store.h"
#include "dir.h"

static char *diff_gui_tool;
Expand Down
1 change: 1 addition & 0 deletions builtin/fast-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "config.h"
#include "refs.h"
#include "refspec.h"
#include "object-store.h"
#include "commit.h"
#include "object.h"
#include "tag.h"
Expand Down
7 changes: 4 additions & 3 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "repository.h"
#include "refs.h"
#include "refspec.h"
#include "object-store.h"
#include "commit.h"
#include "builtin.h"
#include "string-list.h"
Expand Down Expand Up @@ -777,7 +778,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
const char *what, *kind;
struct ref *rm;
char *url;
const char *filename = dry_run ? "/dev/null" : git_path_fetch_head();
const char *filename = dry_run ? "/dev/null" : git_path_fetch_head(the_repository);
int want_status;
int summary_width = transport_summary_width(ref_map);

Expand Down Expand Up @@ -1029,7 +1030,7 @@ static void check_not_current_branch(struct ref *ref_map)

static int truncate_fetch_head(void)
{
const char *filename = git_path_fetch_head();
const char *filename = git_path_fetch_head(the_repository);
FILE *fp = fopen_for_writing(filename);

if (!fp)
Expand Down Expand Up @@ -1449,7 +1450,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
if (unshallow) {
if (depth)
die(_("--depth and --unshallow cannot be used together"));
else if (!is_repository_shallow())
else if (!is_repository_shallow(the_repository))
die(_("--unshallow on a complete repository does not make sense"));
else
depth = xstrfmt("%d", INFINITE_DEPTH);
Expand Down
1 change: 1 addition & 0 deletions builtin/fmt-merge-msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "cache.h"
#include "config.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "diff.h"
#include "revision.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/hash-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#include "builtin.h"
#include "config.h"
#include "object-store.h"
#include "blob.h"
#include "quote.h"
#include "parse-options.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "cache.h"
#include "config.h"
#include "refs.h"
#include "object-store.h"
#include "color.h"
#include "commit.h"
#include "diff.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/ls-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
#include "cache.h"
#include "config.h"
#include "object-store.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/merge-tree.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "builtin.h"
#include "tree-walk.h"
#include "xdiff-interface.h"
#include "object-store.h"
#include "blob.h"
#include "exec-cmd.h"
#include "merge-blobs.h"
Expand Down
Loading

0 comments on commit b16b60f

Please sign in to comment.