mirror of
https://github.com/git/git.git
synced 2024-05-05 17:36:18 +02:00
refs: convert AUTO_MERGE to become a normal pseudo-ref
In 70c70de616
(refs: complete list of special refs, 2023-12-14) we have
inrtoduced a new `is_special_ref()` function that classifies some refs
as being special. The rule is that special refs are exclusively read and
written via the filesystem directly, whereas normal refs exclucsively go
via the refs API.
The intent of that commit was to record the status quo so that we know
to route reads of such special refs consistently. Eventually, the list
should be reduced to its bare minimum of refs which really are special,
namely FETCH_HEAD and MERGE_HEAD.
Follow up on this promise and convert the AUTO_MERGE ref to become a
normal pseudo-ref by using the refs API to both read and write it
instead of accessing the filesystem directly.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
bb02e95f3b
commit
fd7c6ffa9e
3
branch.c
3
branch.c
|
@ -817,7 +817,8 @@ void remove_merge_branch_state(struct repository *r)
|
|||
unlink(git_path_merge_rr(r));
|
||||
unlink(git_path_merge_msg(r));
|
||||
unlink(git_path_merge_mode(r));
|
||||
unlink(git_path_auto_merge(r));
|
||||
refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
|
||||
NULL, REF_NO_DEREF);
|
||||
save_autostash(git_path_merge_autostash(r));
|
||||
}
|
||||
|
||||
|
|
|
@ -515,7 +515,7 @@ static int finish_rebase(struct rebase_options *opts)
|
|||
int ret = 0;
|
||||
|
||||
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
|
||||
unlink(git_path_auto_merge(the_repository));
|
||||
delete_ref(NULL, "AUTO_MERGE", NULL, REF_NO_DEREF);
|
||||
apply_autostash(state_dir_path("autostash", opts));
|
||||
/*
|
||||
* We ignore errors in 'git maintenance run --auto', since the
|
||||
|
|
19
merge-ort.c
19
merge-ort.c
|
@ -38,6 +38,7 @@
|
|||
#include "path.h"
|
||||
#include "promisor-remote.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "refs.h"
|
||||
#include "revision.h"
|
||||
#include "sparse-index.h"
|
||||
#include "strmap.h"
|
||||
|
@ -4659,9 +4660,6 @@ void merge_switch_to_result(struct merge_options *opt,
|
|||
{
|
||||
assert(opt->priv == NULL);
|
||||
if (result->clean >= 0 && update_worktree_and_index) {
|
||||
const char *filename;
|
||||
FILE *fp;
|
||||
|
||||
trace2_region_enter("merge", "checkout", opt->repo);
|
||||
if (checkout(opt, head, result->tree)) {
|
||||
/* failure to function */
|
||||
|
@ -4687,10 +4685,17 @@ void merge_switch_to_result(struct merge_options *opt,
|
|||
trace2_region_leave("merge", "record_conflicted", opt->repo);
|
||||
|
||||
trace2_region_enter("merge", "write_auto_merge", opt->repo);
|
||||
filename = git_path_auto_merge(opt->repo);
|
||||
fp = xfopen(filename, "w");
|
||||
fprintf(fp, "%s\n", oid_to_hex(&result->tree->object.oid));
|
||||
fclose(fp);
|
||||
if (refs_update_ref(get_main_ref_store(opt->repo), "", "AUTO_MERGE",
|
||||
&result->tree->object.oid, NULL, REF_NO_DEREF,
|
||||
UPDATE_REFS_MSG_ON_ERR)) {
|
||||
/* failure to function */
|
||||
opt->priv = NULL;
|
||||
result->clean = -1;
|
||||
merge_finalize(opt, result);
|
||||
trace2_region_leave("merge", "write_auto_merge",
|
||||
opt->repo);
|
||||
return;
|
||||
}
|
||||
trace2_region_leave("merge", "write_auto_merge", opt->repo);
|
||||
}
|
||||
if (display_update_msgs)
|
||||
|
|
1
path.c
1
path.c
|
@ -1589,6 +1589,5 @@ REPO_GIT_PATH_FUNC(merge_rr, "MERGE_RR")
|
|||
REPO_GIT_PATH_FUNC(merge_mode, "MERGE_MODE")
|
||||
REPO_GIT_PATH_FUNC(merge_head, "MERGE_HEAD")
|
||||
REPO_GIT_PATH_FUNC(merge_autostash, "MERGE_AUTOSTASH")
|
||||
REPO_GIT_PATH_FUNC(auto_merge, "AUTO_MERGE")
|
||||
REPO_GIT_PATH_FUNC(fetch_head, "FETCH_HEAD")
|
||||
REPO_GIT_PATH_FUNC(shallow, "shallow")
|
||||
|
|
1
path.h
1
path.h
|
@ -176,7 +176,6 @@ const char *git_path_merge_rr(struct repository *r);
|
|||
const char *git_path_merge_mode(struct repository *r);
|
||||
const char *git_path_merge_head(struct repository *r);
|
||||
const char *git_path_merge_autostash(struct repository *r);
|
||||
const char *git_path_auto_merge(struct repository *r);
|
||||
const char *git_path_fetch_head(struct repository *r);
|
||||
const char *git_path_shallow(struct repository *r);
|
||||
|
||||
|
|
1
refs.c
1
refs.c
|
@ -1874,7 +1874,6 @@ static int is_special_ref(const char *refname)
|
|||
* (normal ones).
|
||||
*/
|
||||
static const char * const special_refs[] = {
|
||||
"AUTO_MERGE",
|
||||
"FETCH_HEAD",
|
||||
"MERGE_AUTOSTASH",
|
||||
"MERGE_HEAD",
|
||||
|
|
|
@ -263,7 +263,6 @@ static void repo_clear_path_cache(struct repo_path_cache *cache)
|
|||
FREE_AND_NULL(cache->merge_mode);
|
||||
FREE_AND_NULL(cache->merge_head);
|
||||
FREE_AND_NULL(cache->merge_autostash);
|
||||
FREE_AND_NULL(cache->auto_merge);
|
||||
FREE_AND_NULL(cache->fetch_head);
|
||||
FREE_AND_NULL(cache->shallow);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ struct repo_path_cache {
|
|||
char *merge_mode;
|
||||
char *merge_head;
|
||||
char *merge_autostash;
|
||||
char *auto_merge;
|
||||
char *fetch_head;
|
||||
char *shallow;
|
||||
};
|
||||
|
|
12
sequencer.c
12
sequencer.c
|
@ -2408,7 +2408,8 @@ static int do_pick_commit(struct repository *r,
|
|||
refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
|
||||
NULL, REF_NO_DEREF);
|
||||
unlink(git_path_merge_msg(r));
|
||||
unlink(git_path_auto_merge(r));
|
||||
refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
|
||||
NULL, REF_NO_DEREF);
|
||||
fprintf(stderr,
|
||||
_("dropping %s %s -- patch contents already upstream\n"),
|
||||
oid_to_hex(&commit->object.oid), msg.subject);
|
||||
|
@ -2818,7 +2819,8 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
|
|||
need_cleanup = 1;
|
||||
}
|
||||
|
||||
unlink(git_path_auto_merge(r));
|
||||
refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
|
||||
NULL, REF_NO_DEREF);
|
||||
|
||||
if (!need_cleanup)
|
||||
return;
|
||||
|
@ -4766,7 +4768,8 @@ static int pick_commits(struct repository *r,
|
|||
}
|
||||
unlink(rebase_path_author_script());
|
||||
unlink(git_path_merge_head(r));
|
||||
unlink(git_path_auto_merge(r));
|
||||
refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
|
||||
NULL, REF_NO_DEREF);
|
||||
refs_delete_ref(get_main_ref_store(r), "", "REBASE_HEAD",
|
||||
NULL, REF_NO_DEREF);
|
||||
|
||||
|
@ -5123,7 +5126,8 @@ static int commit_staged_changes(struct repository *r,
|
|||
return error(_("could not commit staged changes."));
|
||||
unlink(rebase_path_amend());
|
||||
unlink(git_path_merge_head(r));
|
||||
unlink(git_path_auto_merge(r));
|
||||
refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
|
||||
NULL, REF_NO_DEREF);
|
||||
if (final_fixup) {
|
||||
unlink(rebase_path_fixup_msg());
|
||||
unlink(rebase_path_squash_msg());
|
||||
|
|
Loading…
Reference in New Issue