Skip to content

Commit 6a44c9c

Browse files
committed
Merge branch 'jk/committer-date-is-author-date-fix-simplify'
Code simplification. * jk/committer-date-is-author-date-fix-simplify: am, sequencer: stop parsing our own committer ident
2 parents ecf95d9 + 2020451 commit 6a44c9c

File tree

3 files changed

+5
-44
lines changed

3 files changed

+5
-44
lines changed

builtin/am.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ struct am_state {
9898
char *author_name;
9999
char *author_email;
100100
char *author_date;
101-
char *committer_name;
102-
char *committer_email;
103101
char *msg;
104102
size_t msg_len;
105103

@@ -132,8 +130,6 @@ struct am_state {
132130
*/
133131
static void am_state_init(struct am_state *state)
134132
{
135-
const char *committer;
136-
struct ident_split id;
137133
int gpgsign;
138134

139135
memset(state, 0, sizeof(*state));
@@ -154,14 +150,6 @@ static void am_state_init(struct am_state *state)
154150

155151
if (!git_config_get_bool("commit.gpgsign", &gpgsign))
156152
state->sign_commit = gpgsign ? "" : NULL;
157-
158-
committer = git_committer_info(IDENT_STRICT);
159-
if (split_ident_line(&id, committer, strlen(committer)) < 0)
160-
die(_("invalid committer: %s"), committer);
161-
state->committer_name =
162-
xmemdupz(id.name_begin, id.name_end - id.name_begin);
163-
state->committer_email =
164-
xmemdupz(id.mail_begin, id.mail_end - id.mail_begin);
165153
}
166154

167155
/**
@@ -173,8 +161,6 @@ static void am_state_release(struct am_state *state)
173161
free(state->author_name);
174162
free(state->author_email);
175163
free(state->author_date);
176-
free(state->committer_name);
177-
free(state->committer_email);
178164
free(state->msg);
179165
strvec_clear(&state->git_apply_opts);
180166
}
@@ -1594,8 +1580,9 @@ static void do_commit(const struct am_state *state)
15941580
IDENT_STRICT);
15951581

15961582
if (state->committer_date_is_author_date)
1597-
committer = fmt_ident(state->committer_name,
1598-
state->committer_email, WANT_COMMITTER_IDENT,
1583+
committer = fmt_ident(getenv("GIT_COMMITTER_NAME"),
1584+
getenv("GIT_COMMITTER_EMAIL"),
1585+
WANT_COMMITTER_IDENT,
15991586
state->ignore_date ? NULL
16001587
: state->author_date,
16011588
IDENT_STRICT);

sequencer.c

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,6 @@ int sequencer_remove_state(struct replay_opts *opts)
314314
}
315315
}
316316

317-
free(opts->committer_name);
318-
free(opts->committer_email);
319317
free(opts->gpg_sign);
320318
free(opts->strategy);
321319
for (i = 0; i < opts->xopts_nr; i++)
@@ -1460,8 +1458,8 @@ static int try_to_commit(struct repository *r,
14601458
} else {
14611459
reset_ident_date();
14621460
}
1463-
committer = fmt_ident(opts->committer_name,
1464-
opts->committer_email,
1461+
committer = fmt_ident(getenv("GIT_COMMITTER_NAME"),
1462+
getenv("GIT_COMMITTER_EMAIL"),
14651463
WANT_COMMITTER_IDENT,
14661464
opts->ignore_date ? NULL : date.buf,
14671465
IDENT_STRICT);
@@ -4468,22 +4466,6 @@ static int commit_staged_changes(struct repository *r,
44684466
return 0;
44694467
}
44704468

4471-
static int init_committer(struct replay_opts *opts)
4472-
{
4473-
struct ident_split id;
4474-
const char *committer;
4475-
4476-
committer = git_committer_info(IDENT_STRICT);
4477-
if (split_ident_line(&id, committer, strlen(committer)) < 0)
4478-
return error(_("invalid committer '%s'"), committer);
4479-
opts->committer_name =
4480-
xmemdupz(id.name_begin, id.name_end - id.name_begin);
4481-
opts->committer_email =
4482-
xmemdupz(id.mail_begin, id.mail_end - id.mail_begin);
4483-
4484-
return 0;
4485-
}
4486-
44874469
int sequencer_continue(struct repository *r, struct replay_opts *opts)
44884470
{
44894471
struct todo_list todo_list = TODO_LIST_INIT;
@@ -4495,9 +4477,6 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
44954477
if (read_populate_opts(opts))
44964478
return -1;
44974479
if (is_rebase_i(opts)) {
4498-
if (opts->committer_date_is_author_date && init_committer(opts))
4499-
return -1;
4500-
45014480
if ((res = read_populate_todo(r, &todo_list, opts)))
45024481
goto release_todo_list;
45034482

@@ -5392,9 +5371,6 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
53925371

53935372
res = -1;
53945373

5395-
if (opts->committer_date_is_author_date && init_committer(opts))
5396-
goto cleanup;
5397-
53985374
if (checkout_onto(r, opts, onto_name, &oid, orig_head))
53995375
goto cleanup;
54005376

sequencer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ struct replay_opts {
5050

5151
int mainline;
5252

53-
char *committer_name;
54-
char *committer_email;
5553
char *gpg_sign;
5654
enum commit_msg_cleanup_mode default_msg_cleanup;
5755
int explicit_cleanup;

0 commit comments

Comments
 (0)