Use refs API for handling sundry pseudorefs
cover Use refs API for handling sundry pseudorefs
This series changes the handling of CHERRY_PICK_HEAD and REVERT_HEAD to use the refs API, as a preliminary refactor for reftable.
No functional changes.
Han-Wen Nienhuys (3):
Make refs_ref_exists public
Treat CHERRY_PICK_HEAD as a pseudo ref
Treat REVERT_HEAD as a pseudo ref
builtin/commit.c | 34 ++++++++++++++++------------- builtin/merge.c | 2 +- path.c | 2 -- path.h | 9 ++++---- refs.c | 2 +- refs.h | 2 ++ sequencer.c | 56 +++++++++++++++++++++++++++++------------------- wt-status.c | 6 +++--- 8 files changed, 64 insertions(+), 49 deletions(-)
base-commit: 2befe97201e1f3175cce557866c5822793624b5a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-706%2Fhanwen%2Fstray-pseudorefs-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-706/hanwen/stray-pseudorefs-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/706
Signature · 1 line
gitgitgadget
PATCH 1/3 Make refs_ref_exists public
From: Han-Wen Nienhuys <[email protected]>
--- refs.c | 2 +- refs.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
refs.c +1 -1
@@ -313,7 +313,7 @@ int read_ref(const char *refname, struct object_id *oid)return read_ref_full (refname,RESOLVE_REF_READING , oid,NULL ); } -static int refs_ref_exists (struct ref_store *refs,const char *refname) +int refs_ref_exists (struct ref_store *refs,const char *refname) {return !!refs_resolve_ref_unsafe (refs, refname,RESOLVE_REF_READING ,NULL ,NULL ); }
refs.h +2 -0
@@ -105,6 +105,8 @@ int refs_verify_refname_available(struct ref_store *refs,const struct string_list *skip, struct strbuf *err); +int refs_ref_exists (struct ref_store *refs,const char *refname); +int ref_exists (const char *refname);int should_autocreate_reflog (const char *refname);
Signature · 1 line
gitgitgadget
Re: [PATCH 1/3] Make refs_ref_exists public
Quoted 1 line · Han-Wen Nienhuys via GitGitGadget
Subject: Re: [PATCH 1/3] Make
refs_ref_existspublic
Documentation/SubmittingPatches[[describe-changes]]
Applies to all three patches and probably other recent topics from you.
Quoted 34 lines
From: Han-Wen Nienhuys <[email protected]>
Signed-off-by Han-Wen Nienhuys <[email protected]>--- refs.c | 2 +- refs.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)refs.c +1
-1@@ -313,7 +313,7 @@ int read_ref(const char *refname, struct object_id *oid)return read_ref_full (refname,RESOLVE_REF_READING , oid,NULL ); } -static int refs_ref_exists (struct ref_store *refs,const char *refname) +int refs_ref_exists (struct ref_store *refs,const char *refname) {return !!refs_resolve_ref_unsafe (refs, refname,RESOLVE_REF_READING ,NULL ,NULL ); }refs.h +2
-0@@ -105,6 +105,8 @@ int refs_verify_refname_available(struct ref_store *refs,const struct string_list *skip, struct strbuf *err); +int refs_ref_exists (struct ref_store *refs,const char *refname); +int ref_exists (const char *refname);int should_autocreate_reflog (const char *refname);
PATCH 2/3 Treat CHERRY_PICK_HEAD as a pseudo ref
In reply to Han-Wen Nienhuys via GitGitGadgetFrom: Han-Wen Nienhuys <[email protected]>
Check for existence and delete CHERRY_PICK_HEAD through ref functions. This will help cherry-pick work with alternate ref storage backends.
--- builtin/commit.c | 34 +++++++++++++++++++--------------- builtin/merge.c | 2 +- path.c | 1 - path.h | 7 ++++--- sequencer.c | 42 ++++++++++++++++++++++++++---------------- wt-status.c | 4 ++-- 6 files changed, 52 insertions(+), 38 deletions(-)
builtin/commit.c +19 -15
@@ -847,21 +847,25 @@ static int prepare_to_commit(const char *index_file, const char *prefix,if (cleanup_mode ==COMMIT_MSG_CLEANUP_SCISSORS && !merge_contains_scissors)wt_status_add_cut_line (s->fp); -status_printf_ln (s,GIT_COLOR_NORMAL , - whence ==FROM_MERGE - ?_ ("\n" -"It looks like you may be committing a merge.\n" -"If this is not correct, please remove the file\n" -" %s\n" -"and try again.\n" ) - :_ ("\n" -"It looks like you may be committing a cherry-pick.\n" -"If this is not correct, please remove the file\n" -" %s\n" -"and try again.\n" ), - whence ==FROM_MERGE ? -git_path_merge_head (the_repository) : -git_path_cherry_pick_head (the_repository)); +if (whence ==FROM_MERGE ) +status_printf_ln ( + s,GIT_COLOR_NORMAL , + +_ ("\n" +"It looks like you may be committing a merge.\n" +"If this is not correct, please remove the file\n" +" %s\n" +"and try again.\n" ), +git_path_merge_head (the_repository)); +else +status_printf_ln ( + s,GIT_COLOR_NORMAL , + +_ ("\n" +"It looks like you may be committing a cherry-pick.\n" +"If this is not correct, please run\n" +" git cherry-pick --abort\n" +"and try again.\n" )); }fprintf (s->fp,"\n" );
builtin/merge.c +1 -1
@@ -1348,7 +1348,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)else die (_ ("You have not concluded your merge (MERGE_HEAD exists)." )); } -if (file_exists (git_path_cherry_pick_head (the_repository))) { +if (ref_exists ("CHERRY_PICK_HEAD" )) {if (advice_resolve_conflict)die (_ ("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n" "Please, commit your changes before you merge." ));
path.c +0 -1
@@ -1528,7 +1528,6 @@ char *xdg_cache_home(const char *filename)return NULL ; } -REPO_GIT_PATH_FUNC(cherry_pick_head, "CHERRY_PICK_HEAD") REPO_GIT_PATH_FUNC(revert_head, "REVERT_HEAD") REPO_GIT_PATH_FUNC(squash_msg, "SQUASH_MSG")REPO_GIT_PATH_FUNC (merge_msg,"MERGE_MSG" )
path.h +4 -3
@@ -170,7 +170,6 @@ void report_linked_checkout_garbage(void); }struct path_cache { -const char *cherry_pick_head;const char *revert_head;const char *squash_msg;const char *merge_msg;
@@ -182,9 +181,11 @@ struct path_cache {const char *shallow; }; -#define PATH_CACHE_INIT { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } +#define PATH_CACHE_INIT \ + { \ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ + } -const char *git_path_cherry_pick_head (struct repository *r);const char *git_path_revert_head (struct repository *r);const char *git_path_squash_msg (struct repository *r);const char *git_path_merge_msg (struct repository *r);
sequencer.c +26 -16
114 lines not on this page · raw message
wt-status.c +2 -2
@@ -1672,8 +1672,8 @@ void wt_status_get_state(struct repository *r, state->merge_in_progress =1 ; }else if (wt_status_check_rebase (NULL , state)) { ;/* all set */ - }else if (!stat (git_path_cherry_pick_head (r), &st) && - !get_oid ("CHERRY_PICK_HEAD" , &oid)) { + }else if (refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) && + !get_oid ("CHERRY_PICK_HEAD" , &oid)) { state->cherry_pick_in_progress =1 ;oidcpy (&state->cherry_pick_head_oid, &oid); }
Signature · 1 line
gitgitgadget
Re: [PATCH 2/3] Treat CHERRY_PICK_HEAD as a pseudo ref
Quoted 4 lines · Han-Wen Nienhuys via GitGitGadget
From: Han-Wen Nienhuys <[email protected]>
Check for existence and delete
CHERRY_PICK_HEADthrough ref functions. This will help cherry-pick work with alternate ref storage backends.
These two sentences are true, but this patch does another thing that is not advertised here. It stops recommending removal of CHERRY_PICK_HEAD from the filesystem with "rm" (or using "git update-ref -d" for that matter) as a way to avoid recording the current commit as a cherry-pick.
The intent of the warning message touched by this patch, I think, is that there is CHERRY_PICK_HEAD, but that might be a leftover one that does not have to do anything to do with the commit the user is making, and continuing blindly may record the commit incorrectly (perhaps 'cherry-picked-from' trailer is added incorrectly? existing notes data would be copied to the newly created commit?).
To recover from the situation, the user would want to abort the commit while keeping the changes made to the working tree and to the index to avoid the result recorded as a cherry-pick of an irrelevant commit, get rid of CHERRY_PICK_HEAD and then attempt the "git commit" again.
Does "git cherry-pick --abort" only remove CHERRY_PICK_HEAD without doing any other damage to the working tree files and to the index?
Quoted 43 lines
Signed-off-by Han-Wen Nienhuys <[email protected]>--- builtin/commit.c | 34 +++++++++++++++++++--------------- builtin/merge.c | 2 +- path.c | 1 - path.h | 7 ++++--- sequencer.c | 42 ++++++++++++++++++++++++++---------------- wt-status.c | 4 ++-- 6 files changed, 52 insertions(+), 38 deletions(-)builtin/commit.c +10
-15@@ -847,21 +847,25 @@ static int prepare_to_commit(const char *index_file, const char *prefix,if (cleanup_mode ==COMMIT_MSG_CLEANUP_SCISSORS && !merge_contains_scissors)wt_status_add_cut_line (s->fp); -status_printf_ln (s,GIT_COLOR_NORMAL , - whence ==FROM_MERGE - ?_ ("\n" -"It looks like you may be committing a merge.\n" -"If this is not correct, please remove the file\n" -" %s\n" -"and try again.\n" ) - :_ ("\n" -"It looks like you may be committing a cherry-pick.\n" -"If this is not correct, please remove the file\n" -" %s\n" -"and try again.\n" ), - whence ==FROM_MERGE ? -git_path_merge_head (the_repository) : -git_path_cherry_pick_head (the_repository)); +if (whence ==FROM_MERGE ) +status_printf_ln ( + s,GIT_COLOR_NORMAL , + +_ ("\n" +"It looks like you may be committing a merge.\n" +"If this is not correct, please remove the file\n" +" %s\n" +"and try again.\n" ), +git_path_merge_head (the_repository));
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 869
Quoted 10 lines
builtin/commit.c +9
-0+else +status_printf_ln ( + s,GIT_COLOR_NORMAL , + +_ ("\n" +"It looks like you may be committing a cherry-pick.\n" +"If this is not correct, please run\n" +" git cherry-pick --abort\n" +"and try again.\n" )); }
I do not know about this change (see above).
builtin/merge.c int cmd_merge(int argc, const char **argv, const char *prefix) · line 1351
Quoted 10 lines
builtin/merge.c +1
-1@@ -1348,7 +1348,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)else die (_ ("You have not concluded your merge (MERGE_HEAD exists)." )); } -if (file_exists (git_path_cherry_pick_head (the_repository))) { +if (ref_exists ("CHERRY_PICK_HEAD" )) {
This, and all the rest, look quite sensible.
Quoted 15 lines
wt-status.c +2
-2@@ -1672,8 +1672,8 @@ void wt_status_get_state(struct repository *r, state->merge_in_progress =1 ; }else if (wt_status_check_rebase (NULL , state)) { ;/* all set */ - }else if (!stat (git_path_cherry_pick_head (r), &st) && - !get_oid ("CHERRY_PICK_HEAD" , &oid)) { + }else if (refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) && + !get_oid ("CHERRY_PICK_HEAD" , &oid)) { state->cherry_pick_in_progress =1 ;oidcpy (&state->cherry_pick_head_oid, &oid); }
Re: [PATCH 2/3] Treat CHERRY_PICK_HEAD as a pseudo ref
Quoted 13 lines · Junio C Hamano
Quoted 4 lines · Han-Wen Nienhuys via GitGitGadget
From: Han-Wen Nienhuys <[email protected]>
Check for existence and delete
CHERRY_PICK_HEADthrough ref functions. This will help cherry-pick work with alternate ref storage backends.These two sentences are true, but this patch does another thing that is not advertised here. It stops recommending removal of
CHERRY_PICK_HEADfrom the filesystem with "rm" (or using "git update-ref -d" for that matter) as a way to avoid recording the current commit as a cherry-pick.
..
Quoted 2 lines
Does "git cherry-pick --abort" only remove
CHERRY_PICK_HEADwithout doing any other damage to the working tree files and to the index?
Good catch. I just added cherry-pick --abort without much thinking. I reverted to update-ref -d which should be equivalent to what is currently recommended.
Signature · 11 lines
Han-Wen Nienhuys - Google Munich I work 80%. Don't expect answers from me on Fridays. -- Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Re: [PATCH 2/3] Treat CHERRY_PICK_HEAD as a pseudo ref
Quoted 6 lines · Han-Wen Nienhuys
Quoted 2 lines
Does "git cherry-pick --abort" only remove
CHERRY_PICK_HEADwithout doing any other damage to the working tree files and to the index?Good catch. I just added cherry-pick --abort without much thinking. I reverted to update-ref -d which should be equivalent to what is currently recommended.
I think that is a good change, although it is unfortunate that the command line completion considers "git update-ref -d CHERRY_P<TAB>" something it should help the user with.
I tried "cherry-pick --abort" to see what happens after
$ edit A B
$ git add A
$ git rev-parse HEAD~200 >.git/CHERRY_PICK_HEAD
$ git commitand aborting the last "git commit" step. As "cherry-pick --abort" involves running "git reset --merge" internally, of course some states the user wanted to commit were wiped out and lost.
Thanks.
PATCH 3/3 Treat REVERT_HEAD as a pseudo ref
In reply to Han-Wen Nienhuys via GitGitGadgetFrom: Han-Wen Nienhuys <[email protected]>
--- path.c | 1 - path.h | 8 +++----- sequencer.c | 16 +++++++++------- wt-status.c | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-)
path.c +0 -1
@@ -1528,7 +1528,6 @@ char *xdg_cache_home(const char *filename)return NULL ; } -REPO_GIT_PATH_FUNC(revert_head, "REVERT_HEAD") REPO_GIT_PATH_FUNC(squash_msg, "SQUASH_MSG") REPO_GIT_PATH_FUNC(merge_msg, "MERGE_MSG")REPO_GIT_PATH_FUNC (merge_rr,"MERGE_RR" )
path.h +3 -5
@@ -170,7 +170,6 @@ void report_linked_checkout_garbage(void); }struct path_cache { -const char *revert_head;const char *squash_msg;const char *merge_msg;const char *merge_rr;
@@ -181,12 +180,11 @@ struct path_cache {const char *shallow; }; -#define PATH_CACHE_INIT \ - { \ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ +#define PATH_CACHE_INIT \ + { \ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ } -const char *git_path_revert_head (struct repository *r);const char *git_path_squash_msg (struct repository *r);const char *git_path_merge_msg (struct repository *r);const char *git_path_merge_rr (struct repository *r);
sequencer.c +9 -7
@@ -2317,8 +2317,10 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose) need_cleanup =1 ; } -if (file_exists (git_path_revert_head (r))) { -if (!unlink (git_path_revert_head (r)) && verbose) +if (refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" )) { +if (!refs_delete_ref (get_main_ref_store (r),"" ,"REVERT_HEAD" , +NULL ,0 ) && + verbose)warning (_ ("cancelling a revert in progress" )); opts.action =REPLAY_REVERT ; need_cleanup =1 ;
@@ -2677,7 +2679,7 @@ static int create_seq_dir(struct repository *r)const char *in_progress_error =NULL ;const char *in_progress_advice =NULL ;unsigned int advise_skip = -file_exists (git_path_revert_head (r)) || +refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ) ||refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" );if (!sequencer_get_last_command (r, &action)) {
@@ -2778,7 +2780,7 @@ static int rollback_single_pick(struct repository *r)struct object_id head_oid;if (!refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) && - !file_exists (git_path_revert_head (r))) + !refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ))return error (_ ("no cherry-pick or revert in progress" ));if (read_ref_full ("HEAD" ,0 , &head_oid,NULL ))return error (_ ("cannot resolve HEAD" ));
@@ -2872,7 +2874,7 @@ int sequencer_skip(struct repository *r, struct replay_opts *opts)*/ switch (opts->action) {case REPLAY_REVERT : -if (!file_exists (git_path_revert_head (r))) { +if (!refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" )) {if (action !=REPLAY_REVERT )return error (_ ("no revert in progress" ));if (!rollback_is_safe ())
@@ -4210,7 +4212,7 @@ static int continue_single_pick(struct repository *r)const char *argv[] = {"commit" ,NULL };if (!refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) && - !file_exists (git_path_revert_head (r))) + !refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ))return error (_ ("no cherry-pick or revert in progress" ));return run_command_v_opt (argv,RUN_GIT_CMD ); }
@@ -4390,7 +4392,7 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)/* Verify that the conflict has been resolved */ if (refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) || -file_exists (git_path_revert_head (r))) { +refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" )) { res =continue_single_pick (r);if (res) goto release_todo_list;
wt-status.c +1 -1
@@ -1678,7 +1678,7 @@ void wt_status_get_state(struct repository *r,oidcpy (&state->cherry_pick_head_oid, &oid); }wt_status_check_bisect (NULL , state); -if (!stat (git_path_revert_head (r), &st) && +if (refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ) && !get_oid ("REVERT_HEAD" , &oid)) { state->revert_in_progress =1 ;oidcpy (&state->revert_head_oid, &oid);
Signature · 1 line
gitgitgadget
Re: [PATCH 3/3] Treat REVERT_HEAD as a pseudo ref
Quoted 4 lines · Han-Wen Nienhuys via GitGitGadget
From: Han-Wen Nienhuys <[email protected]>
Signed-off-by Han-Wen Nienhuys <[email protected]>---
This does what was advertised by the proposed log message in the previous patch for REVERT_HEAD. I see nothing questionable here.
Nice.
Quoted 2 lines · Han-Wen Nienhuys via GitGitGadget
This series changes the handling of
CHERRY_PICK_HEADandREVERT_HEADto use the refs API, as a preliminary refactor for reftable.
Nice.
v2 cover Use refs API for handling sundry pseudorefs
In reply to Han-Wen Nienhuys via GitGitGadgetThis series changes the handling of CHERRY_PICK_HEAD and REVERT_HEAD to use the refs API, as a preliminary refactor for reftable.
No functional changes.
Han-Wen Nienhuys (4):
refs: make refs_ref_exists public
sequencer: treat CHERRY_PICK_HEAD as a pseudo ref builtin/commit: suggest update-ref for pseudoref removal
sequencer: treat REVERT_HEAD as a pseudo ref
builtin/commit.c | 30 +++++++++++++------------- builtin/merge.c | 2 +- path.c | 2 -- path.h | 9 ++++---- refs.c | 2 +- refs.h | 2 ++ sequencer.c | 56 +++++++++++++++++++++++++++++------------------- wt-status.c | 6 +++--- 8 files changed, 60 insertions(+), 49 deletions(-)
base-commit: 2befe97201e1f3175cce557866c5822793624b5a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-706%2Fhanwen%2Fstray-pseudorefs-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-706/hanwen/stray-pseudorefs-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/706
Range-diff vs v1:
1: 5e29fa74dc ! 1: a8467a0d66 Make refs_ref_exists public
@@ Metadata
Author: Han-Wen Nienhuys <[email protected]>
## Commit message ##
- Make refs_ref_exists public
+ refs: make refs_ref_exists public
+
+ This will be necessary to replace file existence checks for pseudorefs.
2: 06a8e8cbd1 ! 2: 2797e98446 Treat CHERRY_PICK_HEAD as a pseudo ref
@@ Metadata
Author: Han-Wen Nienhuys <[email protected]>
## Commit message ##
- Treat CHERRY_PICK_HEAD as a pseudo ref
+ sequencer: treat CHERRY_PICK_HEAD as a pseudo ref
Check for existence and delete CHERRY_PICK_HEAD through ref functions.
This will help cherry-pick work with alternate ref storage backends.
Signed-off-by: Han-Wen Nienhuys <[email protected]>
- ## builtin/commit.c ##
-@@ builtin/commit.c: static int prepare_to_commit(const char *index_file, const char *prefix,
- if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
- !merge_contains_scissors)
- wt_status_add_cut_line(s->fp);
-- status_printf_ln(s, GIT_COLOR_NORMAL,
-- whence == FROM_MERGE
-- ? _("\n"
-- "It looks like you may be committing a merge.\n"
-- "If this is not correct, please remove the file\n"
-- " %s\n"
-- "and try again.\n")
-- : _("\n"
-- "It looks like you may be committing a cherry-pick.\n"
-- "If this is not correct, please remove the file\n"
-- " %s\n"
-- "and try again.\n"),
-- whence == FROM_MERGE ?
-- git_path_merge_head(the_repository) :
-- git_path_cherry_pick_head(the_repository));
-+ if (whence == FROM_MERGE)
-+ status_printf_ln(
-+ s, GIT_COLOR_NORMAL,
-+
-+ _("\n"
-+ "It looks like you may be committing a merge.\n"
-+ "If this is not correct, please remove the file\n"
-+ " %s\n"
-+ "and try again.\n"),
-+ git_path_merge_head(the_repository));
-+ else
-+ status_printf_ln(
-+ s, GIT_COLOR_NORMAL,
-+
-+ _("\n"
-+ "It looks like you may be committing a cherry-pick.\n"
-+ "If this is not correct, please run\n"
-+ " git cherry-pick --abort\n"
-+ "and try again.\n"));
- }
-
- fprintf(s->fp, "\n");
-
## builtin/merge.c ##
@@ builtin/merge.c: int cmd_merge(int argc, const char **argv, const char *prefix)
else
-: ---------- > 3: 2681638651 builtin/commit: suggest update-ref for pseudoref removal
3: 173d81dbb4 ! 4: 9dcc10f807 Treat REVERT_HEAD as a pseudo ref @@ Metadata
Author: Han-Wen Nienhuys <[email protected]>
## Commit message ##
- Treat REVERT_HEAD as a pseudo ref
+ sequencer: treat REVERT_HEAD as a pseudo ref
Signature · 1 line
gitgitgadget
PATCH v2 1/4 refs: make refs_ref_exists public
From: Han-Wen Nienhuys <[email protected]>
This will be necessary to replace file existence checks for pseudorefs.
--- refs.c | 2 +- refs.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
refs.c +1 -1
@@ -313,7 +313,7 @@ int read_ref(const char *refname, struct object_id *oid)return read_ref_full (refname,RESOLVE_REF_READING , oid,NULL ); } -static int refs_ref_exists (struct ref_store *refs,const char *refname) +int refs_ref_exists (struct ref_store *refs,const char *refname) {return !!refs_resolve_ref_unsafe (refs, refname,RESOLVE_REF_READING ,NULL ,NULL ); }
refs.h +2 -0
@@ -105,6 +105,8 @@ int refs_verify_refname_available(struct ref_store *refs,const struct string_list *skip, struct strbuf *err); +int refs_ref_exists (struct ref_store *refs,const char *refname); +int ref_exists (const char *refname);int should_autocreate_reflog (const char *refname);
Signature · 1 line
gitgitgadget
PATCH v2 2/4 sequencer: treat CHERRY_PICK_HEAD as a pseudo ref
In reply to Han-Wen Nienhuys via GitGitGadgetFrom: Han-Wen Nienhuys <[email protected]>
Check for existence and delete CHERRY_PICK_HEAD through ref functions. This will help cherry-pick work with alternate ref storage backends.
--- builtin/merge.c | 2 +- path.c | 1 - path.h | 7 ++++--- sequencer.c | 42 ++++++++++++++++++++++++++---------------- wt-status.c | 4 ++-- 5 files changed, 33 insertions(+), 23 deletions(-)
builtin/merge.c +1 -1
@@ -1348,7 +1348,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)else die (_ ("You have not concluded your merge (MERGE_HEAD exists)." )); } -if (file_exists (git_path_cherry_pick_head (the_repository))) { +if (ref_exists ("CHERRY_PICK_HEAD" )) {if (advice_resolve_conflict)die (_ ("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n" "Please, commit your changes before you merge." ));
path.c +0 -1
@@ -1528,7 +1528,6 @@ char *xdg_cache_home(const char *filename)return NULL ; } -REPO_GIT_PATH_FUNC(cherry_pick_head, "CHERRY_PICK_HEAD") REPO_GIT_PATH_FUNC(revert_head, "REVERT_HEAD") REPO_GIT_PATH_FUNC(squash_msg, "SQUASH_MSG")REPO_GIT_PATH_FUNC (merge_msg,"MERGE_MSG" )
path.h +4 -3
@@ -170,7 +170,6 @@ void report_linked_checkout_garbage(void); }struct path_cache { -const char *cherry_pick_head;const char *revert_head;const char *squash_msg;const char *merge_msg;
@@ -182,9 +181,11 @@ struct path_cache {const char *shallow; }; -#define PATH_CACHE_INIT { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } +#define PATH_CACHE_INIT \ + { \ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ + } -const char *git_path_cherry_pick_head (struct repository *r);const char *git_path_revert_head (struct repository *r);const char *git_path_squash_msg (struct repository *r);const char *git_path_merge_msg (struct repository *r);
sequencer.c +26 -16
114 lines not on this page · raw message
wt-status.c +2 -2
@@ -1672,8 +1672,8 @@ void wt_status_get_state(struct repository *r, state->merge_in_progress =1 ; }else if (wt_status_check_rebase (NULL , state)) { ;/* all set */ - }else if (!stat (git_path_cherry_pick_head (r), &st) && - !get_oid ("CHERRY_PICK_HEAD" , &oid)) { + }else if (refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) && + !get_oid ("CHERRY_PICK_HEAD" , &oid)) { state->cherry_pick_in_progress =1 ;oidcpy (&state->cherry_pick_head_oid, &oid); }
Signature · 1 line
gitgitgadget
PATCH v2 3/4 builtin/commit: suggest update-ref for pseudoref removal
In reply to Han-Wen Nienhuys via GitGitGadgetFrom: Han-Wen Nienhuys <[email protected]>
When pseudorefs move to a different ref storage mechanism, pseudorefs no longer can be removed with 'rm'. Instead, suggest a "update-ref -d" command, which will work regardless of ref storage backend.
--- builtin/commit.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
builtin/commit.c +15 -15
@@ -844,24 +844,24 @@ static int prepare_to_commit(const char *index_file, const char *prefix,struct ident_split ci, ai;if (whence !=FROM_COMMIT ) { +const char *pseudoref = (whence ==FROM_MERGE ) ? +"MERGE_HEAD" : +"CHERRY_PICK_HEAD" ; +const char *what = (whence ==FROM_MERGE ) ? +"merge" : +"cherry-pick" ; +if (cleanup_mode ==COMMIT_MSG_CLEANUP_SCISSORS && !merge_contains_scissors)wt_status_add_cut_line (s->fp); -status_printf_ln (s,GIT_COLOR_NORMAL , - whence ==FROM_MERGE - ?_ ("\n" -"It looks like you may be committing a merge.\n" -"If this is not correct, please remove the file\n" -" %s\n" -"and try again.\n" ) - :_ ("\n" -"It looks like you may be committing a cherry-pick.\n" -"If this is not correct, please remove the file\n" -" %s\n" -"and try again.\n" ), - whence ==FROM_MERGE ? -git_path_merge_head (the_repository) : -git_path_cherry_pick_head (the_repository)); +status_printf_ln ( + s,GIT_COLOR_NORMAL , +_ ("\n" +"It looks like you may be committing a %s.\n" +"If this is not correct, please remove %s with\n" +" git update-ref -d %s\n" +"and try again.\n" ), + what, pseudoref, pseudoref); }fprintf (s->fp,"\n" );
Signature · 1 line
gitgitgadget
Re: [PATCH v2 3/4] builtin/commit: suggest update-ref for pseudoref removal
Quoted 10 lines · Han-Wen Nienhuys via GitGitGadget
From: Han-Wen Nienhuys <[email protected]>
When pseudorefs move to a different ref storage mechanism, pseudorefs no longer can be removed with 'rm'. Instead, suggest a "update-ref -d" command, which will work regardless of ref storage backend.
Signed-off-by Han-Wen Nienhuys <[email protected]>--- builtin/commit.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
The spirit is good, but the execution of this patch hurts i18n by consolidating messages that have been deliberately split and duplicated to avoid sentence lego. Limiting the scope of the change to doing
-please remove the file
- %s
+please remove %s with
+ git update-ref -d '%s'
twice may be (unfortunately) more preferrable.
As we'd be repeating the same pseudoref variable twice, introduction of an extra variable pseudoref may be a good idea.
Or would it work better to use %1$s twice, e.g.
status_printf_ln(... _(... "... please remove %1$s with\n" " git update-ref -d '%1$s'\n" "and try again.\n"), pseudoref);
I dunno.
Re: [PATCH v2 3/4] builtin/commit: suggest update-ref for pseudoref removal
Quoted 4 lines · Junio C Hamano
The spirit is good, but the execution of this patch hurts i18n by consolidating messages that have been deliberately split and duplicated to avoid sentence lego. Limiting the scope of the change to doing
Fair enough. I've just written out the complete command in the next version.
Signature · 11 lines
Han-Wen Nienhuys - Google Munich I work 80%. Don't expect answers from me on Fridays. -- Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
PATCH v2 4/4 sequencer: treat REVERT_HEAD as a pseudo ref
In reply to Han-Wen Nienhuys via GitGitGadgetFrom: Han-Wen Nienhuys <[email protected]>
--- path.c | 1 - path.h | 8 +++----- sequencer.c | 16 +++++++++------- wt-status.c | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-)
path.c +0 -1
@@ -1528,7 +1528,6 @@ char *xdg_cache_home(const char *filename)return NULL ; } -REPO_GIT_PATH_FUNC(revert_head, "REVERT_HEAD") REPO_GIT_PATH_FUNC(squash_msg, "SQUASH_MSG") REPO_GIT_PATH_FUNC(merge_msg, "MERGE_MSG")REPO_GIT_PATH_FUNC (merge_rr,"MERGE_RR" )
path.h +3 -5
@@ -170,7 +170,6 @@ void report_linked_checkout_garbage(void); }struct path_cache { -const char *revert_head;const char *squash_msg;const char *merge_msg;const char *merge_rr;
@@ -181,12 +180,11 @@ struct path_cache {const char *shallow; }; -#define PATH_CACHE_INIT \ - { \ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ +#define PATH_CACHE_INIT \ + { \ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ } -const char *git_path_revert_head (struct repository *r);const char *git_path_squash_msg (struct repository *r);const char *git_path_merge_msg (struct repository *r);const char *git_path_merge_rr (struct repository *r);
sequencer.c +9 -7
@@ -2317,8 +2317,10 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose) need_cleanup =1 ; } -if (file_exists (git_path_revert_head (r))) { -if (!unlink (git_path_revert_head (r)) && verbose) +if (refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" )) { +if (!refs_delete_ref (get_main_ref_store (r),"" ,"REVERT_HEAD" , +NULL ,0 ) && + verbose)warning (_ ("cancelling a revert in progress" )); opts.action =REPLAY_REVERT ; need_cleanup =1 ;
@@ -2677,7 +2679,7 @@ static int create_seq_dir(struct repository *r)const char *in_progress_error =NULL ;const char *in_progress_advice =NULL ;unsigned int advise_skip = -file_exists (git_path_revert_head (r)) || +refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ) ||refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" );if (!sequencer_get_last_command (r, &action)) {
@@ -2778,7 +2780,7 @@ static int rollback_single_pick(struct repository *r)struct object_id head_oid;if (!refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) && - !file_exists (git_path_revert_head (r))) + !refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ))return error (_ ("no cherry-pick or revert in progress" ));if (read_ref_full ("HEAD" ,0 , &head_oid,NULL ))return error (_ ("cannot resolve HEAD" ));
@@ -2872,7 +2874,7 @@ int sequencer_skip(struct repository *r, struct replay_opts *opts)*/ switch (opts->action) {case REPLAY_REVERT : -if (!file_exists (git_path_revert_head (r))) { +if (!refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" )) {if (action !=REPLAY_REVERT )return error (_ ("no revert in progress" ));if (!rollback_is_safe ())
@@ -4210,7 +4212,7 @@ static int continue_single_pick(struct repository *r)const char *argv[] = {"commit" ,NULL };if (!refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) && - !file_exists (git_path_revert_head (r))) + !refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ))return error (_ ("no cherry-pick or revert in progress" ));return run_command_v_opt (argv,RUN_GIT_CMD ); }
@@ -4390,7 +4392,7 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)/* Verify that the conflict has been resolved */ if (refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) || -file_exists (git_path_revert_head (r))) { +refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" )) { res =continue_single_pick (r);if (res) goto release_todo_list;
wt-status.c +1 -1
@@ -1678,7 +1678,7 @@ void wt_status_get_state(struct repository *r,oidcpy (&state->cherry_pick_head_oid, &oid); }wt_status_check_bisect (NULL , state); -if (!stat (git_path_revert_head (r), &st) && +if (refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ) && !get_oid ("REVERT_HEAD" , &oid)) { state->revert_in_progress =1 ;oidcpy (&state->revert_head_oid, &oid);
Signature · 1 line
gitgitgadget
v3 cover Use refs API for handling sundry pseudorefs
In reply to Han-Wen Nienhuys via GitGitGadgetThis series changes the handling of CHERRY_PICK_HEAD and REVERT_HEAD to use the refs API, as a preliminary refactor for reftable.
No functional changes.
Han-Wen Nienhuys (4):
refs: make refs_ref_exists public
sequencer: treat CHERRY_PICK_HEAD as a pseudo ref builtin/commit: suggest update-ref for pseudoref removal
sequencer: treat REVERT_HEAD as a pseudo ref
builtin/commit.c | 26 +++++++++++----------- builtin/merge.c | 2 +- path.c | 2 -- path.h | 9 ++++---- refs.c | 2 +- refs.h | 2 ++ sequencer.c | 56 +++++++++++++++++++++++++++++------------------- wt-status.c | 6 +++--- 8 files changed, 57 insertions(+), 48 deletions(-)
base-commit: 675a4aaf3b226c0089108221b96559e0baae5de9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-706%2Fhanwen%2Fstray-pseudorefs-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-706/hanwen/stray-pseudorefs-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/706
Range-diff vs v2:
1: a8467a0d66 = 1: bfea176682 refs: make refs_ref_exists public
2: 2797e98446 = 2: 5ff5d2c663 sequencer: treat CHERRY_PICK_HEAD as a pseudo ref
3: 2681638651 ! 3: 8aacde69c8 builtin/commit: suggest update-ref for pseudoref removal
@@ Commit message
## builtin/commit.c ##
@@ builtin/commit.c: static int prepare_to_commit(const char *index_file, const char *prefix,
- struct ident_split ci, ai;
-
- if (whence != FROM_COMMIT) {
-+ const char *pseudoref = (whence == FROM_MERGE) ?
-+ "MERGE_HEAD" :
-+ "CHERRY_PICK_HEAD";
-+ const char *what = (whence == FROM_MERGE) ?
-+ "merge" :
-+ "cherry-pick";
-+
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
!merge_contains_scissors)
wt_status_add_cut_line(s->fp);
@@ builtin/commit.c: static int prepare_to_commit(const char *index_file, const cha
- "If this is not correct, please remove the file\n"
- " %s\n"
- "and try again.\n"),
-- whence == FROM_MERGE ?
-- git_path_merge_head(the_repository) :
-- git_path_cherry_pick_head(the_repository));
+ status_printf_ln(
+ s, GIT_COLOR_NORMAL,
-+ _("\n"
-+ "It looks like you may be committing a %s.\n"
-+ "If this is not correct, please remove %s with\n"
-+ " git update-ref -d %s\n"
-+ "and try again.\n"),
-+ what, pseudoref, pseudoref);
+ whence == FROM_MERGE ?
+- git_path_merge_head(the_repository) :
+- git_path_cherry_pick_head(the_repository));
++ _("\n"
++ "It looks like you may be committing a merge.\n"
++ "If this is not correct, please run\n"
++ " git update-ref -d MERGE_HEAD\n"
++ "and try again.\n") :
++ _("\n"
++ "It looks like you may be committing a cherry-pick.\n"
++ "If this is not correct, please run\n"
++ " git update-ref -d CHERRY_PICK_HEAD\n"
++ "and try again.\n"));
}
fprintf(s->fp, "\n"); 4: 9dcc10f807 = 4: 9ba0136645 sequencer: treat REVERT_HEAD as a pseudo ref
Signature · 1 line
gitgitgadget
PATCH v3 1/4 refs: make refs_ref_exists public
From: Han-Wen Nienhuys <[email protected]>
This will be necessary to replace file existence checks for pseudorefs.
--- refs.c | 2 +- refs.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
refs.c +1 -1
@@ -313,7 +313,7 @@ int read_ref(const char *refname, struct object_id *oid)return read_ref_full (refname,RESOLVE_REF_READING , oid,NULL ); } -static int refs_ref_exists (struct ref_store *refs,const char *refname) +int refs_ref_exists (struct ref_store *refs,const char *refname) {return !!refs_resolve_ref_unsafe (refs, refname,RESOLVE_REF_READING ,NULL ,NULL ); }
refs.h +2 -0
@@ -105,6 +105,8 @@ int refs_verify_refname_available(struct ref_store *refs,const struct string_list *skip, struct strbuf *err); +int refs_ref_exists (struct ref_store *refs,const char *refname); +int ref_exists (const char *refname);int should_autocreate_reflog (const char *refname);
Signature · 1 line
gitgitgadget
PATCH v3 2/4 sequencer: treat CHERRY_PICK_HEAD as a pseudo ref
In reply to Han-Wen Nienhuys via GitGitGadgetFrom: Han-Wen Nienhuys <[email protected]>
Check for existence and delete CHERRY_PICK_HEAD through ref functions. This will help cherry-pick work with alternate ref storage backends.
--- builtin/merge.c | 2 +- path.c | 1 - path.h | 7 ++++--- sequencer.c | 42 ++++++++++++++++++++++++++---------------- wt-status.c | 4 ++-- 5 files changed, 33 insertions(+), 23 deletions(-)
builtin/merge.c +1 -1
@@ -1348,7 +1348,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)else die (_ ("You have not concluded your merge (MERGE_HEAD exists)." )); } -if (file_exists (git_path_cherry_pick_head (the_repository))) { +if (ref_exists ("CHERRY_PICK_HEAD" )) {if (advice_resolve_conflict)die (_ ("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n" "Please, commit your changes before you merge." ));
path.c +0 -1
@@ -1528,7 +1528,6 @@ char *xdg_cache_home(const char *filename)return NULL ; } -REPO_GIT_PATH_FUNC(cherry_pick_head, "CHERRY_PICK_HEAD") REPO_GIT_PATH_FUNC(revert_head, "REVERT_HEAD") REPO_GIT_PATH_FUNC(squash_msg, "SQUASH_MSG")REPO_GIT_PATH_FUNC (merge_msg,"MERGE_MSG" )
path.h +4 -3
@@ -170,7 +170,6 @@ void report_linked_checkout_garbage(void); }struct path_cache { -const char *cherry_pick_head;const char *revert_head;const char *squash_msg;const char *merge_msg;
@@ -182,9 +181,11 @@ struct path_cache {const char *shallow; }; -#define PATH_CACHE_INIT { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } +#define PATH_CACHE_INIT \ + { \ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ + } -const char *git_path_cherry_pick_head (struct repository *r);const char *git_path_revert_head (struct repository *r);const char *git_path_squash_msg (struct repository *r);const char *git_path_merge_msg (struct repository *r);
sequencer.c +26 -16
114 lines not on this page · raw message
wt-status.c +2 -2
@@ -1672,8 +1672,8 @@ void wt_status_get_state(struct repository *r, state->merge_in_progress =1 ; }else if (wt_status_check_rebase (NULL , state)) { ;/* all set */ - }else if (!stat (git_path_cherry_pick_head (r), &st) && - !get_oid ("CHERRY_PICK_HEAD" , &oid)) { + }else if (refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) && + !get_oid ("CHERRY_PICK_HEAD" , &oid)) { state->cherry_pick_in_progress =1 ;oidcpy (&state->cherry_pick_head_oid, &oid); }
Signature · 1 line
gitgitgadget
PATCH v3 3/4 builtin/commit: suggest update-ref for pseudoref removal
In reply to Han-Wen Nienhuys via GitGitGadgetFrom: Han-Wen Nienhuys <[email protected]>
When pseudorefs move to a different ref storage mechanism, pseudorefs no longer can be removed with 'rm'. Instead, suggest a "update-ref -d" command, which will work regardless of ref storage backend.
--- builtin/commit.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
builtin/commit.c +12 -14
@@ -847,21 +847,19 @@ static int prepare_to_commit(const char *index_file, const char *prefix,if (cleanup_mode ==COMMIT_MSG_CLEANUP_SCISSORS && !merge_contains_scissors)wt_status_add_cut_line (s->fp); -status_printf_ln (s,GIT_COLOR_NORMAL , - whence ==FROM_MERGE - ?_ ("\n" -"It looks like you may be committing a merge.\n" -"If this is not correct, please remove the file\n" -" %s\n" -"and try again.\n" ) - :_ ("\n" -"It looks like you may be committing a cherry-pick.\n" -"If this is not correct, please remove the file\n" -" %s\n" -"and try again.\n" ), +status_printf_ln ( + s,GIT_COLOR_NORMAL , whence ==FROM_MERGE ? -git_path_merge_head (the_repository) : -git_path_cherry_pick_head (the_repository)); +_ ("\n" +"It looks like you may be committing a merge.\n" +"If this is not correct, please run\n" +" git update-ref -d MERGE_HEAD\n" +"and try again.\n" ) : +_ ("\n" +"It looks like you may be committing a cherry-pick.\n" +"If this is not correct, please run\n" +" git update-ref -d CHERRY_PICK_HEAD\n" +"and try again.\n" )); }fprintf (s->fp,"\n" );
Signature · 1 line
gitgitgadget
PATCH v3 4/4 sequencer: treat REVERT_HEAD as a pseudo ref
In reply to Han-Wen Nienhuys via GitGitGadgetFrom: Han-Wen Nienhuys <[email protected]>
--- path.c | 1 - path.h | 8 +++----- sequencer.c | 16 +++++++++------- wt-status.c | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-)
path.c +0 -1
@@ -1528,7 +1528,6 @@ char *xdg_cache_home(const char *filename)return NULL ; } -REPO_GIT_PATH_FUNC(revert_head, "REVERT_HEAD") REPO_GIT_PATH_FUNC(squash_msg, "SQUASH_MSG") REPO_GIT_PATH_FUNC(merge_msg, "MERGE_MSG")REPO_GIT_PATH_FUNC (merge_rr,"MERGE_RR" )
path.h +3 -5
@@ -170,7 +170,6 @@ void report_linked_checkout_garbage(void); }struct path_cache { -const char *revert_head;const char *squash_msg;const char *merge_msg;const char *merge_rr;
@@ -181,12 +180,11 @@ struct path_cache {const char *shallow; }; -#define PATH_CACHE_INIT \ - { \ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ +#define PATH_CACHE_INIT \ + { \ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ } -const char *git_path_revert_head (struct repository *r);const char *git_path_squash_msg (struct repository *r);const char *git_path_merge_msg (struct repository *r);const char *git_path_merge_rr (struct repository *r);
sequencer.c +9 -7
@@ -2317,8 +2317,10 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose) need_cleanup =1 ; } -if (file_exists (git_path_revert_head (r))) { -if (!unlink (git_path_revert_head (r)) && verbose) +if (refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" )) { +if (!refs_delete_ref (get_main_ref_store (r),"" ,"REVERT_HEAD" , +NULL ,0 ) && + verbose)warning (_ ("cancelling a revert in progress" )); opts.action =REPLAY_REVERT ; need_cleanup =1 ;
@@ -2677,7 +2679,7 @@ static int create_seq_dir(struct repository *r)const char *in_progress_error =NULL ;const char *in_progress_advice =NULL ;unsigned int advise_skip = -file_exists (git_path_revert_head (r)) || +refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ) ||refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" );if (!sequencer_get_last_command (r, &action)) {
@@ -2778,7 +2780,7 @@ static int rollback_single_pick(struct repository *r)struct object_id head_oid;if (!refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) && - !file_exists (git_path_revert_head (r))) + !refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ))return error (_ ("no cherry-pick or revert in progress" ));if (read_ref_full ("HEAD" ,0 , &head_oid,NULL ))return error (_ ("cannot resolve HEAD" ));
@@ -2872,7 +2874,7 @@ int sequencer_skip(struct repository *r, struct replay_opts *opts)*/ switch (opts->action) {case REPLAY_REVERT : -if (!file_exists (git_path_revert_head (r))) { +if (!refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" )) {if (action !=REPLAY_REVERT )return error (_ ("no revert in progress" ));if (!rollback_is_safe ())
@@ -4210,7 +4212,7 @@ static int continue_single_pick(struct repository *r)const char *argv[] = {"commit" ,NULL };if (!refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) && - !file_exists (git_path_revert_head (r))) + !refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ))return error (_ ("no cherry-pick or revert in progress" ));return run_command_v_opt (argv,RUN_GIT_CMD ); }
@@ -4390,7 +4392,7 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)/* Verify that the conflict has been resolved */ if (refs_ref_exists (get_main_ref_store (r),"CHERRY_PICK_HEAD" ) || -file_exists (git_path_revert_head (r))) { +refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" )) { res =continue_single_pick (r);if (res) goto release_todo_list;
wt-status.c +1 -1
@@ -1678,7 +1678,7 @@ void wt_status_get_state(struct repository *r,oidcpy (&state->cherry_pick_head_oid, &oid); }wt_status_check_bisect (NULL , state); -if (!stat (git_path_revert_head (r), &st) && +if (refs_ref_exists (get_main_ref_store (r),"REVERT_HEAD" ) && !get_oid ("REVERT_HEAD" , &oid)) { state->revert_in_progress =1 ;oidcpy (&state->revert_head_oid, &oid);
Signature · 1 line
gitgitgadget
Quoted 10 lines · Han-Wen Nienhuys via GitGitGadget
This series changes the handling of
CHERRY_PICK_HEADandREVERT_HEADto use the refs API, as a preliminary refactor for reftable.No functional changes.
Han-Wen Nienhuys (4):
refs: makerefs_ref_existspublic
sequencer: treatCHERRY_PICK_HEADas a pseudo ref builtin/commit: suggest update-ref for pseudoref removal
sequencer: treatREVERT_HEADas a pseudo ref
Thanks.