rebase: introduce and use pseudo-ref REBASE_HEAD
The new command `git rebase --show-current-patch` is useful for seeing the commit related to the current rebase state. Some however may find the "git show" command behind it too limiting. You may want to increase context lines, do a diff that ignores whitespaces... For these advanced use cases, the user can execute any command they want with the new pseudo ref REBASE_HEAD. This also helps show where the stopped commit is from, which is hard to see from the previous patch which implements --show-current-patch. Helped-by: Tim Landscheidt <tim@tim-landscheidt.de> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
66335298a4
commit
fbd7a23237
@ -1011,6 +1011,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
|
||||
|
||||
if (mkdir(state->dir, 0777) < 0 && errno != EEXIST)
|
||||
die_errno(_("failed to create directory '%s'"), state->dir);
|
||||
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
|
||||
|
||||
if (split_mail(state, patch_format, paths, keep_cr) < 0) {
|
||||
am_destroy(state);
|
||||
@ -1110,6 +1111,7 @@ static void am_next(struct am_state *state)
|
||||
|
||||
oidclr(&state->orig_commit);
|
||||
unlink(am_path(state, "original-commit"));
|
||||
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
|
||||
|
||||
if (!get_oid("HEAD", &head))
|
||||
write_state_text(state, "abort-safety", oid_to_hex(&head));
|
||||
@ -1441,6 +1443,8 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)
|
||||
|
||||
oidcpy(&state->orig_commit, &commit_oid);
|
||||
write_state_text(state, "original-commit", oid_to_hex(&commit_oid));
|
||||
update_ref("am", "REBASE_HEAD", &commit_oid,
|
||||
NULL, REF_NO_DEREF, UPDATE_REFS_DIE_ON_ERR);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user