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

Re: [PATCH 4/6] update-ref: add support for 'symref-create' command

From
Karthik Nayak <karthik.188@gmail.com>
Date
May 19, 2024, 14:01 UTC
Message-ID
<CAOLa=ZQzxax0GoCKMTNxdwy+0f+nU3HFC_ixp24RXgW0+jeXWQ@mail.gmail.com>
In-Reply-To
<ZkXpbLPGgdqy6YJk@tanuki>
Patrick Steinhardt <ps@pks.im> writes:
Show 23 quoted lines
> On Tue, May 14, 2024 at 02:44:09PM +0200, Karthik Nayak wrote:
>> From: Karthik Nayak <karthik.188@gmail.com>
>> diff --git a/refs.c b/refs.c
>> index c2c9889466..6b724343fe 100644
>> --- a/refs.c
>> +++ b/refs.c
>> @@ -1302,15 +1302,16 @@ int ref_transaction_update(struct ref_transaction *transaction,
>>  int ref_transaction_create(struct ref_transaction *transaction,
>>  			   const char *refname,
>>  			   const struct object_id *new_oid,
>> +			   const char *new_target,
>>  			   unsigned int flags, const char *msg,
>>  			   struct strbuf *err)
>>  {
>> -	if (!new_oid || is_null_oid(new_oid)) {
>> -		strbuf_addf(err, "'%s' has a null OID", refname);
>> +	if ((!new_oid || is_null_oid(new_oid)) && !new_target) {
>> +		strbuf_addf(err, "'%s' has a null OID or no new target", refname);
>>  		return 1;
>>  	}
>
> Shouldn't this be "'%s' has neither an OID nor a target"?
>

Well it's actually all three. If new_oid is not set, or if new_oid is NULL or there is no new_target.

I think "'%s' has neither a valid OID nor a target" would be best.
> Also, we again miss `new_oid && new_target`.
>
Will fix for all the commands!
Show 21 quoted lines
>> diff --git a/t/t0600-reffiles-backend.sh b/t/t0600-reffiles-backend.sh
>> index a390cffc80..cc7e20431e 100755
>> --- a/t/t0600-reffiles-backend.sh
>> +++ b/t/t0600-reffiles-backend.sh
>> @@ -468,4 +468,36 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
>>  	esac
>>  '
>>
>> +test_expect_success SYMLINKS 'symref transaction supports symlinks' '
>> +	test_when_finished "git symbolic-ref -d TESTSYMREFONE" &&
>> +	git update-ref refs/heads/new @ &&
>> +	test_config core.prefersymlinkrefs true &&
>> +	cat >stdin <<-EOF &&
>> +	start
>> +	symref-create TESTSYMREFONE refs/heads/new
>
> Let's future proof this and create the ref with a name that matches our
> root ref restrictions, like "TEST_SYMREF_HEAD". We do plan to enforce
> those soonish, so these tests would break.
>
> Patrick
Makes sense, will fix. Thanks.
Previous: Patrick SteinhardtNext: Karthik Nayak
Message 13 of 50 in “update-ref: add symref support for --stdin”
  1. 0/6 update-ref: add symref support for --stdinKarthik Nayak, May 14, 2024
  2. 1/6 refs: create and use `ref_update_ref_must_exist()`Karthik Nayak, May 14, 2024
  3. Patrick SteinhardtMay 16, 2024
  4. Karthik NayakMay 17, 2024
  5. 2/6 update-ref: add support for 'symref-verify' commandKarthik Nayak, May 14, 2024
  6. Patrick SteinhardtMay 16, 2024
  7. Karthik NayakMay 17, 2024
  8. Patrick SteinhardtMay 21, 2024
  9. 3/6 update-ref: add support for 'symref-delete' commandKarthik Nayak, May 14, 2024
  10. Patrick SteinhardtMay 16, 2024
  11. 4/6 update-ref: add support for 'symref-create' commandKarthik Nayak, May 14, 2024
  12. Patrick SteinhardtMay 16, 2024
  13. Karthik NayakMay 19, 2024
  14. 5/6 reftable: pick either 'oid' or 'target' for new updatesKarthik Nayak, May 14, 2024
  15. 6/6 update-ref: add support for 'symref-update' commandKarthik Nayak, May 14, 2024
  16. Patrick SteinhardtMay 16, 2024
  17. Karthik NayakMay 21, 2024
  18. Karthik NayakMay 22, 2024
  19. 0/6 update-ref: add symref support for --stdinKarthik Nayak, May 22, 2024
  20. 1/6 refs: create and use `ref_update_expects_existing_old_ref()`Karthik Nayak, May 22, 2024
  21. 2/6 update-ref: add support for 'symref-verify' commandKarthik Nayak, May 22, 2024
  22. 3/6 update-ref: add support for 'symref-delete' commandKarthik Nayak, May 22, 2024
  23. 4/6 update-ref: add support for 'symref-create' commandKarthik Nayak, May 22, 2024
  24. 5/6 reftable: pick either 'oid' or 'target' for new updatesKarthik Nayak, May 22, 2024
  25. 6/6 update-ref: add support for 'symref-update' commandKarthik Nayak, May 22, 2024
  26. Junio C HamanoMay 25, 2024
  27. Karthik NayakMay 29, 2024
  28. Junio C HamanoMay 23, 2024
  29. Karthik NayakMay 23, 2024
  30. Junio C HamanoMay 23, 2024
  31. Karthik NayakMay 23, 2024
  32. Eric SunshineMay 23, 2024
  33. Junio C HamanoMay 23, 2024
  34. Eric SunshineMay 23, 2024
  35. Junio C HamanoMay 23, 2024
  36. Junio C HamanoMay 23, 2024
  37. Junio C HamanoMay 23, 2024
  38. 0/6 update-ref: add symref support for --stdinKarthik Nayak, May 30, 2024
  39. Patrick SteinhardtJun 5, 2024
  40. 1/6 refs: create and use `ref_update_expects_existing_old_ref()`Karthik Nayak, May 30, 2024
  41. 2/6 update-ref: add support for 'symref-verify' commandKarthik Nayak, May 30, 2024
  42. 3/6 update-ref: add support for 'symref-delete' commandKarthik Nayak, May 30, 2024
  43. Patrick SteinhardtJun 5, 2024
  44. Karthik NayakJun 5, 2024
  45. Junio C HamanoJun 5, 2024
  46. 4/6 update-ref: add support for 'symref-create' commandKarthik Nayak, May 30, 2024
  47. Patrick SteinhardtJun 5, 2024
  48. 5/6 reftable: pick either 'oid' or 'target' for new updatesKarthik Nayak, May 30, 2024
  49. 6/6 update-ref: add support for 'symref-update' commandKarthik Nayak, May 30, 2024
  50. Patrick SteinhardtJun 5, 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.