Re: [PATCH v2 3/3] rebase: introduce and use pseudo-ref ORIG_COMMIT
Duy Nguyenwrites: > On Thu, Feb 1, 2018 at 6:18 AM, Junio C Hamano wrote: > ... >> Hmph, how is this new file conceptually different from existing ones >> like CHERRY_PICK_HEAD? > > Conceptually the same, except that CHERRY_PICK_HEAD can't be reused > because it's specifically tied to git-cherry-pick (there's even code > that delete this ref if cherry-pick is run as part of rebase, and > git-status uses this ref to see if a cherry-pick is in progress). > There's also REVERT_HEAD in sequencer.c, same purpose but for > git-revert. Perhaps I should rename this new ref to REBASE_HEAD to > follow the same naming? I just found "ORIG_COMMIT" too similar to "ORIG_HEAD" that is totally a different thing and feared unnecessary confusion. I think you are correct to suggest that REBASE_HEAD would be more in line with the naming convention with the sequencer-like operations. Thanks.
Re: [PATCH v2 3/3] rebase: introduce and use pseudo-ref ORIG_COMMIT
On 31/01/18 09:30, Nguyễn Thái Ngọc Duy wrote: > > 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 ORIG_COMMIT. > > 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> Signed-off-by: Nguyễn Thái Ngọc Duy > --- > Documentation/git-rebase.txt | 3 ++- > builtin/am.c | 4 > contrib/completion/git-completion.bash | 2 +- > git-rebase--interactive.sh | 5 - > git-rebase--merge.sh | 4 +++- > git-rebase.sh | 1 + > sequencer.c| 3 +++ > t/t3400-rebase.sh | 3 ++- > t/t3404-rebase-interactive.sh | 5 - > 9 files changed, 24 insertions(+), 6 deletions(-) > > diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt > index 7ef9577472..6da9296bf8 100644 > --- a/Documentation/git-rebase.txt > +++ b/Documentation/git-rebase.txt > @@ -252,7 +252,8 @@ leave out at most one of A and B, in which case it > defaults to HEAD. > > --show-current-patch:: > Show the current patch in an interactive rebase or when rebase > - is stopped because of conflicts. > + is stopped because of conflicts. This is the equivalent of > + `git show ORIG_COMMIT`. > > -m:: > --merge:: > diff --git a/builtin/am.c b/builtin/am.c > index caec50cba9..bf9b356340 100644 > --- a/builtin/am.c > +++ b/builtin/am.c > @@ -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, "ORIG_COMMIT", NULL, REF_NO_DEREF); > > if (split_mail(state, patch_format, paths, keep_cr) < 0) { > am_destroy(state); > @@ -1110,6 +,7 @@ static void am_next(struct am_state *state) > > oidclr(>orig_commit); > unlink(am_path(state, "original-commit")); > + delete_ref(NULL, "ORIG_COMMIT", NULL, REF_NO_DEREF); > > if (!get_oid("HEAD", )) > write_state_text(state, "abort-safety", oid_to_hex()); > @@ -1441,6 +1443,8 @@ static int parse_mail_rebase(struct am_state *state, > const char *mail) > > oidcpy(>orig_commit, _oid); > write_state_text(state, "original-commit", oid_to_hex(_oid)); > + update_ref("am", "ORIG_COMMIT", _oid, > +NULL, 0, UPDATE_REFS_DIE_ON_ERR); > > return 0; > } > diff --git a/contrib/completion/git-completion.bash > b/contrib/completion/git-completion.bash > index 2bd30d68cf..deea688e0e 100644 > --- a/contrib/completion/git-completion.bash > +++ b/contrib/completion/git-completion.bash > @@ -439,7 +439,7 @@ __git_refs () > track="" > ;; > *) > - for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do > + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD > ORIG_COMMIT; do > case "$i" in > $match*) > if [ -e "$dir/$i" ]; then > diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh > index 0c0f8abbf9..ef72bd5871 100644 > --- a/git-rebase--interactive.sh > +++ b/git-rebase--interactive.sh > @@ -199,12 +199,14 @@ make_patch () { > > die_with_patch () { > echo "$1" > "$state_dir"/stopped-sha > + git update-ref ORIG_COMMIT "$1" > make_patch "$1" > die "$2" > } > > exit_with_patch () { > echo "$1" > "$state_dir"/stopped-sha > + git update-ref ORIG_COMMIT "$1" > make_patch $1 > git rev-parse --verify HEAD > "$amend" > gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote > "$gpg_sign_opt")} > @@ -841,7 +843,7 @@ To continue rebase after editing, run: > exit > ;; > show-current-patch) > - exec git show "$(cat "$state_dir/stopped-sha")" -- > + exec git show ORIG_COMMIT -- > ;; > esac > > @@ -858,6 +860,7 @@ fi > > orig_head=$(git rev-parse --verify HEAD) || die "$(gettext "No HEAD?")" > mkdir -p "$state_dir" || die "$(eval_gettext "Could not create temporary > \$state_dir")" > +rm -f "$(git rev-parse --git-path ORIG_COMMIT)" > > : > "$state_dir"/interactive || die "$(gettext "Could not mark as > interactive")" > write_basic_state > diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh > index 0a96dfae37..70966c32c3 100644 > --- a/git-rebase--merge.sh > +++
Re: [PATCH v2 3/3] rebase: introduce and use pseudo-ref ORIG_COMMIT
On Thu, Feb 1, 2018 at 6:18 AM, Junio C Hamanowrote: > Nguyễn Thái Ngọc Duy writes: > >> 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 ORIG_COMMIT. >> >> 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 >> Signed-off-by: Nguyễn Thái Ngọc Duy >> --- > > Hmph, how is this new file conceptually different from existing ones > like CHERRY_PICK_HEAD? Conceptually the same, except that CHERRY_PICK_HEAD can't be reused because it's specifically tied to git-cherry-pick (there's even code that delete this ref if cherry-pick is run as part of rebase, and git-status uses this ref to see if a cherry-pick is in progress). There's also REVERT_HEAD in sequencer.c, same purpose but for git-revert. Perhaps I should rename this new ref to REBASE_HEAD to follow the same naming? -- Duy
Re: [PATCH v2 3/3] rebase: introduce and use pseudo-ref ORIG_COMMIT
Nguyễn Thái Ngọc Duywrites: > 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 ORIG_COMMIT. > > 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 > Signed-off-by: Nguyễn Thái Ngọc Duy > --- Hmph, how is this new file conceptually different from existing ones like CHERRY_PICK_HEAD? > Documentation/git-rebase.txt | 3 ++- > builtin/am.c | 4 > contrib/completion/git-completion.bash | 2 +- > git-rebase--interactive.sh | 5 - > git-rebase--merge.sh | 4 +++- > git-rebase.sh | 1 + > sequencer.c| 3 +++ > t/t3400-rebase.sh | 3 ++- > t/t3404-rebase-interactive.sh | 5 - > 9 files changed, 24 insertions(+), 6 deletions(-) > > diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt > index 7ef9577472..6da9296bf8 100644 > --- a/Documentation/git-rebase.txt > +++ b/Documentation/git-rebase.txt > @@ -252,7 +252,8 @@ leave out at most one of A and B, in which case it > defaults to HEAD. > > --show-current-patch:: > Show the current patch in an interactive rebase or when rebase > - is stopped because of conflicts. > + is stopped because of conflicts. This is the equivalent of > + `git show ORIG_COMMIT`. > > -m:: > --merge:: > diff --git a/builtin/am.c b/builtin/am.c > index caec50cba9..bf9b356340 100644 > --- a/builtin/am.c > +++ b/builtin/am.c > @@ -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, "ORIG_COMMIT", NULL, REF_NO_DEREF); > > if (split_mail(state, patch_format, paths, keep_cr) < 0) { > am_destroy(state); > @@ -1110,6 +,7 @@ static void am_next(struct am_state *state) > > oidclr(>orig_commit); > unlink(am_path(state, "original-commit")); > + delete_ref(NULL, "ORIG_COMMIT", NULL, REF_NO_DEREF); > > if (!get_oid("HEAD", )) > write_state_text(state, "abort-safety", oid_to_hex()); > @@ -1441,6 +1443,8 @@ static int parse_mail_rebase(struct am_state *state, > const char *mail) > > oidcpy(>orig_commit, _oid); > write_state_text(state, "original-commit", oid_to_hex(_oid)); > + update_ref("am", "ORIG_COMMIT", _oid, > +NULL, 0, UPDATE_REFS_DIE_ON_ERR); > > return 0; > } > diff --git a/contrib/completion/git-completion.bash > b/contrib/completion/git-completion.bash > index 2bd30d68cf..deea688e0e 100644 > --- a/contrib/completion/git-completion.bash > +++ b/contrib/completion/git-completion.bash > @@ -439,7 +439,7 @@ __git_refs () > track="" > ;; > *) > - for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do > + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD > ORIG_COMMIT; do > case "$i" in > $match*) > if [ -e "$dir/$i" ]; then > diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh > index 0c0f8abbf9..ef72bd5871 100644 > --- a/git-rebase--interactive.sh > +++ b/git-rebase--interactive.sh > @@ -199,12 +199,14 @@ make_patch () { > > die_with_patch () { > echo "$1" > "$state_dir"/stopped-sha > + git update-ref ORIG_COMMIT "$1" > make_patch "$1" > die "$2" > } > > exit_with_patch () { > echo "$1" > "$state_dir"/stopped-sha > + git update-ref ORIG_COMMIT "$1" > make_patch $1 > git rev-parse --verify HEAD > "$amend" > gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote > "$gpg_sign_opt")} > @@ -841,7 +843,7 @@ To continue rebase after editing, run: > exit > ;; > show-current-patch) > - exec git show "$(cat "$state_dir/stopped-sha")" -- > + exec git show ORIG_COMMIT -- > ;; > esac > > @@ -858,6 +860,7 @@ fi > > orig_head=$(git rev-parse --verify HEAD) || die "$(gettext "No HEAD?")" > mkdir -p "$state_dir" || die "$(eval_gettext "Could not create temporary > \$state_dir")" > +rm -f "$(git rev-parse --git-path ORIG_COMMIT)" > > : > "$state_dir"/interactive || die "$(gettext "Could not mark as > interactive")" > write_basic_state > diff --git a/git-rebase--merge.sh
[PATCH v2 3/3] rebase: introduce and use pseudo-ref ORIG_COMMIT
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 ORIG_COMMIT. 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 LandscheidtSigned-off-by: Nguyễn Thái Ngọc Duy --- Documentation/git-rebase.txt | 3 ++- builtin/am.c | 4 contrib/completion/git-completion.bash | 2 +- git-rebase--interactive.sh | 5 - git-rebase--merge.sh | 4 +++- git-rebase.sh | 1 + sequencer.c| 3 +++ t/t3400-rebase.sh | 3 ++- t/t3404-rebase-interactive.sh | 5 - 9 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 7ef9577472..6da9296bf8 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -252,7 +252,8 @@ leave out at most one of A and B, in which case it defaults to HEAD. --show-current-patch:: Show the current patch in an interactive rebase or when rebase - is stopped because of conflicts. + is stopped because of conflicts. This is the equivalent of + `git show ORIG_COMMIT`. -m:: --merge:: diff --git a/builtin/am.c b/builtin/am.c index caec50cba9..bf9b356340 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -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, "ORIG_COMMIT", NULL, REF_NO_DEREF); if (split_mail(state, patch_format, paths, keep_cr) < 0) { am_destroy(state); @@ -1110,6 +,7 @@ static void am_next(struct am_state *state) oidclr(>orig_commit); unlink(am_path(state, "original-commit")); + delete_ref(NULL, "ORIG_COMMIT", NULL, REF_NO_DEREF); if (!get_oid("HEAD", )) write_state_text(state, "abort-safety", oid_to_hex()); @@ -1441,6 +1443,8 @@ static int parse_mail_rebase(struct am_state *state, const char *mail) oidcpy(>orig_commit, _oid); write_state_text(state, "original-commit", oid_to_hex(_oid)); + update_ref("am", "ORIG_COMMIT", _oid, + NULL, 0, UPDATE_REFS_DIE_ON_ERR); return 0; } diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 2bd30d68cf..deea688e0e 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -439,7 +439,7 @@ __git_refs () track="" ;; *) - for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD ORIG_COMMIT; do case "$i" in $match*) if [ -e "$dir/$i" ]; then diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 0c0f8abbf9..ef72bd5871 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -199,12 +199,14 @@ make_patch () { die_with_patch () { echo "$1" > "$state_dir"/stopped-sha + git update-ref ORIG_COMMIT "$1" make_patch "$1" die "$2" } exit_with_patch () { echo "$1" > "$state_dir"/stopped-sha + git update-ref ORIG_COMMIT "$1" make_patch $1 git rev-parse --verify HEAD > "$amend" gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} @@ -841,7 +843,7 @@ To continue rebase after editing, run: exit ;; show-current-patch) - exec git show "$(cat "$state_dir/stopped-sha")" -- + exec git show ORIG_COMMIT -- ;; esac @@ -858,6 +860,7 @@ fi orig_head=$(git rev-parse --verify HEAD) || die "$(gettext "No HEAD?")" mkdir -p "$state_dir" || die "$(eval_gettext "Could not create temporary \$state_dir")" +rm -f "$(git rev-parse --git-path ORIG_COMMIT)" : > "$state_dir"/interactive || die "$(gettext "Could not mark as interactive")" write_basic_state diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh index 0a96dfae37..70966c32c3 100644 --- a/git-rebase--merge.sh +++ b/git-rebase--merge.sh @@ -57,6 +57,7 @@ call_merge () { echo "$msgnum" >"$state_dir/msgnum" cmt="$(cat "$state_dir/cmt.$msgnum")" echo "$cmt" > "$state_dir/current" + git update-ref ORIG_COMMIT "$cmt"