static int run_status(FILE *fp, const char *index_file, const char *prefix, int nowarn,
struct wt_status *s)
{
- unsigned char sha1[20];
+ struct object_id oid;
if (s->relative_paths)
s->prefix = prefix;
s->index_file = index_file;
s->fp = fp;
s->nowarn = nowarn;
- s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
+ s->is_initial = get_sha1(s->reference, oid.hash) ? 1 : 0;
if (!s->is_initial)
- hashcpy(s->sha1_commit, sha1);
+ hashcpy(s->sha1_commit, oid.hash);
s->status_format = status_format;
s->ignore_submodule_arg = ignore_submodule_arg;
commitable = run_status(s->fp, index_file, prefix, 1, s);
s->use_color = saved_color_setting;
} else {
- unsigned char sha1[20];
+ struct object_id oid;
const char *parent = "HEAD";
if (!active_nr && read_cache() < 0)
if (amend)
parent = "HEAD^1";
- if (get_sha1(parent, sha1)) {
+ if (get_sha1(parent, oid.hash)) {
int i, ita_nr = 0;
for (i = 0; i < active_nr; i++)
{
static struct wt_status s;
int fd;
- unsigned char sha1[20];
+ struct object_id oid;
static struct option builtin_status_options[] = {
OPT__VERBOSE(&verbose, N_("be verbose")),
OPT_SET_INT('s', "short", &status_format,
fd = hold_locked_index(&index_lock, 0);
- s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
+ s.is_initial = get_sha1(s.reference, oid.hash) ? 1 : 0;
if (!s.is_initial)
- hashcpy(s.sha1_commit, sha1);
+ hashcpy(s.sha1_commit, oid.hash);
s.ignore_submodule_arg = ignore_submodule_arg;
s.status_format = status_format;
}
-static void print_summary(const char *prefix, const unsigned char *sha1,
+static void print_summary(const char *prefix, const struct object_id *oid,
int initial_commit)
{
struct rev_info rev;
struct commit *commit;
struct strbuf format = STRBUF_INIT;
- unsigned char junk_sha1[20];
+ struct object_id junk_oid;
const char *head;
struct pretty_print_context pctx = {0};
struct strbuf author_ident = STRBUF_INIT;
struct strbuf committer_ident = STRBUF_INIT;
- commit = lookup_commit(sha1);
+ commit = lookup_commit(oid->hash);
if (!commit)
die(_("couldn't look up newly created commit"));
if (parse_commit(commit))
rev.diffopt.break_opt = 0;
diff_setup_done(&rev.diffopt);
- head = resolve_ref_unsafe("HEAD", 0, junk_sha1, NULL);
+ head = resolve_ref_unsafe("HEAD", 0, junk_oid.hash, NULL);
if (!strcmp(head, "HEAD"))
head = _("detached HEAD");
else
return git_status_config(k, v, s);
}
-static int run_rewrite_hook(const unsigned char *oldsha1,
- const unsigned char *newsha1)
+static int run_rewrite_hook(const struct object_id *oldoid,
+ const struct object_id *newoid)
{
struct child_process proc = CHILD_PROCESS_INIT;
const char *argv[3];
code = start_command(&proc);
if (code)
return code;
- strbuf_addf(&sb, "%s %s\n", sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
+ strbuf_addf(&sb, "%s %s\n", oid_to_hex(oldoid), oid_to_hex(newoid));
sigchain_push(SIGPIPE, SIG_IGN);
write_in_full(proc.in, sb.buf, sb.len);
close(proc.in);
struct strbuf author_ident = STRBUF_INIT;
const char *index_file, *reflog_msg;
char *nl;
- unsigned char sha1[20];
+ struct object_id oid;
struct commit_list *parents = NULL;
struct stat statbuf;
struct commit *current_head = NULL;
status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
s.colopts = 0;
- if (get_sha1("HEAD", sha1))
+ if (get_sha1("HEAD", oid.hash))
current_head = NULL;
else {
- current_head = lookup_commit_or_die(sha1, "HEAD");
+ current_head = lookup_commit_or_die(oid.hash, "HEAD");
if (parse_commit(current_head))
die(_("could not parse HEAD commit"));
}
}
if (commit_tree_extended(sb.buf, sb.len, active_cache_tree->sha1,
- parents, sha1, author_ident.buf, sign_commit, extra)) {
+ parents, oid.hash, author_ident.buf, sign_commit, extra)) {
rollback_index_files();
die(_("failed to write commit object"));
}
transaction = ref_transaction_begin(&err);
if (!transaction ||
- ref_transaction_update(transaction, "HEAD", sha1,
+ ref_transaction_update(transaction, "HEAD", oid.hash,
current_head
? current_head->object.oid.hash : null_sha1,
0, sb.buf, &err) ||
cfg = init_copy_notes_for_rewrite("amend");
if (cfg) {
/* we are amending, so current_head is not NULL */
- copy_note_for_rewrite(cfg, current_head->object.oid.hash, sha1);
+ copy_note_for_rewrite(cfg, current_head->object.oid.hash, oid.hash);
finish_copy_notes_for_rewrite(cfg, "Notes added by 'git commit --amend'");
}
- run_rewrite_hook(current_head->object.oid.hash, sha1);
+ run_rewrite_hook(¤t_head->object.oid, &oid);
}
if (!quiet)
- print_summary(prefix, sha1, !current_head);
+ print_summary(prefix, &oid, !current_head);
strbuf_release(&err);
return 0;