Revert "Merge branch 'ra/rebase-i-more-options'"
This reverts commit5d9324e0f4
, reversing changes made toc58ae96fc4
. The topic turns out to be too buggy for real use. cf. <f2fe7437-8a48-3315-4d3f-8d51fe4bb8f1@gmail.com>
This commit is contained in:
141
sequencer.c
141
sequencer.c
@ -147,8 +147,6 @@ static GIT_PATH_FUNC(rebase_path_refs_to_delete, "rebase-merge/refs-to-delete")
|
||||
* command-line.
|
||||
*/
|
||||
static GIT_PATH_FUNC(rebase_path_gpg_sign_opt, "rebase-merge/gpg_sign_opt")
|
||||
static GIT_PATH_FUNC(rebase_path_cdate_is_adate, "rebase-merge/cdate_is_adate")
|
||||
static GIT_PATH_FUNC(rebase_path_ignore_date, "rebase-merge/ignore_date")
|
||||
static GIT_PATH_FUNC(rebase_path_orig_head, "rebase-merge/orig-head")
|
||||
static GIT_PATH_FUNC(rebase_path_verbose, "rebase-merge/verbose")
|
||||
static GIT_PATH_FUNC(rebase_path_quiet, "rebase-merge/quiet")
|
||||
@ -825,19 +823,9 @@ int read_author_script(const char *path, char **name, char **email, char **date,
|
||||
error(_("missing 'GIT_AUTHOR_DATE'"));
|
||||
if (date_i < 0 || email_i < 0 || date_i < 0 || err)
|
||||
goto finish;
|
||||
|
||||
if (name)
|
||||
*name = kv.items[name_i].util;
|
||||
else
|
||||
free(kv.items[name_i].util);
|
||||
if (email)
|
||||
*email = kv.items[email_i].util;
|
||||
else
|
||||
free(kv.items[email_i].util);
|
||||
if (date)
|
||||
*date = kv.items[date_i].util;
|
||||
else
|
||||
free(kv.items[date_i].util);
|
||||
*name = kv.items[name_i].util;
|
||||
*email = kv.items[email_i].util;
|
||||
*date = kv.items[date_i].util;
|
||||
retval = 0;
|
||||
finish:
|
||||
string_list_clear(&kv, !!retval);
|
||||
@ -880,47 +868,6 @@ static char *get_author(const char *message)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Returns a "date" string that needs to be free()'d by the caller */
|
||||
static char *read_author_date_or_null(void)
|
||||
{
|
||||
char *date;
|
||||
|
||||
if (read_author_script(rebase_path_author_script(),
|
||||
NULL, NULL, &date, 0))
|
||||
return NULL;
|
||||
return date;
|
||||
}
|
||||
|
||||
/* Construct a free()able author string with current time as the author date */
|
||||
static char *ignore_author_date(const char *author)
|
||||
{
|
||||
int len = strlen(author);
|
||||
struct ident_split ident;
|
||||
struct strbuf new_author = STRBUF_INIT;
|
||||
|
||||
if (split_ident_line(&ident, author, len) < 0) {
|
||||
error(_("malformed ident line"));
|
||||
return NULL;
|
||||
}
|
||||
len = ident.mail_end - ident.name_begin + 1;
|
||||
|
||||
strbuf_addf(&new_author, "%.*s ", len, ident.name_begin);
|
||||
datestamp(&new_author);
|
||||
return strbuf_detach(&new_author, NULL);
|
||||
}
|
||||
|
||||
static void push_dates(struct child_process *child, int change_committer_date)
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
struct strbuf date = STRBUF_INIT;
|
||||
|
||||
strbuf_addf(&date, "@%"PRIuMAX, (uintmax_t)now);
|
||||
argv_array_pushf(&child->env_array, "GIT_AUTHOR_DATE=%s", date.buf);
|
||||
if (change_committer_date)
|
||||
argv_array_pushf(&child->env_array, "GIT_COMMITTER_DATE=%s", date.buf);
|
||||
strbuf_release(&date);
|
||||
}
|
||||
|
||||
static const char staged_changes_advice[] =
|
||||
N_("you have staged changes in your working tree\n"
|
||||
"If these changes are meant to be squashed into the previous commit, run:\n"
|
||||
@ -980,25 +927,6 @@ static int run_git_commit(struct repository *r,
|
||||
|
||||
cmd.git_cmd = 1;
|
||||
|
||||
if (opts->committer_date_is_author_date) {
|
||||
int res = -1;
|
||||
struct strbuf datebuf = STRBUF_INIT;
|
||||
char *date = read_author_date_or_null();
|
||||
|
||||
if (!date)
|
||||
return -1;
|
||||
|
||||
strbuf_addf(&datebuf, "@%s", date);
|
||||
res = setenv("GIT_COMMITTER_DATE",
|
||||
opts->ignore_date ? "" : datebuf.buf, 1);
|
||||
|
||||
strbuf_release(&datebuf);
|
||||
free(date);
|
||||
|
||||
if (res)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_rebase_i(opts) && read_env_script(&cmd.env_array)) {
|
||||
const char *gpg_opt = gpg_sign_opt_quoted(opts);
|
||||
|
||||
@ -1014,8 +942,6 @@ static int run_git_commit(struct repository *r,
|
||||
argv_array_push(&cmd.args, "--amend");
|
||||
if (opts->gpg_sign)
|
||||
argv_array_pushf(&cmd.args, "-S%s", opts->gpg_sign);
|
||||
if (opts->ignore_date)
|
||||
push_dates(&cmd, opts->committer_date_is_author_date);
|
||||
if (defmsg)
|
||||
argv_array_pushl(&cmd.args, "-F", defmsg, NULL);
|
||||
else if (!(flags & EDIT_MSG))
|
||||
@ -1384,13 +1310,14 @@ static int try_to_commit(struct repository *r,
|
||||
struct commit_extra_header *extra = NULL;
|
||||
struct strbuf err = STRBUF_INIT;
|
||||
struct strbuf commit_msg = STRBUF_INIT;
|
||||
char *author_to_free = NULL;
|
||||
char *amend_author = NULL;
|
||||
const char *hook_commit = NULL;
|
||||
enum commit_msg_cleanup_mode cleanup;
|
||||
int res = 0;
|
||||
|
||||
if (parse_head(r, ¤t_head))
|
||||
return -1;
|
||||
|
||||
if (flags & AMEND_MSG) {
|
||||
const char *exclude_gpgsig[] = { "gpgsig", NULL };
|
||||
const char *out_enc = get_commit_output_encoding();
|
||||
@ -1405,7 +1332,7 @@ static int try_to_commit(struct repository *r,
|
||||
strbuf_addstr(msg, orig_message);
|
||||
hook_commit = "HEAD";
|
||||
}
|
||||
author = author_to_free = get_author(message);
|
||||
author = amend_author = get_author(message);
|
||||
unuse_commit_buffer(current_head, message);
|
||||
if (!author) {
|
||||
res = error(_("unable to parse commit author"));
|
||||
@ -1418,31 +1345,6 @@ static int try_to_commit(struct repository *r,
|
||||
commit_list_insert(current_head, &parents);
|
||||
}
|
||||
|
||||
if (opts->committer_date_is_author_date) {
|
||||
int len = strlen(author);
|
||||
struct ident_split ident;
|
||||
struct strbuf date = STRBUF_INIT;
|
||||
|
||||
if (split_ident_line(&ident, author, len) < 0) {
|
||||
res = error(_("malformed ident line"));
|
||||
goto out;
|
||||
}
|
||||
if (!ident.date_begin) {
|
||||
res = error(_("corrupted author without date information"));
|
||||
goto out;
|
||||
}
|
||||
|
||||
strbuf_addf(&date, "@%.*s %.*s",
|
||||
(int)(ident.date_end - ident.date_begin), ident.date_begin,
|
||||
(int)(ident.tz_end - ident.tz_begin), ident.tz_begin);
|
||||
res = setenv("GIT_COMMITTER_DATE",
|
||||
opts->ignore_date ? "" : date.buf, 1);
|
||||
strbuf_release(&date);
|
||||
|
||||
if (res)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (write_index_as_tree(&tree, r->index, r->index_file, 0, NULL)) {
|
||||
res = error(_("git write-tree failed to write a tree"));
|
||||
goto out;
|
||||
@ -1502,15 +1404,6 @@ static int try_to_commit(struct repository *r,
|
||||
|
||||
reset_ident_date();
|
||||
|
||||
if (opts->ignore_date) {
|
||||
author = ignore_author_date(author);
|
||||
if (!author) {
|
||||
res = -1;
|
||||
goto out;
|
||||
}
|
||||
free(author_to_free);
|
||||
author_to_free = (char *)author;
|
||||
}
|
||||
if (commit_tree_extended(msg->buf, msg->len, &tree, parents,
|
||||
oid, author, opts->gpg_sign, extra)) {
|
||||
res = error(_("failed to write commit object"));
|
||||
@ -1531,7 +1424,7 @@ out:
|
||||
free_commit_extra_headers(extra);
|
||||
strbuf_release(&err);
|
||||
strbuf_release(&commit_msg);
|
||||
free(author_to_free);
|
||||
free(amend_author);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -2599,16 +2492,6 @@ static int read_populate_opts(struct replay_opts *opts)
|
||||
opts->signoff = 1;
|
||||
}
|
||||
|
||||
if (file_exists(rebase_path_cdate_is_adate())) {
|
||||
opts->allow_ff = 0;
|
||||
opts->committer_date_is_author_date = 1;
|
||||
}
|
||||
|
||||
if (file_exists(rebase_path_ignore_date())) {
|
||||
opts->allow_ff = 0;
|
||||
opts->ignore_date = 1;
|
||||
}
|
||||
|
||||
if (file_exists(rebase_path_reschedule_failed_exec()))
|
||||
opts->reschedule_failed_exec = 1;
|
||||
|
||||
@ -2691,10 +2574,6 @@ int write_basic_state(struct replay_opts *opts, const char *head_name,
|
||||
write_file(rebase_path_gpg_sign_opt(), "-S%s\n", opts->gpg_sign);
|
||||
if (opts->signoff)
|
||||
write_file(rebase_path_signoff(), "--signoff\n");
|
||||
if (opts->committer_date_is_author_date)
|
||||
write_file(rebase_path_cdate_is_adate(), "%s", "");
|
||||
if (opts->ignore_date)
|
||||
write_file(rebase_path_ignore_date(), "%s", "");
|
||||
if (opts->reschedule_failed_exec)
|
||||
write_file(rebase_path_reschedule_failed_exec(), "%s", "");
|
||||
|
||||
@ -3635,8 +3514,6 @@ static int do_merge(struct repository *r,
|
||||
argv_array_push(&cmd.args, git_path_merge_msg(r));
|
||||
if (opts->gpg_sign)
|
||||
argv_array_push(&cmd.args, opts->gpg_sign);
|
||||
if (opts->ignore_date)
|
||||
push_dates(&cmd, opts->committer_date_is_author_date);
|
||||
|
||||
/* Add the tips to be merged */
|
||||
for (j = to_merge; j; j = j->next)
|
||||
@ -3909,9 +3786,7 @@ static int pick_commits(struct repository *r,
|
||||
setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
|
||||
if (opts->allow_ff)
|
||||
assert(!(opts->signoff || opts->no_commit ||
|
||||
opts->record_origin || opts->edit ||
|
||||
opts->committer_date_is_author_date ||
|
||||
opts->ignore_date));
|
||||
opts->record_origin || opts->edit));
|
||||
if (read_and_refresh_cache(r, opts))
|
||||
return -1;
|
||||
|
||||
|
Reference in New Issue
Block a user