Re: [PATCH v2 0/4] Handle FETCH_HEAD and MERGE_HEAD generically
From: Junio C Hamano <hidden>
Date: 2020-08-19 21:09:52
"Han-Wen Nienhuys via GitGitGadget" [off-list ref] writes:
This moves the FETCH_HEAD handling into refs.c as discussed in https://public-inbox.org/git/xmqq5z9pav01.fsf@gitster.c.googlers.com/
Thanks. The way the support for MERGE_HEAD is added to the series looks very sensible, too. Will replace.
-+static int refs_read_fetch_head(struct ref_store *ref_store,
-+ struct object_id *oid, struct strbuf *referent,
-+ unsigned int *type)
++static int refs_read_special_head(struct ref_store *ref_store,
++ const char *refname, struct object_id *oid,
++ struct strbuf *referent, unsigned int *type)
+{
+ struct strbuf full_path = STRBUF_INIT;
+ struct strbuf content = STRBUF_INIT;
+ int result = -1;
-+ strbuf_addf(&full_path, "%s/%s", ref_store->gitdir, "FETCH_HEAD");
++ strbuf_addf(&full_path, "%s/%s", ref_store->gitdir, refname);
+
+ if (strbuf_read_file(&content, full_path.buf, 0) < 0)
+ goto done;
@@ refs.c: int for_each_rawref(each_ref_fn fn, void *cb_data)
struct strbuf *referent, unsigned int *type)
{
- return ref_store->be->read_raw_ref(ref_store, refname, oid, referent, type);
-+ if (!strcmp(refname, "FETCH_HEAD")) {
-+ return refs_read_fetch_head(ref_store, oid, referent, type);
++ if (!strcmp(refname, "FETCH_HEAD") || !strcmp(refname, "MERGE_HEAD")) {
++ return refs_read_special_head(ref_store, refname, oid, referent,
++ type);
+ }
+
+ return ref_store->be->read_raw_ref(ref_store, refname, oid, referent,