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

Is git-am expected to honor core.sharedRepository?

From
Matheus Tavares Bernardino <matheus.bernardino@usp.br>
Date
Dec 1, 2020, 15:23 UTC
Message-ID
<CAHd-oW4yHSTYr0Gwn60tu2c7VY=PJbSbg23Z5Bd_11Do-+juGA@mail.gmail.com>
Hi, everyone

I'm not very familiar with this setting, but to my understanding it should only affect files in $GIT_DIR not $GIT_WORK_TREE, is that correct? Nevertheless, apply and am (which uses apply) end up adjusting the permissions of created directories based on the setting. To give an example:

We first commit the directory 'd': $ mkdir d $ touch d/f $ git add d $ git commit -m d $ ls -l drwxr-xr-x 2 matheus matheus 60 dez 1 11:29 d

Then we create a patch and use am to apply it: $ git format-patch -1 $ git reset --hard HEAD~ $ git config core.sharedRepository 0700 $ git am *.patch

The setting was honored by am: $ ls -l drwx--S--- 2 matheus matheus 60 dez 1 11:30 d

And if we delete 'd' and check it out again, the setting is ignored: $ rm -rf d $ git checkout d $ ls -l drwxr-xr-x 2 matheus matheus 60 dez 1 11:31 d

Is this expected?

If not, the place to be changed is probably the safe_create_leading_directories() call in apply.c. This function internally calls adjust_shared_perm() to modify the permissions according to core.sharedRepository, so we could probably pass a flag to skip this step. But this function has at least 15 callers, so should we introduce a wrapper for the non-shared case, instead?

(For some background, I stumbled across this while considering using safe_create_leading_directories() for a parallel-checkout patch. But then I noticed it adjusts the directories' permissions based on the setting and I was worried whether it could be user for checkout.)

Thanks, Matheus

Next: Junio C Hamano
Message 1 of 17 in “Is git-am expected to honor core.sharedRepository?”
  1. Matheus Tavares BernardinoDec 1, 2020
  2. Junio C HamanoDec 1, 2020
  3. apply: don't use core.sharedRepository to create working tree filesMatheus Tavares, Dec 1, 2020
  4. Junio C HamanoDec 2, 2020
  5. Adam DinwoodieDec 19, 2020
  6. Junio C HamanoDec 19, 2020
  7. Adam DinwoodieDec 19, 2020
  8. Achim GratzDec 19, 2020
  9. Adam DinwoodieDec 19, 2020
  10. Achim GratzDec 19, 2020
  11. Adam DinwoodieDec 22, 2020
  12. Matheus Tavares BernardinoDec 22, 2020
  13. t4129: fix setfacl-related permissions failureAdam Dinwoodie, Dec 23, 2020
  14. Matheus Tavares BernardinoJan 9, 2021
  15. Junio C HamanoJan 9, 2021
  16. Junio C HamanoDec 2, 2020
  17. Matheus Tavares BernardinoDec 3, 2020

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.