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

Re: [PATCH 3/3] replay: allow to specify a ref with option --ref

From
Toon Claes <toon@iotcl.com>
Date
Mar 25, 2026, 12:50 UTC
Message-ID
<87h5q413b5.fsf@iotcl.com>
In-Reply-To
<b0d49276-a9d3-435d-bb39-8cf7a08fbd11@malon.dev>
Tian Yuchen <cat@malon.dev> writes:
Show 17 quoted lines
> Hi Toon,
>
> On 3/24/26 00:09, Toon Claes wrote:
>
>
>> +	die_for_incompatible_opt2(!!opts.ref, "--ref",
>> +				  !!opts.contained, "--contained");
>
>> +	/*
>> +	 * Reference to update with the result of the replay. This stops replay
>> +	 * from taking refs from `onto`, `advance`, and `revert`. Ignores
>> +	 * `contained`.
>> +	 */
>> +	const char *ref;
>> +
>
> Do the comment and the code implementation match up here?

The comment is a bit misleading. A user cannot set the field `contained` in the struct when it passed `--ref`. But if a bug is made somewhere, but both fields can be set, that's what the comment is saying.

I can add a check to verify in replay.c that not both are set, and update the comment they are incompatible?

Show 23 quoted lines
>> @@ -427,13 +446,9 @@ int replay_revisions(struct rev_info *revs,
>>  		goto out;
>>  	}
>>  
>> -	/* In --advance or --revert mode, update the target ref */
>> -	if (advance || revert) {
>> -		const char *ref = advance ? advance : revert;
>> -		replay_result_queue_update(out, ref,
>> -					   &onto->object.oid,
>> +	if (ref)
>> +		replay_result_queue_update(out, ref, &old_oid,
>>  					   &last_commit->object.oid);
>> -	}
>>  
>>  	ret = 0;
>
> It doesn't seem like there's anything here to prevent users from 
> inputting multiple branches? I think this will result in at least one 
> branch becoming orphaned, without any error being reported.
>
> Consider this command:
>
> 	git replay --onto main --ref refs/heads/target topic1 topic2
That's interesting, I didn't think of that.
Show 21 quoted lines
>
> In replay.c we have:
>
>> if (onto_name) {
>> 		*onto = peel_committish(repo, onto_name, "--onto");
>> 		if (rinfo.positive_refexprs <
>> 		    strset_get_size(&rinfo.positive_refs))
>> 			die(_("all positive revisions given must be references"));
>> 		*update_refs = xcalloc(1, sizeof(**update_refs));
>> 		**update_refs = rinfo.positive_refs;
>> 		memset(&rinfo.positive_refs, 0, sizeof(**update_refs));
>
>
> After topic1 and topic2 are put into update_refs, only one ref 
> (refs/heads/target) is updated, since what is written in the patch is:
>
>  > +	if (ref)
>  > +		replay_result_queue_update(out, ref, &old_oid,
>  >  					   &last_commit->object.oid);
>
> I believe this is not what we expect :P
Let me look into that how we can deal with that.
-- 
Cheers,
Toon
Previous: Tian YuchenNext: Kristoffer Haugsbakk
Message 9 of 25 in “Add option --ref to git-replay(1)”
  1. 0/3 Add option --ref to git-replay(1)Toon Claes, Mar 23, 2026
  2. 1/3 t3650: use option with value consistenly with equal signToon Claes, Mar 23, 2026
  3. Kristoffer HaugsbakkMar 23, 2026
  4. Junio C HamanoMar 23, 2026
  5. Toon ClaesMar 25, 2026
  6. 2/3 builtin/replay: improve documentation on optionsToon Claes, Mar 23, 2026
  7. 3/3 replay: allow to specify a ref with option --refToon Claes, Mar 23, 2026
  8. Tian YuchenMar 23, 2026
  9. Toon ClaesMar 25, 2026
  10. Kristoffer HaugsbakkMar 23, 2026
  11. Toon ClaesMar 25, 2026
  12. 0/3 Add option --ref to git-replay(1)Toon Claes, Mar 25, 2026
  13. 1/3 builtin/replay: mark options as not negatableToon Claes, Mar 25, 2026
  14. 2/3 replay: use stuck form in documentation and help messageToon Claes, Mar 25, 2026
  15. 3/3 replay: allow to specify a ref with option --refToon Claes, Mar 25, 2026
  16. Junio C HamanoMar 25, 2026
  17. Toon ClaesMar 31, 2026
  18. Junio C HamanoMar 25, 2026
  19. Junio C HamanoMar 26, 2026
  20. Toon ClaesMar 31, 2026
  21. Junio C HamanoMar 31, 2026
  22. 0/3 Add option --ref to git-replay(1)Toon Claes, Apr 1, 2026
  23. 1/3 builtin/replay: mark options as not negatableToon Claes, Apr 1, 2026
  24. 2/3 replay: use stuck form in documentation and help messageToon Claes, Apr 1, 2026
  25. 3/3 replay: allow to specify a ref with option --refToon Claes, Apr 1, 2026

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.