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

Re: [PATCH v1 3/4] environment: move 'trust_executable_bit' into repo_config_values

From
Junio C Hamano <gitster@pobox.com>
Date
May 30, 2026, 23:17 UTC
Message-ID
<xmqq7bokebct.fsf@gitster.g>
In-Reply-To
<20260530160520.77859-4-cat@malon.dev>
Tian Yuchen <cat@malon.dev> writes:
Show 36 quoted lines
> diff --git a/apply.c b/apply.c
> index 249248d4f2..73ca9907f8 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -3890,10 +3890,12 @@ static int check_preimage(struct apply_state *state,
>  	}
>  
>  	if (!state->cached && !previous) {
> +		struct repo_config_values *cfg = repo_config_values(the_repository);
> +
>  		if (*ce && !(*ce)->ce_mode)
>  			BUG("ce_mode == 0 for path '%s'", old_name);
>  
> -		if (trust_executable_bit || !S_ISREG(st->st_mode))
> +		if (cfg->trust_executable_bit || !S_ISREG(st->st_mode))
>  			st_mode = ce_mode_from_stat(*ce, st->st_mode);
>  		else if (*ce)
>  			st_mode = (*ce)->ce_mode;
> diff --git a/read-cache.c b/read-cache.c
> index 54150fe756..18af533649 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -204,10 +204,12 @@ void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, st
>  
>  unsigned int ce_mode_from_stat(const struct cache_entry *ce, unsigned int mode)
>  {
> +	struct repo_config_values *cfg = repo_config_values(the_repository);
> +
>  	if (!has_symlinks && S_ISREG(mode) &&
>  	    ce && S_ISLNK(ce->ce_mode))
>  		return ce->ce_mode;
> -	if (!trust_executable_bit && S_ISREG(mode)) {
> +	if (!cfg->trust_executable_bit && S_ISREG(mode)) {
>  		if (ce && S_ISREG(ce->ce_mode))
>  			return ce->ce_mode;
>  		return create_ce_mode(0666);

How hot are the code paths that call into this helper function? In the original under some condition, it was possible to return without even consulting the trust_executable_bit variable, but in the updated code, the helper unconditionally makes a call to the repo_config_values() helper function even before it knows it needs to know the value of trust_executable_bit.

Show 15 quoted lines
> @@ -217,11 +219,13 @@ unsigned int ce_mode_from_stat(const struct cache_entry *ce, unsigned int mode)
>  
>  static unsigned int st_mode_from_ce(const struct cache_entry *ce)
>  {
> +	struct repo_config_values *cfg = repo_config_values(the_repository);
> +
>  	switch (ce->ce_mode & S_IFMT) {
>  	case S_IFLNK:
>  		return has_symlinks ? S_IFLNK : (S_IFREG | 0644);
>  	case S_IFREG:
> -		return (ce->ce_mode & (trust_executable_bit ? 0755 : 0644)) | S_IFREG;
> +		return (ce->ce_mode & (cfg->trust_executable_bit ? 0755 : 0644)) | S_IFREG;
>  	case S_IFGITLINK:
>  		return S_IFDIR | 0755;
>  	case S_IFDIR:
Ditto.
Show 17 quoted lines
> @@ -321,6 +325,7 @@ static int ce_modified_check_fs(struct index_state *istate,
>  static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
>  {
>  	unsigned int changed = 0;
> +	struct repo_config_values *cfg = repo_config_values(the_repository);
>  
>  	if (ce->ce_flags & CE_REMOVE)
>  		return MODE_CHANGED | DATA_CHANGED | TYPE_CHANGED;
> @@ -331,7 +336,7 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
>  		/* We consider only the owner x bit to be relevant for
>  		 * "mode changes"
>  		 */
> -		if (trust_executable_bit &&
> +		if (cfg->trust_executable_bit &&
>  		    (0100 & (ce->ce_mode ^ st->st_mode)))
>  			changed |= MODE_CHANGED;
>  		break;
Ditto.
Show 6 quoted lines
> @@ -732,6 +737,8 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
>  			  (intent_only ? ADD_CACHE_NEW_ONLY : 0));
>  	unsigned hash_flags = pretend ? 0 : INDEX_WRITE_OBJECT;
>  
> +	struct repo_config_values *cfg = repo_config_values(the_repository);
> +
Lose the excess blank line before the new declaration.
Show 12 quoted lines
>  	if (flags & ADD_CACHE_RENORMALIZE)
>  		hash_flags |= INDEX_RENORMALIZE;
>  
> @@ -752,7 +759,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
>  		ce->ce_flags |= CE_INTENT_TO_ADD;
>  
>  
> -	if (trust_executable_bit && has_symlinks) {
> +	if (cfg->trust_executable_bit && has_symlinks) {
>  		ce->ce_mode = create_ce_mode(st_mode);
>  	} else {
>  		/* If there is an existing entry, pick the mode bits and type

Almost all of these places that care about trust_executable_bit also cares about has_symlinks. I wonder if they should be converted to repo-local settings in the same series.

Previous: Christian CouderNext: Tian Yuchen
Message 7 of 62 in “environment.c: migrate 'trust_executable_bit' into 'repo_config_values'”
  1. 0/4 environment.c: migrate 'trust_executable_bit' into 'repo_config_values'Tian Yuchen, May 30, 2026
  2. 2/4 read-cache: move 'ce_mode_from_stat()' to 'read-cache.c'Tian Yuchen, May 30, 2026
  3. Patrick SteinhardtJun 4, 2026
  4. Tian YuchenJun 10, 2026
  5. 3/4 environment: move 'trust_executable_bit' into repo_config_valuesTian Yuchen, May 30, 2026
  6. Christian CouderMay 30, 2026
  7. Junio C HamanoMay 30, 2026
  8. Tian YuchenJun 1, 2026
  9. Tian YuchenJun 1, 2026
  10. Junio C HamanoJun 9, 2026
  11. 4/4 read-cache: pass 'istate' to stat/mode helper functionsTian Yuchen, May 30, 2026
  12. Christian CouderMay 30, 2026
  13. 1/4 read-cache: remove redundant extern declarationsTian Yuchen, May 30, 2026
  14. 0/3 environment: migrate 'trust_executable_bit' into 'repo_config_values'Tian Yuchen, Jun 10, 2026
  15. 1/3 read-cache: remove redundant extern declarationsTian Yuchen, Jun 10, 2026
  16. 2/3 read-cache: move 'ce_mode_from_stat()' to 'read-cache.c'Tian Yuchen, Jun 10, 2026
  17. Christian CouderJun 12, 2026
  18. 3/3 environment: move trust_executable_bit into repo_config_valuesTian Yuchen, Jun 10, 2026
  19. Tian YuchenJun 11, 2026
  20. Christian CouderJun 12, 2026
  21. Junio C HamanoJun 12, 2026
  22. 0/3 environment: migrate 'trust_executable_bit' into 'repo_config_values'Tian Yuchen, Jun 12, 2026
  23. 2/3 read-cache: move 'ce_mode_from_stat()' to 'read-cache.c'Tian Yuchen, Jun 12, 2026
  24. 1/3 read-cache: remove redundant extern declarationsTian Yuchen, Jun 12, 2026
  25. 3/3 environment: move trust_executable_bit into repo_config_valuesTian Yuchen, Jun 12, 2026
  26. 0/3 environment: migrate 'trust_executable_bit' into 'repo_config_values'Tian Yuchen, Jun 19, 2026
  27. 1/3 read-cache: remove redundant extern declarationsTian Yuchen, Jun 19, 2026
  28. 2/3 read-cache: move 'ce_mode_from_stat()' to 'read-cache.c'Tian Yuchen, Jun 19, 2026
  29. 3/3 environment: move trust_executable_bit into repo_config_valuesTian Yuchen, Jun 19, 2026
  30. Junio C HamanoJun 29, 2026
  31. Tian YuchenJul 15, 2026
  32. 0/4 environment: migrate 'trust_executable_bit' and 'has_symlinks' into 'repo_config_values'Tian Yuchen, Jul 15, 2026
  33. 1/4 read-cache: remove redundant extern declarationsTian Yuchen, Jul 15, 2026
  34. 2/4 read-cache: move 'ce_mode_from_stat()' to 'read-cache.c'Tian Yuchen, Jul 15, 2026
  35. 3/4 environment: move trust_executable_bit into repo_config_valuesTian Yuchen, Jul 15, 2026
  36. 4/4 environment: move has_symlinks into repo_config_valuesTian Yuchen, Jul 15, 2026
  37. Christian CouderJul 15, 2026
  38. Junio C HamanoJul 15, 2026
  39. Junio C HamanoJul 15, 2026
  40. 0/4 environment: migrate 'trust_executable_bit' and 'has_symlinks' into 'repo_config_values'Tian Yuchen, Jul 16, 2026
  41. 1/4 read-cache: remove redundant extern declarationsTian Yuchen, Jul 16, 2026
  42. 2/4 read-cache: move 'ce_mode_from_stat()' to 'read-cache.c'Tian Yuchen, Jul 16, 2026
  43. Junio C HamanoJul 16, 2026
  44. 3/4 environment: move trust_executable_bit into repo_config_valuesTian Yuchen, Jul 16, 2026
  45. 4/4 environment: move has_symlinks into repo_config_valuesTian Yuchen, Jul 16, 2026
  46. Junio C HamanoJul 16, 2026
  47. 0/4 environment: migrate 'trust_executable_bit' and 'has_symlinks' into 'repo_config_values'Tian Yuchen, Jul 17, 2026
  48. 2/4 read-cache: pass 'repo' to 'ce_mode_from_stat()'Tian Yuchen, Jul 17, 2026
  49. SZEDER GáborJul 18, 2026
  50. Tian YuchenJul 20, 2026
  51. SZEDER GáborJul 20, 2026
  52. Tian YuchenJul 20, 2026
  53. 1/4 read-cache: remove redundant extern declarationsTian Yuchen, Jul 17, 2026
  54. 3/4 environment: move trust_executable_bit into repo_config_valuesTian Yuchen, Jul 17, 2026
  55. Junio C HamanoJul 17, 2026
  56. Tian YuchenJul 20, 2026
  57. 4/4 environment: move has_symlinks into repo_config_valuesTian Yuchen, Jul 17, 2026
  58. 0/4 environment: migrate 'trust_executable_bit' and 'has_symlinks' into 'repo_config_values'Tian Yuchen, Jul 20, 2026
  59. 1/4 read-cache: remove redundant extern declarationsTian Yuchen, Jul 20, 2026
  60. 2/4 read-cache: pass 'repo' to 'ce_mode_from_stat()'Tian Yuchen, Jul 20, 2026
  61. 3/4 environment: move trust_executable_bit into repo_config_valuesTian Yuchen, Jul 20, 2026
  62. 4/4 environment: move has_symlinks into repo_config_valuesTian Yuchen, Jul 20, 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.