summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/add.c7
-rw-r--r--builtin/am.c58
-rw-r--r--builtin/blame.c28
-rw-r--r--builtin/branch.c6
-rw-r--r--builtin/check-ignore.c3
-rw-r--r--builtin/checkout.c19
-rw-r--r--builtin/clean.c4
-rw-r--r--builtin/clone.c21
-rw-r--r--builtin/commit-tree.c2
-rw-r--r--builtin/commit.c12
-rw-r--r--builtin/describe.c10
-rw-r--r--builtin/diff-tree.c8
-rw-r--r--builtin/diff.c6
-rw-r--r--builtin/fast-export.c8
-rw-r--r--builtin/fetch.c7
-rw-r--r--builtin/fmt-merge-msg.c8
-rw-r--r--builtin/fsck.c22
-rw-r--r--builtin/gc.c2
-rw-r--r--builtin/grep.c4
-rw-r--r--builtin/index-pack.c56
-rw-r--r--builtin/log.c18
-rw-r--r--builtin/ls-files.c10
-rw-r--r--builtin/ls-tree.c6
-rw-r--r--builtin/merge-base.c8
-rw-r--r--builtin/merge-tree.c10
-rw-r--r--builtin/merge.c12
-rw-r--r--builtin/name-rev.c38
-rw-r--r--builtin/notes.c2
-rw-r--r--builtin/pack-objects.c81
-rw-r--r--builtin/prune.c11
-rw-r--r--builtin/pull.c14
-rw-r--r--builtin/read-tree.c10
-rw-r--r--builtin/receive-pack.c73
-rw-r--r--builtin/reflog.c60
-rw-r--r--builtin/repack.c5
-rw-r--r--builtin/replace.c6
-rw-r--r--builtin/reset.c40
-rw-r--r--builtin/rev-list.c4
-rw-r--r--builtin/rev-parse.c58
-rw-r--r--builtin/show-branch.c8
-rw-r--r--builtin/tag.c78
-rw-r--r--builtin/unpack-objects.c65
-rw-r--r--builtin/verify-commit.c12
-rw-r--r--builtin/worktree.c4
44 files changed, 521 insertions, 403 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 9f53f02..36cad00 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -400,7 +400,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
}
/* This picks up the paths that are not tracked */
- baselen = fill_directory(&dir, &pathspec);
+ baselen = fill_directory(&dir, &the_index, &pathspec);
if (pathspec.nr)
seen = prune_directory(&dir, &pathspec, baselen);
}
@@ -436,8 +436,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
!file_exists(path))) {
if (ignore_missing) {
int dtype = DT_UNKNOWN;
- if (is_excluded(&dir, path, &dtype))
- dir_add_ignored(&dir, path, pathspec.items[i].len);
+ if (is_excluded(&dir, &the_index, path, &dtype))
+ dir_add_ignored(&dir, &the_index,
+ path, pathspec.items[i].len);
} else
die(_("pathspec '%s' did not match any files"),
pathspec.items[i].original);
diff --git a/builtin/am.c b/builtin/am.c
index 9c5c2c7..8b218f9 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -879,12 +879,12 @@ static int hg_patch_to_mail(FILE *out, FILE *in, int keep_cr)
if (skip_prefix(sb.buf, "# User ", &str))
fprintf(out, "From: %s\n", str);
else if (skip_prefix(sb.buf, "# Date ", &str)) {
- unsigned long timestamp;
+ timestamp_t timestamp;
long tz, tz2;
char *end;
errno = 0;
- timestamp = strtoul(str, &end, 10);
+ timestamp = parse_timestamp(str, &end, 10);
if (errno)
return error(_("invalid timestamp"));
@@ -1145,7 +1145,7 @@ static int index_has_changes(struct strbuf *sb)
DIFF_OPT_SET(&opt, EXIT_WITH_STATUS);
if (!sb)
DIFF_OPT_SET(&opt, QUICK);
- do_diff_cache(head.hash, &opt);
+ do_diff_cache(&head, &opt);
diffcore_std(&opt);
for (i = 0; sb && i < diff_queued_diff.nr; i++) {
if (i)
@@ -1369,40 +1369,33 @@ static int get_mail_commit_oid(struct object_id *commit_id, const char *mail)
*/
static void get_commit_info(struct am_state *state, struct commit *commit)
{
- const char *buffer, *ident_line, *author_date, *msg;
+ const char *buffer, *ident_line, *msg;
size_t ident_len;
- struct ident_split ident_split;
- struct strbuf sb = STRBUF_INIT;
+ struct ident_split id;
buffer = logmsg_reencode(commit, NULL, get_commit_output_encoding());
ident_line = find_commit_header(buffer, "author", &ident_len);
- if (split_ident_line(&ident_split, ident_line, ident_len) < 0) {
- strbuf_add(&sb, ident_line, ident_len);
- die(_("invalid ident line: %s"), sb.buf);
- }
+ if (split_ident_line(&id, ident_line, ident_len) < 0)
+ die(_("invalid ident line: %.*s"), (int)ident_len, ident_line);
assert(!state->author_name);
- if (ident_split.name_begin) {
- strbuf_add(&sb, ident_split.name_begin,
- ident_split.name_end - ident_split.name_begin);
- state->author_name = strbuf_detach(&sb, NULL);
- } else
+ if (id.name_begin)
+ state->author_name =
+ xmemdupz(id.name_begin, id.name_end - id.name_begin);
+ else
state->author_name = xstrdup("");
assert(!state->author_email);
- if (ident_split.mail_begin) {
- strbuf_add(&sb, ident_split.mail_begin,
- ident_split.mail_end - ident_split.mail_begin);
- state->author_email = strbuf_detach(&sb, NULL);
- } else
+ if (id.mail_begin)
+ state->author_email =
+ xmemdupz(id.mail_begin, id.mail_end - id.mail_begin);
+ else
state->author_email = xstrdup("");
- author_date = show_ident_date(&ident_split, DATE_MODE(NORMAL));
- strbuf_addstr(&sb, author_date);
assert(!state->author_date);
- state->author_date = strbuf_detach(&sb, NULL);
+ state->author_date = xstrdup(show_ident_date(&id, DATE_MODE(NORMAL)));
assert(!state->msg);
msg = strstr(buffer, "\n\n");
@@ -1410,6 +1403,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid));
state->msg = xstrdup(msg + 2);
state->msg_len = strlen(state->msg);
+ unuse_commit_buffer(commit, buffer);
}
/**
@@ -1450,9 +1444,9 @@ static void write_index_patch(const struct am_state *state)
FILE *fp;
if (!get_sha1_tree("HEAD", head.hash))
- tree = lookup_tree(head.hash);
+ tree = lookup_tree(&head);
else
- tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
+ tree = lookup_tree(&empty_tree_oid);
fp = xfopen(am_path(state, "patch"), "w");
init_revisions(&rev_info, NULL);
@@ -1485,7 +1479,7 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)
if (get_mail_commit_oid(&commit_oid, mail) < 0)
die(_("could not parse %s"), mail);
- commit = lookup_commit_or_die(commit_oid.hash, mail);
+ commit = lookup_commit_or_die(&commit_oid, mail);
get_commit_info(state, commit);
@@ -1615,7 +1609,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
init_revisions(&rev_info, NULL);
rev_info.diffopt.output_format = DIFF_FORMAT_NAME_STATUS;
diff_opt_parse(&rev_info.diffopt, &diff_filter_str, 1, rev_info.prefix);
- add_pending_sha1(&rev_info, "HEAD", our_tree.hash, 0);
+ add_pending_oid(&rev_info, "HEAD", &our_tree, 0);
diff_setup_done(&rev_info.diffopt);
run_diff_index(&rev_info, 1);
}
@@ -1680,7 +1674,7 @@ static void do_commit(const struct am_state *state)
if (!get_sha1_commit("HEAD", parent.hash)) {
old_oid = &parent;
- commit_list_insert(lookup_commit(parent.hash), &parents);
+ commit_list_insert(lookup_commit(&parent), &parents);
} else {
old_oid = NULL;
say(state, stderr, _("applying to an empty history"));
@@ -2042,11 +2036,11 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
struct tree *head_tree, *remote_tree, *index_tree;
struct object_id index;
- head_tree = parse_tree_indirect(head->hash);
+ head_tree = parse_tree_indirect(head);
if (!head_tree)
return error(_("Could not parse object '%s'."), oid_to_hex(head));
- remote_tree = parse_tree_indirect(remote->hash);
+ remote_tree = parse_tree_indirect(remote);
if (!remote_tree)
return error(_("Could not parse object '%s'."), oid_to_hex(remote));
@@ -2058,7 +2052,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
if (write_cache_as_tree(index.hash, 0, NULL))
return -1;
- index_tree = parse_tree_indirect(index.hash);
+ index_tree = parse_tree_indirect(&index);
if (!index_tree)
return error(_("Could not parse object '%s'."), oid_to_hex(&index));
@@ -2153,7 +2147,7 @@ static void am_abort(struct am_state *state)
am_rerere_clear();
curr_branch = resolve_refdup("HEAD", 0, curr_head.hash, NULL);
- has_curr_head = !is_null_oid(&curr_head);
+ has_curr_head = curr_branch && !is_null_oid(&curr_head);
if (!has_curr_head)
hashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN);
diff --git a/builtin/blame.c b/builtin/blame.c
index 07506a3..1043e53 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -563,7 +563,7 @@ static struct origin *find_origin(struct scoreboard *sb,
diff_setup_done(&diff_opts);
if (is_null_oid(&origin->commit->object.oid))
- do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
+ do_diff_cache(&parent->tree->object.oid, &diff_opts);
else
diff_tree_sha1(parent->tree->object.oid.hash,
origin->commit->tree->object.oid.hash,
@@ -633,7 +633,7 @@ static struct origin *find_rename(struct scoreboard *sb,
diff_setup_done(&diff_opts);
if (is_null_oid(&origin->commit->object.oid))
- do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
+ do_diff_cache(&parent->tree->object.oid, &diff_opts);
else
diff_tree_sha1(parent->tree->object.oid.hash,
origin->commit->tree->object.oid.hash,
@@ -1272,7 +1272,7 @@ static void find_copy_in_parent(struct scoreboard *sb,
DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
if (is_null_oid(&target->commit->object.oid))
- do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
+ do_diff_cache(&parent->tree->object.oid, &diff_opts);
else
diff_tree_sha1(parent->tree->object.oid.hash,
target->commit->tree->object.oid.hash,
@@ -1561,13 +1561,13 @@ finish:
struct commit_info {
struct strbuf author;
struct strbuf author_mail;
- unsigned long author_time;
+ timestamp_t author_time;
struct strbuf author_tz;
/* filled only when asked for details */
struct strbuf committer;
struct strbuf committer_mail;
- unsigned long committer_time;
+ timestamp_t committer_time;
struct strbuf committer_tz;
struct strbuf summary;
@@ -1578,7 +1578,7 @@ struct commit_info {
*/
static void get_ac_line(const char *inbuf, const char *what,
struct strbuf *name, struct strbuf *mail,
- unsigned long *time, struct strbuf *tz)
+ timestamp_t *time, struct strbuf *tz)
{
struct ident_split ident;
size_t len, maillen, namelen;
@@ -1727,11 +1727,11 @@ static int emit_one_suspect_detail(struct origin *suspect, int repeat)
get_commit_info(suspect->commit, &ci, 1);
printf("author %s\n", ci.author.buf);
printf("author-mail %s\n", ci.author_mail.buf);
- printf("author-time %lu\n", ci.author_time);
+ printf("author-time %"PRItime"\n", ci.author_time);
printf("author-tz %s\n", ci.author_tz.buf);
printf("committer %s\n", ci.committer.buf);
printf("committer-mail %s\n", ci.committer_mail.buf);
- printf("committer-time %lu\n", ci.committer_time);
+ printf("committer-time %"PRItime"\n", ci.committer_time);
printf("committer-tz %s\n", ci.committer_tz.buf);
printf("summary %s\n", ci.summary.buf);
if (suspect->commit->object.flags & UNINTERESTING)
@@ -1837,14 +1837,14 @@ static void assign_blame(struct scoreboard *sb, int opt)
stop_progress(&pi.progress);
}
-static const char *format_time(unsigned long time, const char *tz_str,
+static const char *format_time(timestamp_t time, const char *tz_str,
int show_raw_time)
{
static struct strbuf time_buf = STRBUF_INIT;
strbuf_reset(&time_buf);
if (show_raw_time) {
- strbuf_addf(&time_buf, "%lu %s", time, tz_str);
+ strbuf_addf(&time_buf, "%"PRItime" %s", time, tz_str);
}
else {
const char *time_str;
@@ -2253,7 +2253,7 @@ static struct commit_list **append_parent(struct commit_list **tail, const struc
{
struct commit *parent;
- parent = lookup_commit_reference(oid->hash);
+ parent = lookup_commit_reference(oid);
if (!parent)
die("no such commit %s", oid_to_hex(oid));
return &commit_list_insert(parent, tail)->next;
@@ -2461,7 +2461,7 @@ static const char *dwim_reverse_initial(struct scoreboard *sb)
*/
struct object *obj;
struct commit *head_commit;
- unsigned char head_sha1[20];
+ struct object_id head_oid;
if (sb->revs->pending.nr != 1)
return NULL;
@@ -2473,9 +2473,9 @@ static const char *dwim_reverse_initial(struct scoreboard *sb)
return NULL;
/* Do we have HEAD? */
- if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_sha1, NULL))
+ if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
return NULL;
- head_commit = lookup_commit_reference_gently(head_sha1, 1);
+ head_commit = lookup_commit_reference_gently(&head_oid, 1);
if (!head_commit)
return NULL;
diff --git a/builtin/branch.c b/builtin/branch.c
index 48a513a..83fcda4 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -124,7 +124,7 @@ static int branch_merged(int kind, const char *name,
(reference_name = reference_name_to_free =
resolve_refdup(upstream, RESOLVE_REF_READING,
oid.hash, NULL)) != NULL)
- reference_rev = lookup_commit_reference(oid.hash);
+ reference_rev = lookup_commit_reference(&oid);
}
if (!reference_rev)
reference_rev = head_rev;
@@ -157,7 +157,7 @@ static int check_branch_commit(const char *branchname, const char *refname,
const struct object_id *oid, struct commit *head_rev,
int kinds, int force)
{
- struct commit *rev = lookup_commit_reference(oid->hash);
+ struct commit *rev = lookup_commit_reference(oid);
if (!rev) {
error(_("Couldn't look up commit object for '%s'"), refname);
return -1;
@@ -211,7 +211,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
}
if (!force) {
- head_rev = lookup_commit_reference(head_oid.hash);
+ head_rev = lookup_commit_reference(&head_oid);
if (!head_rev)
die(_("Couldn't look up commit object for HEAD"));
}
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 1d73d3c..d2293b2 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -101,7 +101,8 @@ static int check_ignore(struct dir_struct *dir,
full_path = pathspec.items[i].match;
exclude = NULL;
if (!seen[i]) {
- exclude = last_exclude_matching(dir, full_path, &dtype);
+ exclude = last_exclude_matching(dir, &the_index,
+ full_path, &dtype);
}
if (!quiet && (exclude || show_non_matching))
output_exclude(pathspec.items[i].original, exclude);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 94849cf..b6249a3 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -395,7 +395,7 @@ static int checkout_paths(const struct checkout_opts *opts,
die(_("unable to write new index file"));
read_ref_full("HEAD", 0, rev.hash, NULL);
- head = lookup_commit_reference_gently(rev.hash, 1);
+ head = lookup_commit_reference_gently(&rev, 1);
errs |= post_checkout_hook(head, head, 0);
return errs;
@@ -529,10 +529,10 @@ static int merge_working_tree(const struct checkout_opts *opts,
setup_standard_excludes(topts.dir);
}
tree = parse_tree_indirect(old->commit ?
- old->commit->object.oid.hash :
- EMPTY_TREE_SHA1_BIN);
+ &old->commit->object.oid :
+ &empty_tree_oid);
init_tree_desc(&trees[0], tree->buffer, tree->size);
- tree = parse_tree_indirect(new->commit->object.oid.hash);
+ tree = parse_tree_indirect(&new->commit->object.oid);
init_tree_desc(&trees[1], tree->buffer, tree->size);
ret = unpack_trees(2, trees, &topts);
@@ -723,7 +723,7 @@ static int add_pending_uninteresting_ref(const char *refname,
const struct object_id *oid,
int flags, void *cb_data)
{
- add_pending_sha1(cb_data, refname, oid->hash, UNINTERESTING);
+ add_pending_oid(cb_data, refname, oid, UNINTERESTING);
return 0;
}
@@ -809,7 +809,7 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)
add_pending_object(&revs, object, oid_to_hex(&object->oid));
for_each_ref(add_pending_uninteresting_ref, &revs);
- add_pending_sha1(&revs, "HEAD", new->object.oid.hash, UNINTERESTING);
+ add_pending_oid(&revs, "HEAD", &new->object.oid, UNINTERESTING);
refs = revs.pending;
revs.leak_pending = 1;
@@ -835,7 +835,8 @@ static int switch_branches(const struct checkout_opts *opts,
int flag, writeout_error = 0;
memset(&old, 0, sizeof(old));
old.path = path_to_free = resolve_refdup("HEAD", 0, rev.hash, &flag);
- old.commit = lookup_commit_reference_gently(rev.hash, 1);
+ if (old.path)
+ old.commit = lookup_commit_reference_gently(&rev, 1);
if (!(flag & REF_ISSYMREF))
old.path = NULL;
@@ -1049,10 +1050,10 @@ static int parse_branchname_arg(int argc, const char **argv,
else
new->path = NULL; /* not an existing branch */
- new->commit = lookup_commit_reference_gently(rev->hash, 1);
+ new->commit = lookup_commit_reference_gently(rev, 1);
if (!new->commit) {
/* not a commit */
- *source_tree = parse_tree_indirect(rev->hash);
+ *source_tree = parse_tree_indirect(rev);
} else {
parse_commit_or_die(new->commit);
*source_tree = new->commit->tree;
diff --git a/builtin/clean.c b/builtin/clean.c
index d861f83..329b68c 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -683,7 +683,7 @@ static int filter_by_patterns_cmd(void)
for_each_string_list_item(item, &del_list) {
int dtype = DT_UNKNOWN;
- if (is_excluded(&dir, item->string, &dtype)) {
+ if (is_excluded(&dir, &the_index, item->string, &dtype)) {
*item->string = '\0';
changed++;
}
@@ -930,7 +930,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
PATHSPEC_PREFER_CWD,
prefix, argv);
- fill_directory(&dir, &pathspec);
+ fill_directory(&dir, &the_index, &pathspec);
for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
diff --git a/builtin/clone.c b/builtin/clone.c
index de85b85..743f16a 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -40,6 +40,7 @@ static const char * const builtin_clone_usage[] = {
static int option_no_checkout, option_bare, option_mirror, option_single_branch = -1;
static int option_local = -1, option_no_hardlinks, option_shared;
+static int option_no_tags;
static int option_shallow_submodules;
static int deepen;
static char *option_template, *option_depth, *option_since;
@@ -120,6 +121,8 @@ static struct option builtin_clone_options[] = {
N_("deepen history of shallow clone, excluding rev")),
OPT_BOOL(0, "single-branch", &option_single_branch,
N_("clone only one branch, HEAD or --branch")),
+ OPT_BOOL(0, "no-tags", &option_no_tags,
+ N_("don't clone any tags, and make later fetches not to follow them")),
OPT_BOOL(0, "shallow-submodules", &option_shallow_submodules,
N_("any cloned submodules will be shallow")),
OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"),
@@ -563,7 +566,7 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
} else
get_fetch_map(refs, refspec, &tail, 0);
- if (!option_mirror && !option_single_branch)
+ if (!option_mirror && !option_single_branch && !option_no_tags)
get_fetch_map(refs, tag_refspec, &tail, 0);
return local_refs;
@@ -652,7 +655,7 @@ static void update_remote_refs(const struct ref *refs,
if (refs) {
write_remote_refs(mapped_refs);
- if (option_single_branch)
+ if (option_single_branch && !option_no_tags)
write_followtags(refs, msg);
}
@@ -682,7 +685,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
install_branch_config(0, head, option_origin, our->name);
}
} else if (our) {
- struct commit *c = lookup_commit_reference(our->old_oid.hash);
+ struct commit *c = lookup_commit_reference(&our->old_oid);
/* --branch specifies a non-branch (i.e. tags), detach HEAD */
update_ref(msg, "HEAD", c->object.oid.hash,
NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
@@ -739,7 +742,7 @@ static int checkout(int submodule_progress)
opts.src_index = &the_index;
opts.dst_index = &the_index;
- tree = parse_tree_indirect(oid.hash);
+ tree = parse_tree_indirect(&oid);
parse_tree(tree);
init_tree_desc(&t, tree->buffer, tree->size);
if (unpack_trees(1, &t, &opts) < 0)
@@ -773,7 +776,9 @@ static int checkout(int submodule_progress)
static int write_one_config(const char *key, const char *value, void *data)
{
- return git_config_set_multivar_gently(key, value ? value : "true", "^$", 0);
+ return git_config_set_multivar_gently(key,
+ value ? value : "true",
+ CONFIG_REGEX_NONE, 0);
}
static void write_config(struct string_list *config)
@@ -1035,6 +1040,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
git_config_set(key.buf, repo);
strbuf_reset(&key);
+ if (option_no_tags) {
+ strbuf_addf(&key, "remote.%s.tagOpt", option_origin);
+ git_config_set(key.buf, "--no-tags");
+ strbuf_reset(&key);
+ }
+
if (option_required_reference.nr || option_optional_reference.nr)
setup_reference();
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 6050172..f39c2b2 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -58,7 +58,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
if (get_sha1_commit(argv[i], oid.hash))
die("Not a valid object name %s", argv[i]);
assert_sha1_type(oid.hash, OBJ_COMMIT);
- new_parent(lookup_commit(oid.hash), &parents);
+ new_parent(lookup_commit(&oid), &parents);
continue;
}
diff --git a/builtin/commit.c b/builtin/commit.c
index 1d805f5..1d191a4 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -313,7 +313,7 @@ static void create_base_index(const struct commit *current_head)
opts.dst_index = &the_index;
opts.fn = oneway_merge;
- tree = parse_tree_indirect(current_head->object.oid.hash);
+ tree = parse_tree_indirect(&current_head->object.oid);
if (!tree)
die(_("failed to unpack HEAD tree object"));
parse_tree(tree);
@@ -1263,6 +1263,10 @@ static int parse_status_slot(const char *slot)
return WT_STATUS_NOBRANCH;
if (!strcasecmp(slot, "unmerged"))
return WT_STATUS_UNMERGED;
+ if (!strcasecmp(slot, "localBranch"))
+ return WT_STATUS_LOCAL_BRANCH;
+ if (!strcasecmp(slot, "remoteBranch"))
+ return WT_STATUS_REMOTE_BRANCH;
return -1;
}
@@ -1430,7 +1434,7 @@ static void print_summary(const char *prefix, const struct object_id *oid,
struct strbuf author_ident = STRBUF_INIT;
struct strbuf committer_ident = STRBUF_INIT;
- commit = lookup_commit(oid->hash);
+ commit = lookup_commit(oid);
if (!commit)
die(_("couldn't look up newly created commit"));
if (parse_commit(commit))
@@ -1654,7 +1658,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (get_sha1("HEAD", oid.hash))
current_head = NULL;
else {
- current_head = lookup_commit_or_die(oid.hash, "HEAD");
+ current_head = lookup_commit_or_die(&oid, "HEAD");
if (parse_commit(current_head))
die(_("could not parse HEAD commit"));
}
@@ -1758,7 +1762,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
append_merge_tag_headers(parents, &tail);
}
- if (commit_tree_extended(sb.buf, sb.len, active_cache_tree->sha1,
+ if (commit_tree_extended(sb.buf, sb.len, active_cache_tree->oid.hash,
parents, oid.hash, author_ident.buf, sign_commit, extra)) {
rollback_index_files();
die(_("failed to write commit object"));
diff --git a/builtin/describe.c b/builtin/describe.c
index a5cd8c5..893c878 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -79,13 +79,13 @@ static int replace_name(struct commit_name *e,
struct tag *t;
if (!e->tag) {
- t = lookup_tag(e->oid.hash);
+ t = lookup_tag(&e->oid);
if (!t || parse_tag(t))
return 1;
e->tag = t;
}
- t = lookup_tag(oid->hash);
+ t = lookup_tag(oid);
if (!t || parse_tag(t))
return 0;
*tag = t;
@@ -245,7 +245,7 @@ static unsigned long finish_depth_computation(
static void display_name(struct commit_name *n)
{
if (n->prio == 2 && !n->tag) {
- n->tag = lookup_tag(n->oid.hash);
+ n->tag = lookup_tag(&n->oid);
if (!n->tag || parse_tag(n->tag))
die(_("annotated tag %s not available"), n->path);
}
@@ -281,7 +281,7 @@ static void describe(const char *arg, int last_one)
if (get_oid(arg, &oid))
die(_("Not a valid object name %s"), arg);
- cmit = lookup_commit_reference(oid.hash);
+ cmit = lookup_commit_reference(&oid);
if (!cmit)
die(_("%s is not a valid '%s' object"), arg, commit_type);
@@ -309,7 +309,7 @@ static void describe(const char *arg, int last_one)
struct commit *c;
struct commit_name *n = hashmap_iter_first(&names, &iter);
for (; n; n = hashmap_iter_next(&iter)) {
- c = lookup_commit_reference_gently(n->peeled.hash, 1);
+ c = lookup_commit_reference_gently(&n->peeled, 1);
if (c)
c->util = n;
}
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 326f88b..5ea1c14 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -9,7 +9,7 @@ static struct rev_info log_tree_opt;
static int diff_tree_commit_sha1(const struct object_id *oid)
{
- struct commit *commit = lookup_commit_reference(oid->hash);
+ struct commit *commit = lookup_commit_reference(oid);
if (!commit)
return -1;
return log_tree_commit(&log_tree_opt, commit);
@@ -23,7 +23,7 @@ static int stdin_diff_commit(struct commit *commit, const char *p)
/* Graft the fake parents locally to the commit */
while (isspace(*p++) && !parse_oid_hex(p, &oid, &p)) {
- struct commit *parent = lookup_commit(oid.hash);
+ struct commit *parent = lookup_commit(&oid);
if (!pptr) {
/* Free the real parent list */
free_commit_list(commit->parents);
@@ -44,7 +44,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
struct tree *tree2;
if (!isspace(*p++) || parse_oid_hex(p, &oid, &p) || *p)
return error("Need exactly two trees, separated by a space");
- tree2 = lookup_tree(oid.hash);
+ tree2 = lookup_tree(&oid);
if (!tree2 || parse_tree(tree2))
return -1;
printf("%s %s\n", oid_to_hex(&tree1->object.oid),
@@ -67,7 +67,7 @@ static int diff_tree_stdin(char *line)
line[len-1] = 0;
if (parse_oid_hex(line, &oid, &p))
return -1;
- obj = parse_object(oid.hash);
+ obj = parse_object(&oid);
if (!obj)
return -1;
if (obj->type == OBJ_COMMIT)
diff --git a/builtin/diff.c b/builtin/diff.c
index d184aaf..8c03dda 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -381,7 +381,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
add_head_to_pending(&rev);
if (!rev.pending.nr) {
struct tree *tree;
- tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
+ tree = lookup_tree(&empty_tree_oid);
add_pending_object(&rev, &tree->object, "HEAD");
}
break;
@@ -395,7 +395,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
const char *name = entry->name;
int flags = (obj->flags & UNINTERESTING);
if (!obj->parsed)
- obj = parse_object(obj->oid.hash);
+ obj = parse_object(&obj->oid);
obj = deref_tag(obj, NULL, 0);
if (!obj)
die(_("invalid object '%s' given."), name);
@@ -408,7 +408,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
} else if (obj->type == OBJ_BLOB) {
if (2 <= blobs)
die(_("more than two blobs given: '%s'"), name);
- hashcpy(blob[blobs].oid.hash, obj->oid.hash);
+ oidcpy(&blob[blobs].oid, &obj->oid);
blob[blobs].name = name;
blob[blobs].mode = entry->mode;
blobs++;
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 64617ad..24e29ad 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -232,7 +232,7 @@ static void export_blob(const struct object_id *oid)
if (anonymize) {
buf = anonymize_blob(&size);
- object = (struct object *)lookup_blob(oid->hash);
+ object = (struct object *)lookup_blob(oid);
eaten = 0;
} else {
buf = read_sha1_file(oid->hash, &type, &size);
@@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid)
die ("Could not read blob %s", oid_to_hex(oid));
if (check_sha1_signature(oid->hash, buf, size, typename(type)) < 0)
die("sha1 mismatch in blob %s", oid_to_hex(oid));
- object = parse_object_buffer(oid->hash, type, size, buf, &eaten);
+ object = parse_object_buffer(oid, type, size, buf, &eaten);
}
if (!object)
@@ -779,7 +779,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)
/* handle nested tags */
while (tag && tag->object.type == OBJ_TAG) {
- parse_object(tag->object.oid.hash);
+ parse_object(&tag->object.oid);
string_list_append(&extra_refs, full_name)->util = tag;
tag = (struct tag *)tag->tagged;
}
@@ -940,7 +940,7 @@ static void import_marks(char *input_file)
/* only commits */
continue;
- commit = lookup_commit(oid.hash);
+ commit = lookup_commit(&oid);
if (!commit)
die("not a commit? can't happen: %s", oid_to_hex(&oid));
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 5f2c2ab..d4d573b 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -636,8 +636,8 @@ static int update_local_ref(struct ref *ref,
return r;
}
- current = lookup_commit_reference_gently(ref->old_oid.hash, 1);
- updated = lookup_commit_reference_gently(ref->new_oid.hash, 1);
+ current = lookup_commit_reference_gently(&ref->old_oid, 1);
+ updated = lookup_commit_reference_gently(&ref->new_oid, 1);
if (!current || !updated) {
const char *msg;
const char *what;
@@ -770,7 +770,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
continue;
}
- commit = lookup_commit_reference_gently(rm->old_oid.hash, 1);
+ commit = lookup_commit_reference_gently(&rm->old_oid,
+ 1);
if (!commit)
rm->fetch_head_status = FETCH_HEAD_NOT_FOR_MERGE;
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 6faa3c0..70137b0 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -341,7 +341,7 @@ static void shortlog(const char *name,
const struct object_id *oid = &origin_data->oid;
int limit = opts->shortlog_len;
- branch = deref_tag(parse_object(oid->hash), oid_to_hex(oid), GIT_SHA1_HEXSZ);
+ branch = deref_tag(parse_object(oid), oid_to_hex(oid), GIT_SHA1_HEXSZ);
if (!branch || branch->type != OBJ_COMMIT)
return;
@@ -559,14 +559,14 @@ static void find_merge_parents(struct merge_parents *result,
* "name" here and we do not want to contaminate its
* util field yet.
*/
- obj = parse_object(oid.hash);
+ obj = parse_object(&oid);
parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);
if (!parent)
continue;
commit_list_insert(parent, &parents);
add_merge_parent(result, &obj->oid, &parent->object.oid);
}
- head_commit = lookup_commit(head->hash);
+ head_commit = lookup_commit(head);
if (head_commit)
commit_list_insert(head_commit, &parents);
parents = reduce_heads(parents);
@@ -633,7 +633,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
struct commit *head;
struct rev_info rev;
- head = lookup_commit_or_die(head_oid.hash, "HEAD");
+ head = lookup_commit_or_die(&head_oid, "HEAD");
init_revisions(&rev, NULL);
rev.commit_format = CMIT_FMT_ONELINE;
rev.ignore_merges = 1;
diff --git a/builtin/fsck.c b/builtin/fsck.c
index b5e13a4..cb2ba6c 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -377,7 +377,7 @@ static int fsck_obj(struct object *obj)
return 0;
}
-static int fsck_obj_buffer(const unsigned char *sha1, enum object_type type,
+static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
unsigned long size, void *buffer, int *eaten)
{
/*
@@ -385,10 +385,10 @@ static int fsck_obj_buffer(const unsigned char *sha1, enum object_type type,
* verify_packfile(), data_valid variable for details.
*/
struct object *obj;
- obj = parse_object_buffer(sha1, type, size, buffer, eaten);
+ obj = parse_object_buffer(oid, type, size, buffer, eaten);
if (!obj) {
errors_found |= ERROR_OBJECT;
- return error("%s: object corrupt or missing", sha1_to_hex(sha1));
+ return error("%s: object corrupt or missing", oid_to_hex(oid));
}
obj->flags = HAS_OBJ;
return fsck_obj(obj);
@@ -397,7 +397,7 @@ static int fsck_obj_buffer(const unsigned char *sha1, enum object_type type,
static int default_refs;
static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
- unsigned long timestamp)
+ timestamp_t timestamp)
{
struct object *obj;
@@ -407,7 +407,7 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
if (timestamp && name_objects)
add_decoration(fsck_walk_options.object_names,
obj,
- xstrfmt("%s@{%ld}", refname, timestamp));
+ xstrfmt("%s@{%"PRItime"}", refname, timestamp));
obj->used = 1;
mark_object_reachable(obj);
} else {
@@ -418,7 +418,7 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
}
static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid,
- const char *email, unsigned long timestamp, int tz,
+ const char *email, timestamp_t timestamp, int tz,
const char *message, void *cb_data)
{
const char *refname = cb_data;
@@ -444,7 +444,7 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
{
struct object *obj;
- obj = parse_object(oid->hash);
+ obj = parse_object(oid);
if (!obj) {
error("%s: invalid sha1 pointer %s", refname, oid_to_hex(oid));
errors_found |= ERROR_REACHABLE;
@@ -506,7 +506,7 @@ static struct object *parse_loose_object(const struct object_id *oid,
if (!contents && type != OBJ_BLOB)
die("BUG: read_loose_object streamed a non-blob");
- obj = parse_object_buffer(oid->hash, type, size, contents, &eaten);
+ obj = parse_object_buffer(oid, type, size, contents, &eaten);
if (!eaten)
free(contents);
@@ -599,10 +599,10 @@ static int fsck_cache_tree(struct cache_tree *it)
fprintf(stderr, "Checking cache tree\n");
if (0 <= it->entry_count) {
- struct object *obj = parse_object(it->sha1);
+ struct object *obj = parse_object(&it->oid);
if (!obj) {
error("%s: invalid sha1 pointer in cache-tree",
- sha1_to_hex(it->sha1));
+ oid_to_hex(&it->oid));
errors_found |= ERROR_REFS;
return 1;
}
@@ -781,7 +781,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
mode = active_cache[i]->ce_mode;
if (S_ISGITLINK(mode))
continue;
- blob = lookup_blob(active_cache[i]->oid.hash);
+ blob = lookup_blob(&active_cache[i]->oid);
if (!blob)
continue;
obj = &blob->object;
diff --git a/builtin/gc.c b/builtin/gc.c
index 91f7696..f484eda 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -33,7 +33,7 @@ static int aggressive_window = 250;
static int gc_auto_threshold = 6700;
static int gc_auto_pack_limit = 50;
static int detach_auto = 1;
-static unsigned long gc_log_expire_time;
+static timestamp_t gc_log_expire_time;
static const char *gc_log_expire = "1.day.ago";
static const char *prune_expire = "2.weeks.ago";
static const char *prune_worktrees_expire = "3.months.ago";
diff --git a/builtin/grep.c b/builtin/grep.c
index 3ffb5b4..c6c26e9 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -866,7 +866,7 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec,
if (exc_std)
setup_standard_excludes(&dir);
- fill_directory(&dir, pathspec);
+ fill_directory(&dir, &the_index, pathspec);
for (i = 0; i < dir.nr; i++) {
if (!dir_path_match(dir.entries[i], pathspec, 0, NULL))
continue;
@@ -1196,7 +1196,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
break;
}
- object = parse_object_or_die(oid.hash, arg);
+ object = parse_object_or_die(&oid, arg);
if (!seen_dashdash)
verify_non_filename(prefix, arg);
add_object_array_with_path(object, arg, &list, oc.mode, oc.path);
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 4ff567d..04b9dca 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -747,13 +747,13 @@ static int compare_objects(const unsigned char *buf, unsigned long size,
ssize_t len = read_istream(data->st, data->buf, size);
if (len == 0)
die(_("SHA1 COLLISION FOUND WITH %s !"),
- sha1_to_hex(data->entry->idx.sha1));
+ oid_to_hex(&data->entry->idx.oid));
if (len < 0)
die(_("unable to read %s"),
- sha1_to_hex(data->entry->idx.sha1));
+ oid_to_hex(&data->entry->idx.oid));
if (memcmp(buf, data->buf, len))
die(_("SHA1 COLLISION FOUND WITH %s !"),
- sha1_to_hex(data->entry->idx.sha1));
+ oid_to_hex(&data->entry->idx.oid));
size -= len;
buf += len;
}
@@ -771,12 +771,12 @@ static int check_collison(struct object_entry *entry)
memset(&data, 0, sizeof(data));
data.entry = entry;
- data.st = open_istream(entry->idx.sha1, &type, &size, NULL);
+ data.st = open_istream(entry->idx.oid.hash, &type, &size, NULL);
if (!data.st)
return -1;
if (size != entry->size || type != entry->type)
die(_("SHA1 COLLISION FOUND WITH %s !"),
- sha1_to_hex(entry->idx.sha1));
+ oid_to_hex(&entry->idx.oid));
unpack_data(entry, compare_objects, &data);
close_istream(data.st);
free(data.buf);
@@ -785,7 +785,7 @@ static int check_collison(struct object_entry *entry)
static void sha1_object(const void *data, struct object_entry *obj_entry,
unsigned long size, enum object_type type,
- const unsigned char *sha1)
+ const struct object_id *oid)
{
void *new_data = NULL;
int collision_test_needed = 0;
@@ -794,7 +794,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
if (startup_info->have_repository) {
read_lock();
- collision_test_needed = has_sha1_file_with_flags(sha1, HAS_SHA1_QUICK);
+ collision_test_needed = has_sha1_file_with_flags(oid->hash, HAS_SHA1_QUICK);
read_unlock();
}
@@ -809,31 +809,31 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
enum object_type has_type;
unsigned long has_size;
read_lock();
- has_type = sha1_object_info(sha1, &has_size);
+ has_type = sha1_object_info(oid->hash, &has_size);
if (has_type < 0)
- die(_("cannot read existing object info %s"), sha1_to_hex(sha1));
+ die(_("cannot read existing object info %s"), oid_to_hex(oid));
if (has_type != type || has_size != size)
- die(_("SHA1 COLLISION FOUND WITH %s !"), sha1_to_hex(sha1));
- has_data = read_sha1_file(sha1, &has_type, &has_size);
+ die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
+ has_data = read_sha1_file(oid->hash, &has_type, &has_size);
read_unlock();
if (!data)
data = new_data = get_data_from_pack(obj_entry);
if (!has_data)
- die(_("cannot read existing object %s"), sha1_to_hex(sha1));
+ die(_("cannot read existing object %s"), oid_to_hex(oid));
if (size != has_size || type != has_type ||
memcmp(data, has_data, size) != 0)
- die(_("SHA1 COLLISION FOUND WITH %s !"), sha1_to_hex(sha1));
+ die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
free(has_data);
}
if (strict) {
read_lock();
if (type == OBJ_BLOB) {
- struct blob *blob = lookup_blob(sha1);
+ struct blob *blob = lookup_blob(oid);
if (blob)
blob->object.flags |= FLAG_CHECKED;
else
- die(_("invalid blob object %s"), sha1_to_hex(sha1));
+ die(_("invalid blob object %s"), oid_to_hex(oid));
} else {
struct object *obj;
int eaten;
@@ -845,7 +845,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
* we do not need to free the memory here, as the
* buf is deleted by the caller.
*/
- obj = parse_object_buffer(sha1, type, size, buf, &eaten);
+ obj = parse_object_buffer(oid, type, size, buf,
+ &eaten);
if (!obj)
die(_("invalid %s"), typename(type));
if (do_fsck_object &&
@@ -957,9 +958,10 @@ static void resolve_delta(struct object_entry *delta_obj,
if (!result->data)
bad_object(delta_obj->idx.offset, _("failed to apply delta"));
hash_sha1_file(result->data, result->size,
- typename(delta_obj->real_type), delta_obj->idx.sha1);
+ typename(delta_obj->real_type),
+ delta_obj->idx.oid.hash);
sha1_object(result->data, NULL, result->size, delta_obj->real_type,
- delta_obj->idx.sha1);
+ &delta_obj->idx.oid);
counter_lock();
nr_resolved_deltas++;
counter_unlock();
@@ -989,7 +991,7 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base,
struct base_data *prev_base)
{
if (base->ref_last == -1 && base->ofs_last == -1) {
- find_ref_delta_children(base->obj->idx.sha1,
+ find_ref_delta_children(base->obj->idx.oid.hash,
&base->ref_first, &base->ref_last,
OBJ_REF_DELTA);
@@ -1130,7 +1132,8 @@ static void parse_pack_objects(unsigned char *sha1)
for (i = 0; i < nr_objects; i++) {
struct object_entry *obj = &objects[i];
void *data = unpack_raw_entry(obj, &ofs_delta->offset,
- ref_delta_sha1, obj->idx.sha1);
+ ref_delta_sha1,
+ obj->idx.oid.hash);
obj->real_type = obj->type;
if (obj->type == OBJ_OFS_DELTA) {
nr_ofs_deltas++;
@@ -1146,7 +1149,8 @@ static void parse_pack_objects(unsigned char *sha1)
obj->real_type = OBJ_BAD;
nr_delays++;
} else
- sha1_object(data, NULL, obj->size, obj->type, obj->idx.sha1);
+ sha1_object(data, NULL, obj->size, obj->type,
+ &obj->idx.oid);
free(data);
display_progress(progress, i+1);
}
@@ -1172,7 +1176,8 @@ static void parse_pack_objects(unsigned char *sha1)
if (obj->real_type != OBJ_BAD)
continue;
obj->real_type = obj->type;
- sha1_object(NULL, obj, obj->size, obj->type, obj->idx.sha1);
+ sha1_object(NULL, obj, obj->size, obj->type,
+ &obj->idx.oid);
nr_delays--;
}
if (nr_delays)
@@ -1330,7 +1335,7 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,
obj[1].idx.offset += write_compressed(f, buf, size);
obj[0].idx.crc32 = crc32_end(f);
sha1flush(f);
- hashcpy(obj->idx.sha1, sha1);
+ hashcpy(obj->idx.oid.hash, sha1);
return obj;
}
@@ -1581,13 +1586,14 @@ static void show_pack_info(int stat_only)
if (stat_only)
continue;
printf("%s %-6s %lu %lu %"PRIuMAX,
- sha1_to_hex(obj->idx.sha1),
+ oid_to_hex(&obj->idx.oid),
typename(obj->real_type), obj->size,
(unsigned long)(obj[1].idx.offset - obj->idx.offset),
(uintmax_t)obj->idx.offset);
if (is_delta_type(obj->type)) {
struct object_entry *bobj = &objects[obj_stat[i].base_object_no];
- printf(" %u %s", obj_stat[i].delta_depth, sha1_to_hex(bobj->idx.sha1));
+ printf(" %u %s", obj_stat[i].delta_depth,
+ oid_to_hex(&bobj->idx.oid));
}
putchar('\n');
}
diff --git a/builtin/log.c b/builtin/log.c
index b3b10cc..a440601ef 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -110,6 +110,8 @@ static void init_log_defaults(void)
{
init_grep_defaults();
init_diff_ui_defaults();
+
+ decoration_style = auto_decoration_style();
}
static void cmd_log_init_defaults(struct rev_info *rev)
@@ -410,8 +412,6 @@ static int git_log_config(const char *var, const char *value, void *cb)
if (decoration_style < 0)
decoration_style = 0; /* maybe warn? */
return 0;
- } else {
- decoration_style = auto_decoration_style();
}
if (!strcmp(var, "log.showroot")) {
default_show_root = git_config_bool(var, value);
@@ -596,7 +596,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
rev.shown_one = 1;
if (ret)
break;
- o = parse_object(t->tagged->oid.hash);
+ o = parse_object(&t->tagged->oid);
if (!o)
ret = error(_("Could not read object %s"),
oid_to_hex(&t->tagged->oid));
@@ -878,8 +878,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
o2 = rev->pending.objects[1].item;
flags1 = o1->flags;
flags2 = o2->flags;
- c1 = lookup_commit_reference(o1->oid.hash);
- c2 = lookup_commit_reference(o2->oid.hash);
+ c1 = lookup_commit_reference(&o1->oid);
+ c2 = lookup_commit_reference(&o2->oid);
if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
die(_("Not a range."));
@@ -910,8 +910,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
static void gen_message_id(struct rev_info *info, char *base)
{
struct strbuf buf = STRBUF_INIT;
- strbuf_addf(&buf, "%s.%lu.git.%s", base,
- (unsigned long) time(NULL),
+ strbuf_addf(&buf, "%s.%"PRItime".git.%s", base,
+ (timestamp_t) time(NULL),
git_committer_info(IDENT_NO_NAME|IDENT_NO_DATE|IDENT_STRICT));
info->message_id = strbuf_detach(&buf, NULL);
}
@@ -1263,7 +1263,7 @@ static struct commit *get_base_commit(const char *base_commit,
if (get_oid(upstream, &oid))
die(_("Failed to resolve '%s' as a valid ref."), upstream);
- commit = lookup_commit_or_die(oid.hash, "upstream base");
+ commit = lookup_commit_or_die(&oid, "upstream base");
base_list = get_merge_bases_many(commit, total, list);
/* There should be one and only one merge base. */
if (!base_list || base_list->next)
@@ -1819,7 +1819,7 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
{
struct object_id oid;
if (get_oid(arg, &oid) == 0) {
- struct commit *commit = lookup_commit_reference(oid.hash);
+ struct commit *commit = lookup_commit_reference(&oid);
if (commit) {
commit->object.flags |= flags;
add_pending_object(revs, &commit->object, arg);
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index a6c70db..530e6ae 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -322,7 +322,7 @@ static void show_ru_info(void)
static int ce_excluded(struct dir_struct *dir, const struct cache_entry *ce)
{
int dtype = ce_to_dtype(ce);
- return is_excluded(dir, ce->name, &dtype);
+ return is_excluded(dir, &the_index, ce->name, &dtype);
}
static void show_files(struct dir_struct *dir)
@@ -333,7 +333,7 @@ static void show_files(struct dir_struct *dir)
if (show_others || show_killed) {
if (!show_others)
dir->flags |= DIR_COLLECT_KILLED_ONLY;
- fill_directory(dir, &pathspec);
+ fill_directory(dir, &the_index, &pathspec);
if (show_others)
show_other_files(dir);
if (show_killed)
@@ -414,14 +414,14 @@ static void prune_cache(const char *prefix, size_t prefixlen)
void overlay_tree_on_cache(const char *tree_name, const char *prefix)
{
struct tree *tree;
- unsigned char sha1[20];
+ struct object_id oid;
struct pathspec pathspec;
struct cache_entry *last_stage0 = NULL;
int i;
- if (get_sha1(tree_name, sha1))
+ if (get_oid(tree_name, &oid))
die("tree-ish %s not found.", tree_name);
- tree = parse_tree_indirect(sha1);
+ tree = parse_tree_indirect(&oid);
if (!tree)
die("bad tree-ish %s", tree_name);
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index d7ebeb4..ee7b293 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -119,7 +119,7 @@ static int show_tree(const unsigned char *sha1, struct strbuf *base,
int cmd_ls_tree(int argc, const char **argv, const char *prefix)
{
- unsigned char sha1[20];
+ struct object_id oid;
struct tree *tree;
int i, full_tree = 0;
const struct option ls_tree_options[] = {
@@ -164,7 +164,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
if (argc < 1)
usage_with_options(ls_tree_usage, ls_tree_options);
- if (get_sha1(argv[0], sha1))
+ if (get_oid(argv[0], &oid))
die("Not a valid object name %s", argv[0]);
/*
@@ -180,7 +180,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
for (i = 0; i < pathspec.nr; i++)
pathspec.items[i].nowildcard_len = pathspec.items[i].len;
pathspec.has_wildcard = 0;
- tree = parse_tree_indirect(sha1);
+ tree = parse_tree_indirect(&oid);
if (!tree)
die("not a tree object");
return !!read_tree_recursive(tree, "", 0, 0, &pathspec, show_tree, NULL);
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index cfe2a79..0c36a70 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -41,7 +41,7 @@ static struct commit *get_commit_reference(const char *arg)
if (get_oid(arg, &revkey))
die("Not a valid object name %s", arg);
- r = lookup_commit_reference(revkey.hash);
+ r = lookup_commit_reference(&revkey);
if (!r)
die("Not a valid commit name %s", arg);
@@ -120,7 +120,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
if (is_null_oid(oid))
return;
- commit = lookup_commit(oid->hash);
+ commit = lookup_commit(oid);
if (!commit ||
(commit->object.flags & TMP_MARK) ||
parse_commit(commit))
@@ -132,7 +132,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
}
static int collect_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
- const char *ident, unsigned long timestamp,
+ const char *ident, timestamp_t timestamp,
int tz, const char *message, void *cbdata)
{
struct rev_collect *revs = cbdata;
@@ -168,7 +168,7 @@ static int handle_fork_point(int argc, const char **argv)
if (get_oid(commitname, &oid))
die("Not a valid object name: '%s'", commitname);
- derived = lookup_commit_reference(oid.hash);
+ derived = lookup_commit_reference(&oid);
memset(&revs, 0, sizeof(revs));
revs.initial = 1;
for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 5b7ab9b..bad6735 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -161,14 +161,14 @@ static int both_empty(struct name_entry *a, struct name_entry *b)
return !(a->oid || b->oid);
}
-static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsigned char *sha1, const char *path)
+static struct merge_list *create_entry(unsigned stage, unsigned mode, const struct object_id *oid, const char *path)
{
struct merge_list *res = xcalloc(1, sizeof(*res));
res->stage = stage;
res->path = path;
res->mode = mode;
- res->blob = lookup_blob(sha1);
+ res->blob = lookup_blob(oid);
return res;
}
@@ -188,8 +188,8 @@ static void resolve(const struct traverse_info *info, struct name_entry *ours, s
return;
path = traverse_path(info, result);
- orig = create_entry(2, ours->mode, ours->oid->hash, path);
- final = create_entry(0, result->mode, result->oid->hash, path);
+ orig = create_entry(2, ours->mode, ours->oid, path);
+ final = create_entry(0, result->mode, result->oid, path);
final->link = orig;
@@ -239,7 +239,7 @@ static struct merge_list *link_entry(unsigned stage, const struct traverse_info
path = entry->path;
else
path = traverse_path(info, n);
- link = create_entry(stage, n->mode, n->oid->hash, path);
+ link = create_entry(stage, n->mode, n->oid, path);
link->link = entry;
return link;
}
diff --git a/builtin/merge.c b/builtin/merge.c
index 703827f..a4a098f 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -605,13 +605,13 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head,
opts.verbose_update = 1;
opts.trivial_merges_only = 1;
opts.merge = 1;
- trees[nr_trees] = parse_tree_indirect(common->hash);
+ trees[nr_trees] = parse_tree_indirect(common);
if (!trees[nr_trees++])
return -1;
- trees[nr_trees] = parse_tree_indirect(head->hash);
+ trees[nr_trees] = parse_tree_indirect(head);
if (!trees[nr_trees++])
return -1;
- trees[nr_trees] = parse_tree_indirect(one->hash);
+ trees[nr_trees] = parse_tree_indirect(one);
if (!trees[nr_trees++])
return -1;
opts.fn = threeway_merge;
@@ -1123,7 +1123,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
if (!branch || is_null_oid(&head_oid))
head_commit = NULL;
else
- head_commit = lookup_commit_or_die(head_oid.hash, "HEAD");
+ head_commit = lookup_commit_or_die(&head_oid, "HEAD");
init_diff_ui_defaults();
git_config(git_merge_config, NULL);
@@ -1372,8 +1372,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
}
- if (checkout_fast_forward(head_commit->object.oid.hash,
- commit->object.oid.hash,
+ if (checkout_fast_forward(&head_commit->object.oid,
+ &commit->object.oid,
overwrite_ignore)) {
ret = 1;
goto done;
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index e7a3fe7..b7afffe 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -10,7 +10,7 @@
typedef struct rev_name {
const char *tip_name;
- unsigned long taggerdate;
+ timestamp_t taggerdate;
int generation;
int distance;
} rev_name;
@@ -21,7 +21,7 @@ static long cutoff = LONG_MAX;
#define MERGE_TRAVERSAL_WEIGHT 65535
static void name_rev(struct commit *commit,
- const char *tip_name, unsigned long taggerdate,
+ const char *tip_name, timestamp_t taggerdate,
int generation, int distance,
int deref)
{
@@ -117,7 +117,7 @@ struct name_ref_data {
static struct tip_table {
struct tip_table_entry {
- unsigned char sha1[20];
+ struct object_id oid;
const char *refname;
} *table;
int nr;
@@ -125,13 +125,13 @@ static struct tip_table {
int sorted;
} tip_table;
-static void add_to_tip_table(const unsigned char *sha1, const char *refname,
+static void add_to_tip_table(const struct object_id *oid, const char *refname,
int shorten_unambiguous)
{
refname = name_ref_abbrev(refname, shorten_unambiguous);
ALLOC_GROW(tip_table.table, tip_table.nr + 1, tip_table.alloc);
- hashcpy(tip_table.table[tip_table.nr].sha1, sha1);
+ oidcpy(&tip_table.table[tip_table.nr].oid, oid);
tip_table.table[tip_table.nr].refname = xstrdup(refname);
tip_table.nr++;
tip_table.sorted = 0;
@@ -140,16 +140,16 @@ static void add_to_tip_table(const unsigned char *sha1, const char *refname,
static int tipcmp(const void *a_, const void *b_)
{
const struct tip_table_entry *a = a_, *b = b_;
- return hashcmp(a->sha1, b->sha1);
+ return oidcmp(&a->oid, &b->oid);
}
static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
{
- struct object *o = parse_object(oid->hash);
+ struct object *o = parse_object(oid);
struct name_ref_data *data = cb_data;
int can_abbreviate_output = data->tags_only && data->name_only;
int deref = 0;
- unsigned long taggerdate = ULONG_MAX;
+ timestamp_t taggerdate = TIME_MAX;
if (data->tags_only && !starts_with(path, "refs/tags/"))
return 0;
@@ -197,13 +197,13 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo
return 0;
}
- add_to_tip_table(oid->hash, path, can_abbreviate_output);
+ add_to_tip_table(oid, path, can_abbreviate_output);
while (o && o->type == OBJ_TAG) {
struct tag *t = (struct tag *) o;
if (!t->tagged)
break; /* broken repository */
- o = parse_object(t->tagged->oid.hash);
+ o = parse_object(&t->tagged->oid);
deref = 1;
taggerdate = t->date;
}
@@ -219,7 +219,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo
static const unsigned char *nth_tip_table_ent(size_t ix, void *table_)
{
struct tip_table_entry *table = table_;
- return table[ix].sha1;
+ return table[ix].oid.hash;
}
static const char *get_exact_ref_match(const struct object *o)
@@ -304,9 +304,9 @@ static void name_rev_line(char *p, struct name_ref_data *data)
#define ishex(x) (isdigit((x)) || ((x) >= 'a' && (x) <= 'f'))
if (!ishex(*p))
forty = 0;
- else if (++forty == 40 &&
+ else if (++forty == GIT_SHA1_HEXSZ &&
!ishex(*(p+1))) {
- unsigned char sha1[40];
+ struct object_id oid;
const char *name = NULL;
char c = *(p+1);
int p_len = p - p_start + 1;
@@ -314,9 +314,9 @@ static void name_rev_line(char *p, struct name_ref_data *data)
forty = 0;
*(p+1) = 0;
- if (!get_sha1(p - 39, sha1)) {
+ if (!get_oid(p - (GIT_SHA1_HEXSZ - 1), &oid)) {
struct object *o =
- lookup_object(sha1);
+ lookup_object(oid.hash);
if (o)
name = get_rev_name(o, &buf);
}
@@ -326,7 +326,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)
continue;
if (data->name_only)
- printf("%.*s%s", p_len - 40, p_start, name);
+ printf("%.*s%s", p_len - GIT_SHA1_HEXSZ, p_start, name);
else
printf("%.*s (%s)", p_len, p_start, name);
p_start = p + 1;
@@ -377,18 +377,18 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
cutoff = 0;
for (; argc; argc--, argv++) {
- unsigned char sha1[20];
+ struct object_id oid;
struct object *object;
struct commit *commit;
- if (get_sha1(*argv, sha1)) {
+ if (get_oid(*argv, &oid)) {
fprintf(stderr, "Could not get sha1 for %s. Skipping.\n",
*argv);
continue;
}
commit = NULL;
- object = parse_object(sha1);
+ object = parse_object(&oid);
if (object) {
struct object *peeled = deref_tag(object, *argv, 0);
if (peeled && peeled->type == OBJ_COMMIT)
diff --git a/builtin/notes.c b/builtin/notes.c
index 7b89147..f2847c4 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -706,7 +706,7 @@ static int merge_commit(struct notes_merge_options *o)
if (get_oid("NOTES_MERGE_PARTIAL", &oid))
die(_("failed to read ref NOTES_MERGE_PARTIAL"));
- else if (!(partial = lookup_commit_reference(oid.hash)))
+ else if (!(partial = lookup_commit_reference(&oid)))
die(_("could not find commit from NOTES_MERGE_PARTIAL."));
else if (parse_commit(partial))
die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 0fe35d1..8043904 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -44,7 +44,7 @@ static uint32_t nr_result, nr_written;
static int non_empty;
static int reuse_delta = 1, reuse_object = 1;
static int keep_unreachable, unpack_unreachable, include_tag;
-static unsigned long unpack_unreachable_expiration;
+static timestamp_t unpack_unreachable_expiration;
static int pack_loose_unreachable;
static int local;
static int have_non_local_packs;
@@ -106,12 +106,14 @@ static void *get_delta(struct object_entry *entry)
void *buf, *base_buf, *delta_buf;
enum object_type type;
- buf = read_sha1_file(entry->idx.sha1, &type, &size);
+ buf = read_sha1_file(entry->idx.oid.hash, &type, &size);
if (!buf)
- die("unable to read %s", sha1_to_hex(entry->idx.sha1));
- base_buf = read_sha1_file(entry->delta->idx.sha1, &type, &base_size);
+ die("unable to read %s", oid_to_hex(&entry->idx.oid));
+ base_buf = read_sha1_file(entry->delta->idx.oid.hash, &type,
+ &base_size);
if (!base_buf)
- die("unable to read %s", sha1_to_hex(entry->delta->idx.sha1));
+ die("unable to read %s",
+ oid_to_hex(&entry->delta->idx.oid));
delta_buf = diff_delta(base_buf, base_size,
buf, size, &delta_size, 0);
if (!delta_buf || delta_size != entry->delta_size)
@@ -249,12 +251,14 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
if (!usable_delta) {
if (entry->type == OBJ_BLOB &&
entry->size > big_file_threshold &&
- (st = open_istream(entry->idx.sha1, &type, &size, NULL)) != NULL)
+ (st = open_istream(entry->idx.oid.hash, &type, &size, NULL)) != NULL)
buf = NULL;
else {
- buf = read_sha1_file(entry->idx.sha1, &type, &size);
+ buf = read_sha1_file(entry->idx.oid.hash, &type,
+ &size);
if (!buf)
- die(_("unable to read %s"), sha1_to_hex(entry->idx.sha1));
+ die(_("unable to read %s"),
+ oid_to_hex(&entry->idx.oid));
}
/*
* make sure no cached delta data remains from a
@@ -322,7 +326,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
return 0;
}
sha1write(f, header, hdrlen);
- sha1write(f, entry->delta->idx.sha1, 20);
+ sha1write(f, entry->delta->idx.oid.hash, 20);
hdrlen += 20;
} else {
if (limit && hdrlen + datalen + 20 >= limit) {
@@ -334,7 +338,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
sha1write(f, header, hdrlen);
}
if (st) {
- datalen = write_large_blob_data(st, f, entry->idx.sha1);
+ datalen = write_large_blob_data(st, f, entry->idx.oid.hash);
close_istream(st);
} else {
sha1write(f, buf, datalen);
@@ -369,7 +373,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
datalen = revidx[1].offset - offset;
if (!pack_to_stdout && p->index_version > 1 &&
check_pack_crc(p, &w_curs, offset, datalen, revidx->nr)) {
- error("bad packed object CRC for %s", sha1_to_hex(entry->idx.sha1));
+ error("bad packed object CRC for %s",
+ oid_to_hex(&entry->idx.oid));
unuse_pack(&w_curs);
return write_no_reuse_object(f, entry, limit, usable_delta);
}
@@ -379,7 +384,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
if (!pack_to_stdout && p->index_version == 1 &&
check_pack_inflate(p, &w_curs, offset, datalen, entry->size)) {
- error("corrupt packed object for %s", sha1_to_hex(entry->idx.sha1));
+ error("corrupt packed object for %s",
+ oid_to_hex(&entry->idx.oid));
unuse_pack(&w_curs);
return write_no_reuse_object(f, entry, limit, usable_delta);
}
@@ -404,7 +410,7 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
return 0;
}
sha1write(f, header, hdrlen);
- sha1write(f, entry->delta->idx.sha1, 20);
+ sha1write(f, entry->delta->idx.oid.hash, 20);
hdrlen += 20;
reused_delta++;
} else {
@@ -509,7 +515,7 @@ static enum write_one_status write_one(struct sha1file *f,
recursing = (e->idx.offset == 1);
if (recursing) {
warning("recursive delta detected for object %s",
- sha1_to_hex(e->idx.sha1));
+ oid_to_hex(&e->idx.oid));
return WRITE_ONE_RECURSIVE;
} else if (e->idx.offset || e->preferred_base) {
/* offset is non zero if object is written already. */
@@ -1432,7 +1438,7 @@ static void check_object(struct object_entry *entry)
ofs += 1;
if (!ofs || MSB(ofs, 7)) {
error("delta base offset overflow in pack for %s",
- sha1_to_hex(entry->idx.sha1));
+ oid_to_hex(&entry->idx.oid));
goto give_up;
}
c = buf[used_0++];
@@ -1441,7 +1447,7 @@ static void check_object(struct object_entry *entry)
ofs = entry->in_pack_offset - ofs;
if (ofs <= 0 || ofs >= entry->in_pack_offset) {
error("delta base offset out of bound for %s",
- sha1_to_hex(entry->idx.sha1));
+ oid_to_hex(&entry->idx.oid));
goto give_up;
}
if (reuse_delta && !entry->preferred_base) {
@@ -1498,7 +1504,7 @@ static void check_object(struct object_entry *entry)
unuse_pack(&w_curs);
}
- entry->type = sha1_object_info(entry->idx.sha1, &entry->size);
+ entry->type = sha1_object_info(entry->idx.oid.hash, &entry->size);
/*
* The error condition is checked in prepare_pack(). This is
* to permit a missing preferred base object to be ignored
@@ -1514,7 +1520,7 @@ static int pack_offset_sort(const void *_a, const void *_b)
/* avoid filesystem trashing with loose objects */
if (!a->in_pack && !b->in_pack)
- return hashcmp(a->idx.sha1, b->idx.sha1);
+ return oidcmp(&a->idx.oid, &b->idx.oid);
if (a->in_pack < b->in_pack)
return -1;
@@ -1560,7 +1566,8 @@ static void drop_reused_delta(struct object_entry *entry)
* And if that fails, the error will be recorded in entry->type
* and dealt with in prepare_pack().
*/
- entry->type = sha1_object_info(entry->idx.sha1, &entry->size);
+ entry->type = sha1_object_info(entry->idx.oid.hash,
+ &entry->size);
}
}
@@ -1852,26 +1859,29 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
/* Load data if not already done */
if (!trg->data) {
read_lock();
- trg->data = read_sha1_file(trg_entry->idx.sha1, &type, &sz);
+ trg->data = read_sha1_file(trg_entry->idx.oid.hash, &type,
+ &sz);
read_unlock();
if (!trg->data)
die("object %s cannot be read",
- sha1_to_hex(trg_entry->idx.sha1));
+ oid_to_hex(&trg_entry->idx.oid));
if (sz != trg_size)
die("object %s inconsistent object length (%lu vs %lu)",
- sha1_to_hex(trg_entry->idx.sha1), sz, trg_size);
+ oid_to_hex(&trg_entry->idx.oid), sz,
+ trg_size);
*mem_usage += sz;
}
if (!src->data) {
read_lock();
- src->data = read_sha1_file(src_entry->idx.sha1, &type, &sz);
+ src->data = read_sha1_file(src_entry->idx.oid.hash, &type,
+ &sz);
read_unlock();
if (!src->data) {
if (src_entry->preferred_base) {
static int warned = 0;
if (!warned++)
warning("object %s cannot be read",
- sha1_to_hex(src_entry->idx.sha1));
+ oid_to_hex(&src_entry->idx.oid));
/*
* Those objects are not included in the
* resulting pack. Be resilient and ignore
@@ -1881,11 +1891,12 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
return 0;
}
die("object %s cannot be read",
- sha1_to_hex(src_entry->idx.sha1));
+ oid_to_hex(&src_entry->idx.oid));
}
if (sz != src_size)
die("object %s inconsistent object length (%lu vs %lu)",
- sha1_to_hex(src_entry->idx.sha1), sz, src_size);
+ oid_to_hex(&src_entry->idx.oid), sz,
+ src_size);
*mem_usage += sz;
}
if (!src->index) {
@@ -2337,7 +2348,7 @@ static void add_tag_chain(const struct object_id *oid)
if (packlist_find(&to_pack, oid->hash, NULL))
return;
- tag = lookup_tag(oid->hash);
+ tag = lookup_tag(oid);
while (1) {
if (!tag || parse_tag(tag) || !tag->tagged)
die("unable to pack objects reachable from tag %s",
@@ -2406,7 +2417,7 @@ static void prepare_pack(int window, int depth)
nr_deltas++;
if (entry->type < 0)
die("unable to get type of object %s",
- sha1_to_hex(entry->idx.sha1));
+ oid_to_hex(&entry->idx.oid));
} else {
if (entry->type < 0) {
/*
@@ -2675,7 +2686,7 @@ static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)
static struct oid_array recent_objects;
static int loosened_object_can_be_discarded(const struct object_id *oid,
- unsigned long mtime)
+ timestamp_t mtime)
{
if (!unpack_unreachable_expiration)
return 0;
@@ -2717,7 +2728,11 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
*/
static int pack_options_allow_reuse(void)
{
- return pack_to_stdout && allow_ofs_delta;
+ return pack_to_stdout &&
+ allow_ofs_delta &&
+ !ignore_packed_keep &&
+ (!local || !have_non_local_packs) &&
+ !incremental;
}
static int get_object_list_from_bitmap(struct rev_info *revs)
@@ -2777,10 +2792,10 @@ static void get_object_list(int ac, const char **av)
continue;
}
if (starts_with(line, "--shallow ")) {
- unsigned char sha1[20];
- if (get_sha1_hex(line + 10, sha1))
+ struct object_id oid;
+ if (get_oid_hex(line + 10, &oid))
die("not an SHA-1 '%s'", line + 10);
- register_shallow(sha1);
+ register_shallow(&oid);
use_bitmap_index = 0;
continue;
}
diff --git a/builtin/prune.c b/builtin/prune.c
index 42633e0..f0e2bff 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -13,7 +13,7 @@ static const char * const prune_usage[] = {
};
static int show_only;
static int verbose;
-static unsigned long expire;
+static timestamp_t expire;
static int show_progress = -1;
static int prune_tmp_file(const char *fullpath)
@@ -111,7 +111,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
};
char *s;
- expire = ULONG_MAX;
+ expire = TIME_MAX;
save_commit_buffer = 0;
check_replace_refs = 0;
ref_paranoia = 1;
@@ -123,11 +123,12 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
die(_("cannot prune in a precious-objects repo"));
while (argc--) {
- unsigned char sha1[20];
+ struct object_id oid;
const char *name = *argv++;
- if (!get_sha1(name, sha1)) {
- struct object *object = parse_object_or_die(sha1, name);
+ if (!get_oid(name, &oid)) {
+ struct object *object = parse_object_or_die(&oid,
+ name);
add_pending_object(&revs, object, "");
}
else
diff --git a/builtin/pull.c b/builtin/pull.c
index dd1a4a9..318c273 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -523,7 +523,7 @@ static int pull_into_void(const struct object_id *merge_head,
* index/worktree changes that the user already made on the unborn
* branch.
*/
- if (checkout_fast_forward(EMPTY_TREE_SHA1_BIN, merge_head->hash, 0))
+ if (checkout_fast_forward(&empty_tree_oid, merge_head, 0))
return 1;
if (update_ref("initial pull", "HEAD", merge_head->hash, curr_head->hash, 0, UPDATE_REFS_DIE_ON_ERR))
@@ -698,10 +698,10 @@ static int get_octopus_merge_base(struct object_id *merge_base,
{
struct commit_list *revs = NULL, *result;
- commit_list_insert(lookup_commit_reference(curr_head->hash), &revs);
- commit_list_insert(lookup_commit_reference(merge_head->hash), &revs);
+ commit_list_insert(lookup_commit_reference(curr_head), &revs);
+ commit_list_insert(lookup_commit_reference(merge_head), &revs);
if (!is_null_oid(fork_point))
- commit_list_insert(lookup_commit_reference(fork_point->hash), &revs);
+ commit_list_insert(lookup_commit_reference(fork_point), &revs);
result = reduce_heads(get_octopus_merge_bases(revs));
free_commit_list(revs);
@@ -839,7 +839,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
"fast-forwarding your working tree from\n"
"commit %s."), oid_to_hex(&orig_head));
- if (checkout_fast_forward(orig_head.hash, curr_head.hash, 0))
+ if (checkout_fast_forward(&orig_head, &curr_head, 0))
die(_("Cannot fast-forward your working tree.\n"
"After making sure that you saved anything precious from\n"
"$ git diff %s\n"
@@ -865,9 +865,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
struct commit_list *list = NULL;
struct commit *merge_head, *head;
- head = lookup_commit_reference(orig_head.hash);
+ head = lookup_commit_reference(&orig_head);
commit_list_insert(head, &list);
- merge_head = lookup_commit_reference(merge_heads.oid[0].hash);
+ merge_head = lookup_commit_reference(&merge_heads.oid[0]);
if (is_descendant_of(merge_head, list)) {
/* we can fast-forward this without invoking rebase */
opt_ff = "--ff-only";
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 23e212e..6d45175 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -23,13 +23,13 @@ static int read_empty;
static struct tree *trees[MAX_UNPACK_TREES];
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
-static int list_tree(unsigned char *sha1)
+static int list_tree(struct object_id *oid)
{
struct tree *tree;
if (nr_trees >= MAX_UNPACK_TREES)
die("I cannot read more than %d trees", MAX_UNPACK_TREES);
- tree = parse_tree_indirect(sha1);
+ tree = parse_tree_indirect(oid);
if (!tree)
return -1;
trees[nr_trees++] = tree;
@@ -121,7 +121,7 @@ static struct lock_file lock_file;
int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
{
int i, stage = 0;
- unsigned char sha1[20];
+ struct object_id oid;
struct tree_desc t[MAX_UNPACK_TREES];
struct unpack_trees_options opts;
int prefix_set = 0;
@@ -204,9 +204,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
for (i = 0; i < argc; i++) {
const char *arg = argv[i];
- if (get_sha1(arg, sha1))
+ if (get_oid(arg, &oid))
die("Not a valid object name %s", arg);
- if (list_tree(sha1) < 0)
+ if (list_tree(&oid) < 0)
die("failed to unpack tree object %s", arg);
stage++;
}
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 48c07dd..b1706a5 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -78,7 +78,7 @@ static const char *NONCE_OK = "OK";
static const char *NONCE_SLOP = "SLOP";
static const char *nonce_status;
static long nonce_stamp_slop;
-static unsigned long nonce_stamp_slop_limit;
+static timestamp_t nonce_stamp_slop_limit;
static struct ref_transaction *transaction;
static enum {
@@ -454,17 +454,17 @@ static void hmac_sha1(unsigned char *out,
git_SHA1_Final(out, &ctx);
}
-static char *prepare_push_cert_nonce(const char *path, unsigned long stamp)
+static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp)
{
struct strbuf buf = STRBUF_INIT;
unsigned char sha1[20];
- strbuf_addf(&buf, "%s:%lu", path, stamp);
+ strbuf_addf(&buf, "%s:%"PRItime, path, stamp);
hmac_sha1(sha1, buf.buf, buf.len, cert_nonce_seed, strlen(cert_nonce_seed));;
strbuf_release(&buf);
/* RFC 2104 5. HMAC-SHA1-80 */
- strbuf_addf(&buf, "%lu-%.*s", stamp, 20, sha1_to_hex(sha1));
+ strbuf_addf(&buf, "%"PRItime"-%.*s", stamp, 20, sha1_to_hex(sha1));
return strbuf_detach(&buf, NULL);
}
@@ -473,7 +473,8 @@ static char *prepare_push_cert_nonce(const char *path, unsigned long stamp)
* after dropping "_commit" from its name and possibly moving it out
* of commit.c
*/
-static char *find_header(const char *msg, size_t len, const char *key)
+static char *find_header(const char *msg, size_t len, const char *key,
+ const char **next_line)
{
int key_len = strlen(key);
const char *line = msg;
@@ -486,6 +487,8 @@ static char *find_header(const char *msg, size_t len, const char *key)
if (line + key_len < eol &&
!memcmp(line, key, key_len) && line[key_len] == ' ') {
int offset = key_len + 1;
+ if (next_line)
+ *next_line = *eol ? eol + 1 : eol;
return xmemdupz(line + offset, (eol - line) - offset);
}
line = *eol ? eol + 1 : NULL;
@@ -495,8 +498,8 @@ static char *find_header(const char *msg, size_t len, const char *key)
static const char *check_nonce(const char *buf, size_t len)
{
- char *nonce = find_header(buf, len, "nonce");
- unsigned long stamp, ostamp;
+ char *nonce = find_header(buf, len, "nonce", NULL);
+ timestamp_t stamp, ostamp;
char *bohmac, *expect = NULL;
const char *retval = NONCE_BAD;
@@ -534,7 +537,7 @@ static const char *check_nonce(const char *buf, size_t len)
retval = NONCE_BAD;
goto leave;
}
- stamp = strtoul(nonce, &bohmac, 10);
+ stamp = parse_timestamp(nonce, &bohmac, 10);
if (bohmac == nonce || bohmac[0] != '-') {
retval = NONCE_BAD;
goto leave;
@@ -552,7 +555,7 @@ static const char *check_nonce(const char *buf, size_t len)
* would mean it was issued by another server with its clock
* skewed in the future.
*/
- ostamp = strtoul(push_cert_nonce, NULL, 10);
+ ostamp = parse_timestamp(push_cert_nonce, NULL, 10);
nonce_stamp_slop = (long)ostamp - (long)stamp;
if (nonce_stamp_slop_limit &&
@@ -575,6 +578,45 @@ leave:
return retval;
}
+/*
+ * Return 1 if there is no push_cert or if the push options in push_cert are
+ * the same as those in the argument; 0 otherwise.
+ */
+static int check_cert_push_options(const struct string_list *push_options)
+{
+ const char *buf = push_cert.buf;
+ int len = push_cert.len;
+
+ char *option;
+ const char *next_line;
+ int options_seen = 0;
+
+ int retval = 1;
+
+ if (!len)
+ return 1;
+
+ while ((option = find_header(buf, len, "push-option", &next_line))) {
+ len -= (next_line - buf);
+ buf = next_line;
+ options_seen++;
+ if (options_seen > push_options->nr
+ || strcmp(option,
+ push_options->items[options_seen - 1].string)) {
+ retval = 0;
+ goto leave;
+ }
+ free(option);
+ }
+
+ if (options_seen != push_options->nr)
+ retval = 0;
+
+leave:
+ free(option);
+ return retval;
+}
+
static void prepare_push_cert_sha1(struct child_process *proc)
{
static int already_done;
@@ -858,7 +900,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)
* not lose these new roots..
*/
for (i = 0; i < extra.nr; i++)
- register_shallow(extra.oid[i].hash);
+ register_shallow(&extra.oid[i]);
si->shallow_ref[cmd->index] = 0;
oid_array_clear(&extra);
@@ -1060,8 +1102,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
struct object *old_object, *new_object;
struct commit *old_commit, *new_commit;
- old_object = parse_object(old_oid->hash);
- new_object = parse_object(new_oid->hash);
+ old_object = parse_object(old_oid);
+ new_object = parse_object(new_oid);
if (!old_object || !new_object ||
old_object->type != OBJ_COMMIT ||
@@ -1084,7 +1126,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
if (is_null_oid(new_oid)) {
struct strbuf err = STRBUF_INIT;
- if (!parse_object(old_oid->hash)) {
+ if (!parse_object(old_oid)) {
old_oid = NULL;
if (ref_exists(name)) {
rp_warning("Allowing deletion of corrupt ref.");
@@ -1931,6 +1973,11 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
if (use_push_options)
read_push_options(&push_options);
+ if (!check_cert_push_options(&push_options)) {
+ struct command *cmd;
+ for (cmd = commands; cmd; cmd = cmd->next)
+ cmd->error_string = "inconsistent push options";
+ }
prepare_shallow_info(&si, &shallow);
if (!si.nr_ours && !si.nr_theirs)
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 7472775..920c16d 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -16,14 +16,14 @@ static const char reflog_delete_usage[] =
static const char reflog_exists_usage[] =
"git reflog exists <ref>";
-static unsigned long default_reflog_expire;
-static unsigned long default_reflog_expire_unreachable;
+static timestamp_t default_reflog_expire;
+static timestamp_t default_reflog_expire_unreachable;
struct cmd_reflog_expire_cb {
struct rev_info revs;
int stalefix;
- unsigned long expire_total;
- unsigned long expire_unreachable;
+ timestamp_t expire_total;
+ timestamp_t expire_unreachable;
int recno;
};
@@ -55,14 +55,14 @@ struct collect_reflog_cb {
#define STUDYING (1u<<11)
#define REACHABLE (1u<<12)
-static int tree_is_complete(const unsigned char *sha1)
+static int tree_is_complete(const struct object_id *oid)
{
struct tree_desc desc;
struct name_entry entry;
int complete;
struct tree *tree;
- tree = lookup_tree(sha1);
+ tree = lookup_tree(oid);
if (!tree)
return 0;
if (tree->object.flags & SEEN)
@@ -73,7 +73,7 @@ static int tree_is_complete(const unsigned char *sha1)
if (!tree->buffer) {
enum object_type type;
unsigned long size;
- void *data = read_sha1_file(sha1, &type, &size);
+ void *data = read_sha1_file(oid->hash, &type, &size);
if (!data) {
tree->object.flags |= INCOMPLETE;
return 0;
@@ -85,7 +85,7 @@ static int tree_is_complete(const unsigned char *sha1)
complete = 1;
while (tree_entry(&desc, &entry)) {
if (!has_sha1_file(entry.oid->hash) ||
- (S_ISDIR(entry.mode) && !tree_is_complete(entry.oid->hash))) {
+ (S_ISDIR(entry.mode) && !tree_is_complete(entry.oid))) {
tree->object.flags |= INCOMPLETE;
complete = 0;
}
@@ -126,7 +126,7 @@ static int commit_is_complete(struct commit *commit)
struct commit_list *parent;
c = (struct commit *)study.objects[--study.nr].item;
- if (!c->object.parsed && !parse_object(c->object.oid.hash))
+ if (!c->object.parsed && !parse_object(&c->object.oid))
c->object.flags |= INCOMPLETE;
if (c->object.flags & INCOMPLETE) {
@@ -152,7 +152,7 @@ static int commit_is_complete(struct commit *commit)
for (i = 0; i < found.nr; i++) {
struct commit *c =
(struct commit *)found.objects[i].item;
- if (!tree_is_complete(c->tree->object.oid.hash)) {
+ if (!tree_is_complete(&c->tree->object.oid)) {
is_incomplete = 1;
c->object.flags |= INCOMPLETE;
}
@@ -186,13 +186,13 @@ static int commit_is_complete(struct commit *commit)
return !is_incomplete;
}
-static int keep_entry(struct commit **it, unsigned char *sha1)
+static int keep_entry(struct commit **it, struct object_id *oid)
{
struct commit *commit;
- if (is_null_sha1(sha1))
+ if (is_null_oid(oid))
return 1;
- commit = lookup_commit_reference_gently(sha1, 1);
+ commit = lookup_commit_reference_gently(oid, 1);
if (!commit)
return 0;
@@ -219,7 +219,7 @@ static int keep_entry(struct commit **it, unsigned char *sha1)
static void mark_reachable(struct expire_reflog_policy_cb *cb)
{
struct commit_list *pending;
- unsigned long expire_limit = cb->mark_limit;
+ timestamp_t expire_limit = cb->mark_limit;
struct commit_list *leftover = NULL;
for (pending = cb->mark_list; pending; pending = pending->next)
@@ -251,17 +251,17 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb)
cb->mark_list = leftover;
}
-static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit, unsigned char *sha1)
+static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit, struct object_id *oid)
{
/*
* We may or may not have the commit yet - if not, look it
* up using the supplied sha1.
*/
if (!commit) {
- if (is_null_sha1(sha1))
+ if (is_null_oid(oid))
return 0;
- commit = lookup_commit_reference_gently(sha1, 1);
+ commit = lookup_commit_reference_gently(oid, 1);
/* Not a commit -- keep it */
if (!commit)
@@ -283,8 +283,8 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit
/*
* Return true iff the specified reflog entry should be expired.
*/
-static int should_expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
- const char *email, unsigned long timestamp, int tz,
+static int should_expire_reflog_ent(struct object_id *ooid, struct object_id *noid,
+ const char *email, timestamp_t timestamp, int tz,
const char *message, void *cb_data)
{
struct expire_reflog_policy_cb *cb = cb_data;
@@ -295,13 +295,13 @@ static int should_expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
old = new = NULL;
if (cb->cmd.stalefix &&
- (!keep_entry(&old, osha1) || !keep_entry(&new, nsha1)))
+ (!keep_entry(&old, ooid) || !keep_entry(&new, noid)))
return 1;
if (timestamp < cb->cmd.expire_unreachable) {
if (cb->unreachable_expire_kind == UE_ALWAYS)
return 1;
- if (unreachable(cb, old, osha1) || unreachable(cb, new, nsha1))
+ if (unreachable(cb, old, ooid) || unreachable(cb, new, noid))
return 1;
}
@@ -318,7 +318,7 @@ static int push_tip_to_list(const char *refname, const struct object_id *oid,
struct commit *tip_commit;
if (flags & REF_ISSYMREF)
return 0;
- tip_commit = lookup_commit_reference_gently(oid->hash, 1);
+ tip_commit = lookup_commit_reference_gently(oid, 1);
if (!tip_commit)
return 0;
commit_list_insert(tip_commit, list);
@@ -326,7 +326,7 @@ static int push_tip_to_list(const char *refname, const struct object_id *oid,
}
static void reflog_expiry_prepare(const char *refname,
- const unsigned char *sha1,
+ const struct object_id *oid,
void *cb_data)
{
struct expire_reflog_policy_cb *cb = cb_data;
@@ -335,7 +335,7 @@ static void reflog_expiry_prepare(const char *refname,
cb->tip_commit = NULL;
cb->unreachable_expire_kind = UE_HEAD;
} else {
- cb->tip_commit = lookup_commit_reference_gently(sha1, 1);
+ cb->tip_commit = lookup_commit_reference_gently(oid, 1);
if (!cb->tip_commit)
cb->unreachable_expire_kind = UE_ALWAYS;
else
@@ -392,8 +392,8 @@ static int collect_reflog(const char *ref, const struct object_id *oid, int unus
static struct reflog_expire_cfg {
struct reflog_expire_cfg *next;
- unsigned long expire_total;
- unsigned long expire_unreachable;
+ timestamp_t expire_total;
+ timestamp_t expire_unreachable;
char pattern[FLEX_ARRAY];
} *reflog_expire_cfg, **reflog_expire_cfg_tail;
@@ -415,7 +415,7 @@ static struct reflog_expire_cfg *find_cfg_ent(const char *pattern, size_t len)
return ent;
}
-static int parse_expire_cfg_value(const char *var, const char *value, unsigned long *expire)
+static int parse_expire_cfg_value(const char *var, const char *value, timestamp_t *expire)
{
if (!value)
return config_error_nonbool(var);
@@ -433,7 +433,7 @@ static int reflog_expire_config(const char *var, const char *value, void *cb)
{
const char *pattern, *key;
int pattern_len;
- unsigned long expire;
+ timestamp_t expire;
int slot;
struct reflog_expire_cfg *ent;
@@ -515,7 +515,7 @@ static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, c
static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
{
struct expire_reflog_policy_cb cb;
- unsigned long now = time(NULL);
+ timestamp_t now = time(NULL);
int i, status, do_all;
int explicit_expiry = 0;
unsigned int flags = 0;
@@ -616,7 +616,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
}
static int count_reflog_ent(struct object_id *ooid, struct object_id *noid,
- const char *email, unsigned long timestamp, int tz,
+ const char *email, timestamp_t timestamp, int tz,
const char *message, void *cb_data)
{
struct expire_reflog_policy_cb *cb = cb_data;
diff --git a/builtin/repack.c b/builtin/repack.c
index 677bc7c..38ba4ef 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -155,6 +155,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
int keep_unreachable = 0;
const char *window = NULL, *window_memory = NULL;
const char *depth = NULL;
+ const char *threads = NULL;
const char *max_pack_size = NULL;
int no_reuse_delta = 0, no_reuse_object = 0;
int no_update_server_info = 0;
@@ -190,6 +191,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
N_("same as the above, but limit memory size instead of entries count")),
OPT_STRING(0, "depth", &depth, N_("n"),
N_("limits the maximum delta depth")),
+ OPT_STRING(0, "threads", &threads, N_("n"),
+ N_("limits the maximum number of threads")),
OPT_STRING(0, "max-pack-size", &max_pack_size, N_("bytes"),
N_("maximum size of each packfile")),
OPT_BOOL(0, "pack-kept-objects", &pack_kept_objects,
@@ -234,6 +237,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
argv_array_pushf(&cmd.args, "--window-memory=%s", window_memory);
if (depth)
argv_array_pushf(&cmd.args, "--depth=%s", depth);
+ if (threads)
+ argv_array_pushf(&cmd.args, "--threads=%s", threads);
if (max_pack_size)
argv_array_pushf(&cmd.args, "--max-pack-size=%s", max_pack_size);
if (no_reuse_delta)
diff --git a/builtin/replace.c b/builtin/replace.c
index ab17668..c921bc9 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -328,7 +328,7 @@ static void replace_parents(struct strbuf *buf, int argc, const char **argv)
struct object_id oid;
if (get_oid(argv[i], &oid) < 0)
die(_("Not a valid object name: '%s'"), argv[i]);
- lookup_commit_or_die(oid.hash, argv[i]);
+ lookup_commit_or_die(&oid, argv[i]);
strbuf_addf(&new_parents, "parent %s\n", oid_to_hex(&oid));
}
@@ -355,7 +355,7 @@ static void check_one_mergetag(struct commit *commit,
int i;
hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), tag_oid.hash);
- tag = lookup_tag(tag_oid.hash);
+ tag = lookup_tag(&tag_oid);
if (!tag)
die(_("bad mergetag in commit '%s'"), ref);
if (parse_tag_buffer(tag, extra->value, extra->len))
@@ -394,7 +394,7 @@ static int create_graft(int argc, const char **argv, int force)
if (get_oid(old_ref, &old) < 0)
die(_("Not a valid object name: '%s'"), old_ref);
- commit = lookup_commit_or_die(old.hash, old_ref);
+ commit = lookup_commit_or_die(&old, old_ref);
buffer = get_commit_buffer(commit, &size);
strbuf_add(&buf, buffer, size);
diff --git a/builtin/reset.c b/builtin/reset.c
index fc3b906..0afe1df 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -21,6 +21,27 @@
#include "parse-options.h"
#include "unpack-trees.h"
#include "cache-tree.h"
+#include "submodule.h"
+#include "submodule-config.h"
+
+static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
+
+static int option_parse_recurse_submodules(const struct option *opt,
+ const char *arg, int unset)
+{
+ if (unset) {
+ recurse_submodules = RECURSE_SUBMODULES_OFF;
+ return 0;
+ }
+ if (arg)
+ recurse_submodules =
+ parse_update_recurse_submodules_arg(opt->long_name,
+ arg);
+ else
+ recurse_submodules = RECURSE_SUBMODULES_ON;
+
+ return 0;
+}
static const char * const git_reset_usage[] = {
N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]"),
@@ -84,7 +105,7 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)
return -1;
if (reset_type == MIXED || reset_type == HARD) {
- tree = parse_tree_indirect(oid->hash);
+ tree = parse_tree_indirect(oid);
prime_cache_tree(&the_index, tree);
}
@@ -154,7 +175,7 @@ static int read_from_tree(const struct pathspec *pathspec,
opt.format_callback = update_index_from_diff;
opt.format_callback_data = &intent_to_add;
- if (do_diff_cache(tree_oid->hash, &opt))
+ if (do_diff_cache(tree_oid, &opt))
return 1;
diffcore_std(&opt);
diff_flush(&opt);
@@ -283,6 +304,9 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
N_("reset HEAD, index and working tree"), MERGE),
OPT_SET_INT(0, "keep", &reset_type,
N_("reset HEAD but keep local changes"), KEEP),
+ { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules,
+ "reset", "control recursive updating of submodules",
+ PARSE_OPT_OPTARG, option_parse_recurse_submodules },
OPT_BOOL('p', "patch", &patch_mode, N_("select hunks interactively")),
OPT_BOOL('N', "intent-to-add", &intent_to_add,
N_("record only the fact that removed paths will be added later")),
@@ -295,6 +319,12 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
PARSE_OPT_KEEP_DASHDASH);
parse_args(&pathspec, argv, prefix, patch_mode, &rev);
+ if (recurse_submodules != RECURSE_SUBMODULES_DEFAULT) {
+ gitmodules_config();
+ git_config(submodule_config, NULL);
+ set_config_update_recurse_submodules(RECURSE_SUBMODULES_ON);
+ }
+
unborn = !strcmp(rev, "HEAD") && get_sha1("HEAD", oid.hash);
if (unborn) {
/* reset on unborn branch: treat as reset to empty tree */
@@ -303,7 +333,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
struct commit *commit;
if (get_sha1_committish(rev, oid.hash))
die(_("Failed to resolve '%s' as a valid revision."), rev);
- commit = lookup_commit_reference(oid.hash);
+ commit = lookup_commit_reference(&oid);
if (!commit)
die(_("Could not parse object '%s'."), rev);
oidcpy(&oid, &commit->object.oid);
@@ -311,7 +341,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
struct tree *tree;
if (get_sha1_treeish(rev, oid.hash))
die(_("Failed to resolve '%s' as a valid tree."), rev);
- tree = parse_tree_indirect(oid.hash);
+ tree = parse_tree_indirect(&oid);
if (!tree)
die(_("Could not parse object '%s'."), rev);
oidcpy(&oid, &tree->object.oid);
@@ -380,7 +410,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
update_ref_status = reset_refs(rev, &oid);
if (reset_type == HARD && !update_ref_status && !quiet)
- print_new_head_line(lookup_commit_reference(oid.hash));
+ print_new_head_line(lookup_commit_reference(&oid));
}
if (!pathspec.nr)
remove_branch_state();
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index bcf77f0..718c605 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -80,7 +80,7 @@ static void show_commit(struct commit *commit, void *data)
}
if (info->show_timestamp)
- printf("%lu ", commit->date);
+ printf("%"PRItime" ", commit->date);
if (info->header_prefix)
fputs(info->header_prefix, stdout);
@@ -181,7 +181,7 @@ static void finish_object(struct object *obj, const char *name, void *cb_data)
if (obj->type == OBJ_BLOB && !has_object_file(&obj->oid))
die("missing blob object '%s'", oid_to_hex(&obj->oid));
if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
- parse_object(obj->oid.hash);
+ parse_object(&obj->oid);
}
static void show_object(struct object *obj, const char *name, void *cb_data)
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 0513330..efdc144 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -121,7 +121,7 @@ static void show_with_type(int type, const char *arg)
}
/* Output a revision, only if filter allows it */
-static void show_rev(int type, const unsigned char *sha1, const char *name)
+static void show_rev(int type, const struct object_id *oid, const char *name)
{
if (!(filter & DO_REVS))
return;
@@ -129,10 +129,10 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
if ((symbolic || abbrev_ref) && name) {
if (symbolic == SHOW_SYMBOLIC_FULL || abbrev_ref) {
- unsigned char discard[20];
+ struct object_id discard;
char *full;
- switch (dwim_ref(name, strlen(name), discard, &full)) {
+ switch (dwim_ref(name, strlen(name), discard.hash, &full)) {
case 0:
/*
* Not found -- not a ref. We could
@@ -158,9 +158,9 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
}
}
else if (abbrev)
- show_with_type(type, find_unique_abbrev(sha1, abbrev));
+ show_with_type(type, find_unique_abbrev(oid->hash, abbrev));
else
- show_with_type(type, sha1_to_hex(sha1));
+ show_with_type(type, oid_to_hex(oid));
}
/* Output a flag, only if filter allows it. */
@@ -180,11 +180,11 @@ static int show_default(void)
const char *s = def;
if (s) {
- unsigned char sha1[20];
+ struct object_id oid;
def = NULL;
- if (!get_sha1(s, sha1)) {
- show_rev(NORMAL, sha1, s);
+ if (!get_oid(s, &oid)) {
+ show_rev(NORMAL, &oid, s);
return 1;
}
}
@@ -195,19 +195,19 @@ static int show_reference(const char *refname, const struct object_id *oid, int
{
if (ref_excluded(ref_excludes, refname))
return 0;
- show_rev(NORMAL, oid->hash, refname);
+ show_rev(NORMAL, oid, refname);
return 0;
}
static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
{
- show_rev(REVERSED, oid->hash, refname);
+ show_rev(REVERSED, oid, refname);
return 0;
}
static int show_abbrev(const struct object_id *oid, void *cb_data)
{
- show_rev(NORMAL, oid->hash, NULL);
+ show_rev(NORMAL, oid, NULL);
return 0;
}
@@ -218,7 +218,7 @@ static void show_datestring(const char *flag, const char *datestr)
/* date handling requires both flags and revs */
if ((filter & (DO_FLAGS | DO_REVS)) != (DO_FLAGS | DO_REVS))
return;
- buffer = xstrfmt("%s%lu", flag, approxidate(datestr));
+ buffer = xstrfmt("%s%"PRItime, flag, approxidate(datestr));
show(buffer);
free(buffer);
}
@@ -242,8 +242,8 @@ static int show_file(const char *arg, int output_prefix)
static int try_difference(const char *arg)
{
char *dotdot;
- unsigned char sha1[20];
- unsigned char end[20];
+ struct object_id oid;
+ struct object_id end;
const char *next;
const char *this;
int symmetric;
@@ -273,18 +273,18 @@ static int try_difference(const char *arg)
return 0;
}
- if (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) {
- show_rev(NORMAL, end, next);
- show_rev(symmetric ? NORMAL : REVERSED, sha1, this);
+ if (!get_sha1_committish(this, oid.hash) && !get_sha1_committish(next, end.hash)) {
+ show_rev(NORMAL, &end, next);
+ show_rev(symmetric ? NORMAL : REVERSED, &oid, this);
if (symmetric) {
struct commit_list *exclude;
struct commit *a, *b;
- a = lookup_commit_reference(sha1);
- b = lookup_commit_reference(end);
+ a = lookup_commit_reference(&oid);
+ b = lookup_commit_reference(&end);
exclude = get_merge_bases(a, b);
while (exclude) {
struct commit *commit = pop_commit(&exclude);
- show_rev(REVERSED, commit->object.oid.hash, NULL);
+ show_rev(REVERSED, &commit->object.oid, NULL);
}
}
*dotdot = '.';
@@ -297,7 +297,7 @@ static int try_difference(const char *arg)
static int try_parent_shorthands(const char *arg)
{
char *dotdot;
- unsigned char sha1[20];
+ struct object_id oid;
struct commit *commit;
struct commit_list *parents;
int parent_number;
@@ -327,12 +327,12 @@ static int try_parent_shorthands(const char *arg)
return 0;
*dotdot = 0;
- if (get_sha1_committish(arg, sha1)) {
+ if (get_sha1_committish(arg, oid.hash)) {
*dotdot = '^';
return 0;
}
- commit = lookup_commit_reference(sha1);
+ commit = lookup_commit_reference(&oid);
if (exclude_parent &&
exclude_parent > commit_list_count(commit->parents)) {
*dotdot = '^';
@@ -340,7 +340,7 @@ static int try_parent_shorthands(const char *arg)
}
if (include_rev)
- show_rev(NORMAL, sha1, arg);
+ show_rev(NORMAL, &oid, arg);
for (parents = commit->parents, parent_number = 1;
parents;
parents = parents->next, parent_number++) {
@@ -352,7 +352,7 @@ static int try_parent_shorthands(const char *arg)
if (symbolic)
name = xstrfmt("%s^%d", arg, parent_number);
show_rev(include_parents ? NORMAL : REVERSED,
- parents->item->object.oid.hash, name);
+ &parents->item->object.oid, name);
free(name);
}
@@ -571,7 +571,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
int did_repo_setup = 0;
int has_dashdash = 0;
int output_prefix = 0;
- unsigned char sha1[20];
+ struct object_id oid;
unsigned int flags = 0;
const char *name = NULL;
struct object_context unused;
@@ -910,11 +910,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
name++;
type = REVERSED;
}
- if (!get_sha1_with_context(name, flags, sha1, &unused)) {
+ if (!get_sha1_with_context(name, flags, oid.hash, &unused)) {
if (verify)
revs_count++;
else
- show_rev(type, sha1, name);
+ show_rev(type, &oid, name);
continue;
}
if (verify)
@@ -929,7 +929,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
strbuf_release(&buf);
if (verify) {
if (revs_count == 1) {
- show_rev(type, sha1, name);
+ show_rev(type, &oid, name);
return 0;
} else if (revs_count == 0 && show_default())
return 0;
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 1975659..4a6cc6f 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -358,7 +358,7 @@ static void sort_ref_range(int bottom, int top)
static int append_ref(const char *refname, const struct object_id *oid,
int allow_dups)
{
- struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
+ struct commit *commit = lookup_commit_reference_gently(oid, 1);
int i;
if (!commit)
@@ -735,7 +735,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
base = strtoul(reflog_base, &ep, 10);
if (*ep) {
/* Ah, that is a date spec... */
- unsigned long at;
+ timestamp_t at;
at = approxidate(reflog_base);
read_ref_at(ref, flags, at, -1, oid.hash, NULL,
NULL, NULL, &base);
@@ -746,7 +746,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
char *logmsg;
char *nth_desc;
const char *msg;
- unsigned long timestamp;
+ timestamp_t timestamp;
int tz;
if (read_ref_at(ref, flags, 0, base+i, oid.hash, &logmsg,
@@ -816,7 +816,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
MAX_REVS), MAX_REVS);
if (get_sha1(ref_name[num_rev], revkey.hash))
die(_("'%s' is not a valid ref."), ref_name[num_rev]);
- commit = lookup_commit_reference(revkey.hash);
+ commit = lookup_commit_reference(&revkey);
if (!commit)
die(_("cannot find commit %s (%s)"),
ref_name[num_rev], oid_to_hex(&revkey));
diff --git a/builtin/tag.c b/builtin/tag.c
index 2224045..1f74a56 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -66,7 +66,7 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con
}
typedef int (*each_tag_name_fn)(const char *name, const char *ref,
- const unsigned char *sha1, const void *cb_data);
+ const struct object_id *oid, const void *cb_data);
static int for_each_tag_name(const char **argv, each_tag_name_fn fn,
const void *cb_data)
@@ -74,17 +74,17 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn,
const char **p;
struct strbuf ref = STRBUF_INIT;
int had_error = 0;
- unsigned char sha1[20];
+ struct object_id oid;
for (p = argv; *p; p++) {
strbuf_reset(&ref);
strbuf_addf(&ref, "refs/tags/%s", *p);
- if (read_ref(ref.buf, sha1)) {
+ if (read_ref(ref.buf, oid.hash)) {
error(_("tag '%s' not found."), *p);
had_error = 1;
continue;
}
- if (fn(*p, ref.buf, sha1, cb_data))
+ if (fn(*p, ref.buf, &oid, cb_data))
had_error = 1;
}
strbuf_release(&ref);
@@ -92,16 +92,16 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn,
}
static int delete_tag(const char *name, const char *ref,
- const unsigned char *sha1, const void *cb_data)
+ const struct object_id *oid, const void *cb_data)
{
- if (delete_ref(NULL, ref, sha1, 0))
+ if (delete_ref(NULL, ref, oid->hash, 0))
return 1;
- printf(_("Deleted tag '%s' (was %s)\n"), name, find_unique_abbrev(sha1, DEFAULT_ABBREV));
+ printf(_("Deleted tag '%s' (was %s)\n"), name, find_unique_abbrev(oid->hash, DEFAULT_ABBREV));
return 0;
}
static int verify_tag(const char *name, const char *ref,
- const unsigned char *sha1, const void *cb_data)
+ const struct object_id *oid, const void *cb_data)
{
int flags;
const char *fmt_pretty = cb_data;
@@ -110,11 +110,11 @@ static int verify_tag(const char *name, const char *ref,
if (fmt_pretty)
flags = GPG_VERIFY_OMIT_STATUS;
- if (gpg_verify_tag(sha1, name, flags))
+ if (gpg_verify_tag(oid->hash, name, flags))
return -1;
if (fmt_pretty)
- pretty_print_ref(name, sha1, fmt_pretty);
+ pretty_print_ref(name, oid->hash, fmt_pretty);
return 0;
}
@@ -182,13 +182,13 @@ static int git_tag_config(const char *var, const char *value, void *cb)
return git_default_config(var, value, cb);
}
-static void write_tag_body(int fd, const unsigned char *sha1)
+static void write_tag_body(int fd, const struct object_id *oid)
{
unsigned long size;
enum object_type type;
char *buf, *sp;
- buf = read_sha1_file(sha1, &type, &size);
+ buf = read_sha1_file(oid->hash, &type, &size);
if (!buf)
return;
/* skip header */
@@ -204,11 +204,11 @@ static void write_tag_body(int fd, const unsigned char *sha1)
free(buf);
}
-static int build_tag_object(struct strbuf *buf, int sign, unsigned char *result)
+static int build_tag_object(struct strbuf *buf, int sign, struct object_id *result)
{
if (sign && do_sign(buf) < 0)
return error(_("unable to sign the tag"));
- if (write_sha1_file(buf->buf, buf->len, tag_type, result) < 0)
+ if (write_sha1_file(buf->buf, buf->len, tag_type, result->hash) < 0)
return error(_("unable to write tag file"));
return 0;
}
@@ -223,15 +223,15 @@ struct create_tag_options {
} cleanup_mode;
};
-static void create_tag(const unsigned char *object, const char *tag,
+static void create_tag(const struct object_id *object, const char *tag,
struct strbuf *buf, struct create_tag_options *opt,
- unsigned char *prev, unsigned char *result)
+ struct object_id *prev, struct object_id *result)
{
enum object_type type;
struct strbuf header = STRBUF_INIT;
char *path = NULL;
- type = sha1_object_info(object, NULL);
+ type = sha1_object_info(object->hash, NULL);
if (type <= OBJ_NONE)
die(_("bad object type."));
@@ -240,7 +240,7 @@ static void create_tag(const unsigned char *object, const char *tag,
"type %s\n"
"tag %s\n"
"tagger %s\n\n",
- sha1_to_hex(object),
+ oid_to_hex(object),
typename(type),
tag,
git_committer_info(IDENT_STRICT));
@@ -254,7 +254,7 @@ static void create_tag(const unsigned char *object, const char *tag,
if (fd < 0)
die_errno(_("could not create file '%s'"), path);
- if (!is_null_sha1(prev)) {
+ if (!is_null_oid(prev)) {
write_tag_body(fd, prev);
} else {
struct strbuf buf = STRBUF_INIT;
@@ -296,7 +296,7 @@ static void create_tag(const unsigned char *object, const char *tag,
}
}
-static void create_reflog_msg(const unsigned char *sha1, struct strbuf *sb)
+static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
{
enum object_type type;
struct commit *c;
@@ -309,36 +309,36 @@ static void create_reflog_msg(const unsigned char *sha1, struct strbuf *sb)
if (rla) {
strbuf_addstr(sb, rla);
} else {
- strbuf_addstr(sb, _("tag: tagging "));
- strbuf_add_unique_abbrev(sb, sha1, DEFAULT_ABBREV);
+ strbuf_addstr(sb, "tag: tagging ");
+ strbuf_add_unique_abbrev(sb, oid->hash, DEFAULT_ABBREV);
}
strbuf_addstr(sb, " (");
- type = sha1_object_info(sha1, NULL);
+ type = sha1_object_info(oid->hash, NULL);
switch (type) {
default:
- strbuf_addstr(sb, _("object of unknown type"));
+ strbuf_addstr(sb, "object of unknown type");
break;
case OBJ_COMMIT:
- if ((buf = read_sha1_file(sha1, &type, &size)) != NULL) {
+ if ((buf = read_sha1_file(oid->hash, &type, &size)) != NULL) {
subject_len = find_commit_subject(buf, &subject_start);
strbuf_insert(sb, sb->len, subject_start, subject_len);
} else {
- strbuf_addstr(sb, _("commit object"));
+ strbuf_addstr(sb, "commit object");
}
free(buf);
- if ((c = lookup_commit_reference(sha1)) != NULL)
+ if ((c = lookup_commit_reference(oid)) != NULL)
strbuf_addf(sb, ", %s", show_date(c->date, 0, DATE_MODE(SHORT)));
break;
case OBJ_TREE:
- strbuf_addstr(sb, _("tree object"));
+ strbuf_addstr(sb, "tree object");
break;
case OBJ_BLOB:
- strbuf_addstr(sb, _("blob object"));
+ strbuf_addstr(sb, "blob object");
break;
case OBJ_TAG:
- strbuf_addstr(sb, _("other tag object"));
+ strbuf_addstr(sb, "other tag object");
break;
}
strbuf_addch(sb, ')');
@@ -378,7 +378,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
struct strbuf buf = STRBUF_INIT;
struct strbuf ref = STRBUF_INIT;
struct strbuf reflog_msg = STRBUF_INIT;
- unsigned char object[20], prev[20];
+ struct object_id object, prev;
const char *object_ref, *tag;
struct create_tag_options opt;
char *cleanup_arg = NULL;
@@ -528,14 +528,14 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
if (argc > 2)
die(_("too many params"));
- if (get_sha1(object_ref, object))
+ if (get_oid(object_ref, &object))
die(_("Failed to resolve '%s' as a valid ref."), object_ref);
if (strbuf_check_tag_ref(&ref, tag))
die(_("'%s' is not a valid tag name."), tag);
- if (read_ref(ref.buf, prev))
- hashclr(prev);
+ if (read_ref(ref.buf, prev.hash))
+ oidclr(&prev);
else if (!force)
die(_("tag '%s' already exists"), tag);
@@ -550,24 +550,24 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
else
die(_("Invalid cleanup mode %s"), cleanup_arg);
- create_reflog_msg(object, &reflog_msg);
+ create_reflog_msg(&object, &reflog_msg);
if (create_tag_object) {
if (force_sign_annotate && !annotate)
opt.sign = 1;
- create_tag(object, tag, &buf, &opt, prev, object);
+ create_tag(&object, tag, &buf, &opt, &prev, &object);
}
transaction = ref_transaction_begin(&err);
if (!transaction ||
- ref_transaction_update(transaction, ref.buf, object, prev,
+ ref_transaction_update(transaction, ref.buf, object.hash, prev.hash,
create_reflog ? REF_FORCE_CREATE_REFLOG : 0,
reflog_msg.buf, &err) ||
ref_transaction_commit(transaction, &err))
die("%s", err.buf);
ref_transaction_free(transaction);
- if (force && !is_null_sha1(prev) && hashcmp(prev, object))
- printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev, DEFAULT_ABBREV));
+ if (force && !is_null_oid(&prev) && oidcmp(&prev, &object))
+ printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev.hash, DEFAULT_ABBREV));
strbuf_release(&err);
strbuf_release(&buf);
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 4532aa0..8bc9997 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -127,7 +127,7 @@ static void *get_data(unsigned long size)
}
struct delta_info {
- unsigned char base_sha1[20];
+ struct object_id base_oid;
unsigned nr;
off_t base_offset;
unsigned long size;
@@ -137,13 +137,13 @@ struct delta_info {
static struct delta_info *delta_list;
-static void add_delta_to_list(unsigned nr, unsigned const char *base_sha1,
+static void add_delta_to_list(unsigned nr, const struct object_id *base_oid,
off_t base_offset,
void *delta, unsigned long size)
{
struct delta_info *info = xmalloc(sizeof(*info));
- hashcpy(info->base_sha1, base_sha1);
+ oidcpy(&info->base_oid, base_oid);
info->base_offset = base_offset;
info->size = size;
info->delta = delta;
@@ -154,7 +154,7 @@ static void add_delta_to_list(unsigned nr, unsigned const char *base_sha1,
struct obj_info {
off_t offset;
- unsigned char sha1[20];
+ struct object_id oid;
struct object *obj;
};
@@ -170,9 +170,9 @@ static unsigned nr_objects;
*/
static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf)
{
- unsigned char sha1[20];
+ struct object_id oid;
- if (write_sha1_file(obj_buf->buffer, obj_buf->size, typename(obj->type), sha1) < 0)
+ if (write_sha1_file(obj_buf->buffer, obj_buf->size, typename(obj->type), oid.hash) < 0)
die("failed to write object %s", oid_to_hex(&obj->oid));
obj->flags |= FLAG_WRITTEN;
}
@@ -237,19 +237,19 @@ static void write_object(unsigned nr, enum object_type type,
void *buf, unsigned long size)
{
if (!strict) {
- if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0)
+ if (write_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash) < 0)
die("failed to write object");
added_object(nr, type, buf, size);
free(buf);
obj_list[nr].obj = NULL;
} else if (type == OBJ_BLOB) {
struct blob *blob;
- if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0)
+ if (write_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash) < 0)
die("failed to write object");
added_object(nr, type, buf, size);
free(buf);
- blob = lookup_blob(obj_list[nr].sha1);
+ blob = lookup_blob(&obj_list[nr].oid);
if (blob)
blob->object.flags |= FLAG_WRITTEN;
else
@@ -258,9 +258,10 @@ static void write_object(unsigned nr, enum object_type type,
} else {
struct object *obj;
int eaten;
- hash_sha1_file(buf, size, typename(type), obj_list[nr].sha1);
+ hash_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash);
added_object(nr, type, buf, size);
- obj = parse_object_buffer(obj_list[nr].sha1, type, size, buf, &eaten);
+ obj = parse_object_buffer(&obj_list[nr].oid, type, size, buf,
+ &eaten);
if (!obj)
die("invalid %s", typename(type));
add_object_buffer(obj, buf, size);
@@ -296,7 +297,7 @@ static void added_object(unsigned nr, enum object_type type,
struct delta_info *info;
while ((info = *p) != NULL) {
- if (!hashcmp(info->base_sha1, obj_list[nr].sha1) ||
+ if (!oidcmp(&info->base_oid, &obj_list[nr].oid) ||
info->base_offset == obj_list[nr].offset) {
*p = info->next;
p = &delta_list;
@@ -320,12 +321,12 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,
free(buf);
}
-static int resolve_against_held(unsigned nr, const unsigned char *base,
+static int resolve_against_held(unsigned nr, const struct object_id *base,
void *delta_data, unsigned long delta_size)
{
struct object *obj;
struct obj_buffer *obj_buffer;
- obj = lookup_object(base);
+ obj = lookup_object(base->hash);
if (!obj)
return 0;
obj_buffer = lookup_object_buffer(obj);
@@ -341,25 +342,25 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
{
void *delta_data, *base;
unsigned long base_size;
- unsigned char base_sha1[20];
+ struct object_id base_oid;
if (type == OBJ_REF_DELTA) {
- hashcpy(base_sha1, fill(20));
- use(20);
+ hashcpy(base_oid.hash, fill(GIT_SHA1_RAWSZ));
+ use(GIT_SHA1_RAWSZ);
delta_data = get_data(delta_size);
if (dry_run || !delta_data) {
free(delta_data);
return;
}
- if (has_sha1_file(base_sha1))
+ if (has_object_file(&base_oid))
; /* Ok we have this one */
- else if (resolve_against_held(nr, base_sha1,
+ else if (resolve_against_held(nr, &base_oid,
delta_data, delta_size))
return; /* we are done */
else {
/* cannot resolve yet --- queue it */
- hashclr(obj_list[nr].sha1);
- add_delta_to_list(nr, base_sha1, 0, delta_data, delta_size);
+ oidclr(&obj_list[nr].oid);
+ add_delta_to_list(nr, &base_oid, 0, delta_data, delta_size);
return;
}
} else {
@@ -399,8 +400,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
} else if (base_offset > obj_list[mid].offset) {
lo = mid + 1;
} else {
- hashcpy(base_sha1, obj_list[mid].sha1);
- base_found = !is_null_sha1(base_sha1);
+ oidcpy(&base_oid, &obj_list[mid].oid);
+ base_found = !is_null_oid(&base_oid);
break;
}
}
@@ -409,19 +410,19 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
* The delta base object is itself a delta that
* has not been resolved yet.
*/
- hashclr(obj_list[nr].sha1);
- add_delta_to_list(nr, null_sha1, base_offset, delta_data, delta_size);
+ oidclr(&obj_list[nr].oid);
+ add_delta_to_list(nr, &null_oid, base_offset, delta_data, delta_size);
return;
}
}
- if (resolve_against_held(nr, base_sha1, delta_data, delta_size))
+ if (resolve_against_held(nr, &base_oid, delta_data, delta_size))
return;
- base = read_sha1_file(base_sha1, &type, &base_size);
+ base = read_sha1_file(base_oid.hash, &type, &base_size);
if (!base) {
error("failed to read delta-pack base object %s",
- sha1_to_hex(base_sha1));
+ oid_to_hex(&base_oid));
if (!recover)
exit(1);
has_errors = 1;
@@ -505,7 +506,7 @@ static void unpack_all(void)
int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
{
int i;
- unsigned char sha1[20];
+ struct object_id oid;
check_replace_refs = 0;
@@ -566,12 +567,12 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
git_SHA1_Init(&ctx);
unpack_all();
git_SHA1_Update(&ctx, buffer, offset);
- git_SHA1_Final(sha1, &ctx);
+ git_SHA1_Final(oid.hash, &ctx);
if (strict)
write_rest();
- if (hashcmp(fill(20), sha1))
+ if (hashcmp(fill(GIT_SHA1_RAWSZ), oid.hash))
die("final sha1 did not match");
- use(20);
+ use(GIT_SHA1_RAWSZ);
/* Write the last part of the buffer to stdout */
while (len) {
diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c
index 38bedf8..05b734e 100644
--- a/builtin/verify-commit.c
+++ b/builtin/verify-commit.c
@@ -18,14 +18,14 @@ static const char * const verify_commit_usage[] = {
NULL
};
-static int run_gpg_verify(const unsigned char *sha1, const char *buf, unsigned long size, unsigned flags)
+static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned long size, unsigned flags)
{
struct signature_check signature_check;
int ret;
memset(&signature_check, 0, sizeof(signature_check));
- ret = check_commit_signature(lookup_commit(sha1), &signature_check);
+ ret = check_commit_signature(lookup_commit(oid), &signature_check);
print_signature_buffer(&signature_check, flags);
signature_check_clear(&signature_check);
@@ -35,22 +35,22 @@ static int run_gpg_verify(const unsigned char *sha1, const char *buf, unsigned l
static int verify_commit(const char *name, unsigned flags)
{
enum object_type type;
- unsigned char sha1[20];
+ struct object_id oid;
char *buf;
unsigned long size;
int ret;
- if (get_sha1(name, sha1))
+ if (get_oid(name, &oid))
return error("commit '%s' not found.", name);
- buf = read_sha1_file(sha1, &type, &size);
+ buf = read_sha1_file(oid.hash, &type, &size);
if (!buf)
return error("%s: unable to read file.", name);
if (type != OBJ_COMMIT)
return error("%s: cannot verify a non-commit object of type %s.",
name, typename(type));
- ret = run_gpg_verify(sha1, buf, size, flags);
+ ret = run_gpg_verify(&oid, buf, size, flags);
free(buf);
return ret;
diff --git a/builtin/worktree.c b/builtin/worktree.c
index ff5dfd2..793306e 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -31,7 +31,7 @@ struct add_opts {
static int show_only;
static int verbose;
-static unsigned long expire;
+static timestamp_t expire;
static int prune_worktree(const char *id, struct strbuf *reason)
{
@@ -131,7 +131,7 @@ static int prune(int ac, const char **av, const char *prefix)
OPT_END()
};
- expire = ULONG_MAX;
+ expire = TIME_MAX;
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
if (ac)
usage_with_options(worktree_usage, options);