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

Re: [PATCH v2 2/8] Apply object_id Coccinelle transformations.

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 21, 2016, 21:36 UTC
Message-ID
<xmqqtwgmns0r.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160618221407.1046188-3-sandals@crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> Apply the set of semantic patches from contrib/examples/coccinelle to
> convert some leftover places using struct object_id's hash member to
> instead use the wrapper functions that take struct object_id natively.
It is somewhat curious how these 'some leftover places' are chosen.
Especially, this hunk was interesting.
Show 21 quoted lines
> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index 1f380764..dac3a222 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -1725,14 +1725,14 @@ static int verify_lock(struct ref_lock *lock,
>  			errno = save_errno;
>  			return -1;
>  		} else {
> -			hashclr(lock->old_oid.hash);
> +			oidclr(&lock->old_oid);
>  			return 0;
>  		}
>  	}
>  	if (old_sha1 && hashcmp(lock->old_oid.hash, old_sha1)) {
>  		strbuf_addf(err, "ref %s is at %s but expected %s",
>  			    lock->ref_name,
> -			    sha1_to_hex(lock->old_oid.hash),
> +			    oid_to_hex(&lock->old_oid),
>  			    sha1_to_hex(old_sha1));
>  		errno = EBUSY;
>  		return -1;

The function gets old_sha1 which is the old-world "const unsigned char *" that is passed via lock_ref_sha1_basic() from public entry points like rename_ref() and ref_transaction_commit(). As this codepath and the functions involved have not be converted to oid, we end up seeing oid_to_hex() next to sha1_to_hex() ;-)

Not a complaint; this is how we make progress incrementally.

It was just I noticed this function is left in a somewhat funny intermediate state after this step.

Thanks.
Previous: brian m. carlsonNext: brian m. carlson
Message 5 of 20 in “object_id part 4”
  1. 0/8 object_id part 4brian m. carlson, Jun 18, 2016
  2. 6/8 merge-recursive: convert struct merge_file_info to object_idbrian m. carlson, Jun 18, 2016
  3. 4/8 Rename struct diff_filespec's sha1_valid member.brian m. carlson, Jun 18, 2016
  4. 2/8 Apply object_id Coccinelle transformations.brian m. carlson, Jun 18, 2016
  5. Junio C HamanoJun 21, 2016
  6. 8/8 merge-recursive: convert merge_recursive_generic to object_idbrian m. carlson, Jun 18, 2016
  7. 7/8 merge-recursive: convert leaf functions to use struct object_idbrian m. carlson, Jun 18, 2016
  8. 5/8 merge-recursive: convert struct stage_data to use object_idbrian m. carlson, Jun 18, 2016
  9. 3/8 Convert struct diff_filespec to struct object_idbrian m. carlson, Jun 18, 2016
  10. Junio C HamanoJun 21, 2016
  11. brian m. carlsonJun 24, 2016
  12. 1/8 Add basic Coccinelle transforms.brian m. carlson, Jun 18, 2016
  13. Johannes SixtJun 19, 2016
  14. Jeff KingJun 19, 2016
  15. brian m. carlsonJun 19, 2016
  16. Johannes SchindelinJun 20, 2016
  17. Jeff KingJun 20, 2016
  18. Junio C HamanoJun 20, 2016
  19. Junio C HamanoJun 21, 2016
  20. brian m. carlsonJun 22, 2016

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.