diff options
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/sequencer.c b/sequencer.c index ea96837cde..6abd72160c 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1164,18 +1164,14 @@ 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]; int code; struct strbuf sb = STRBUF_INIT; + const char *hook_path = find_hook("post-rewrite"); - argv[0] = find_hook("post-rewrite"); - if (!argv[0]) + if (!hook_path) return 0; - argv[1] = "amend"; - argv[2] = NULL; - - proc.argv = argv; + strvec_pushl(&proc.args, hook_path, "amend", NULL); proc.in = -1; proc.stdout_to_stderr = 1; proc.trace2_hook_name = "post-rewrite"; @@ -1284,6 +1280,8 @@ void print_commit_summary(struct repository *r, struct pretty_print_context pctx = {0}; struct strbuf author_ident = STRBUF_INIT; struct strbuf committer_ident = STRBUF_INIT; + struct ref_store *refs; + int resolve_errno; commit = lookup_commit(r, oid); if (!commit) @@ -1333,9 +1331,13 @@ void print_commit_summary(struct repository *r, rev.diffopt.break_opt = 0; diff_setup_done(&rev.diffopt); - head = resolve_ref_unsafe("HEAD", 0, NULL, NULL); - if (!head) + refs = get_main_ref_store(the_repository); + head = refs_resolve_ref_unsafe(refs, "HEAD", 0, NULL, NULL, + &resolve_errno); + if (!head) { + errno = resolve_errno; die_errno(_("unable to resolve HEAD after creating commit")); + } if (!strcmp(head, "HEAD")) head = _("detached HEAD"); else @@ -3495,17 +3497,12 @@ static int error_failed_squash(struct repository *r, static int do_exec(struct repository *r, const char *command_line) { - struct strvec child_env = STRVEC_INIT; const char *child_argv[] = { NULL, NULL }; int dirty, status; fprintf(stderr, _("Executing: %s\n"), command_line); child_argv[0] = command_line; - strvec_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir())); - strvec_pushf(&child_env, "GIT_WORK_TREE=%s", - absolute_path(get_git_work_tree())); - status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL, - child_env.v); + status = run_command_v_opt(child_argv, RUN_USING_SHELL); /* force re-reading of the cache */ if (discard_index(r->index) < 0 || repo_read_index(r) < 0) @@ -3535,8 +3532,6 @@ static int do_exec(struct repository *r, const char *command_line) status = 1; } - strvec_clear(&child_env); - return status; } @@ -4228,6 +4223,8 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts, cmd.git_cmd = 1; + if (startup_info->original_cwd) + cmd.dir = startup_info->original_cwd; strvec_push(&cmd.args, "checkout"); strvec_push(&cmd.args, commit); strvec_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action); @@ -5496,7 +5493,7 @@ static void todo_list_add_exec_commands(struct todo_list *todo_list, } /* insert or append final <commands> */ - if (insert || nr == todo_list->nr) { + if (insert) { ALLOC_GROW(items, nr + commands->nr, alloc); COPY_ARRAY(items + nr, base_items, commands->nr); nr += commands->nr; |