git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/7] refs: convert AUTO_MERGE to become a normal pseudo-ref

From
Patrick Steinhardt <ps@pks.im>
Date
Jan 22, 2024, 10:45 UTC
Message-ID
<Za5HOkWM3IQIiKDJ@tanuki>
In-Reply-To
<xmqqjzo5jf79.fsf@gitster.g>
On Fri, Jan 19, 2024 at 11:28:10AM -0800, Junio C Hamano wrote:
Show 38 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > In 70c70de616 (refs: complete list of special refs, 2023-12-14) we have
> > inrtoduced a new `is_special_ref()` function that classifies some refs
> 
> "introduced"
> 
> > @@ -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)
> 
> We used to ignore errors while updating AUTO_MERGE, implying that it
> is an optional nicety that does not have to block the merge.  Now we
> explicitly mark the resulting index unclean.  While my gut feeling
> says that it should not matter all that much (as such a failure
> would be rare enough that the user may want to inspect and double
> check the situation before going forward), I am not 100% sure if the
> change is behaviour is acceptable by everybody (cc'ed Elijah for
> second opinion).

We only ignored _some_ errors when updating AUTO_MERGE. Most notably we die when we fail to create the file, but we succeed in case its contents aren't written. This does not make much sense to me -- my expectation would be that we should verify either the complete operation or nothing of it and ignore all failures. Gracefully leaving an empty file behind is a weird in-between state, so I'd claim it's more or less an oversight that we did not perform proper error checking here.

Patrick
Previous: Junio C HamanoNext: Elijah Newren
Message 10 of 23 in “refs: convert special refs to become normal pseudo-refs”
  1. 0/7 refs: convert special refs to become normal pseudo-refsPatrick Steinhardt, Jan 19, 2024
  2. 1/7 sequencer: clean up pseudo refs with REF_NO_DEREFPatrick Steinhardt, Jan 19, 2024
  3. Junio C HamanoJan 19, 2024
  4. Patrick SteinhardtJan 22, 2024
  5. Karthik NayakJan 22, 2024
  6. Patrick SteinhardtJan 22, 2024
  7. 2/7 sequencer: delete REBASE_HEAD in correct repo when picking commitsPatrick Steinhardt, Jan 19, 2024
  8. 3/7 refs: convert AUTO_MERGE to become a normal pseudo-refPatrick Steinhardt, Jan 19, 2024
  9. Junio C HamanoJan 19, 2024
  10. Patrick SteinhardtJan 22, 2024
  11. Elijah NewrenJan 24, 2024
  12. Karthik NayakJan 22, 2024
  13. 4/7 sequencer: introduce functions to handle autostashes via refsPatrick Steinhardt, Jan 19, 2024
  14. Junio C HamanoJan 19, 2024
  15. Patrick SteinhardtJan 22, 2024
  16. Phillip WoodJan 22, 2024
  17. Junio C HamanoJan 22, 2024
  18. 5/7 refs: convert MERGE_AUTOSTASH to become a normal pseudo-refPatrick Steinhardt, Jan 19, 2024
  19. 6/7 refs: redefine special refsPatrick Steinhardt, Jan 19, 2024
  20. Junio C HamanoJan 19, 2024
  21. 7/7 Documentation: add "special refs" to the glossaryPatrick Steinhardt, Jan 19, 2024
  22. Phillip WoodJan 23, 2024
  23. Patrick SteinhardtJan 24, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.