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

git am oddity

From
Sverre Rabbelier <srabbelier@gmail.com>
Date
Mar 31, 2014, 21:58 UTC
Message-ID
<CAGdFq_gZoiE_ah0VT5ZfQwg-zHNj6Q-RSB80f=BTf=U6+9L5UA@mail.gmail.com>
Hi,

I noticed something very odd with git am, and have been able to narrow it down to a minimal example.

 git init tmp
 cd tmp
 mkdir -p foo/bar/baz
 cd foo/bar/baz
 echo file > file
 git add file
 git commit -m "1"
 echo other > other
 echo more >> file
 git add file other
 git commit -m "my test"
 git format-patch HEAD~..
 git reset --hard HEAD~
 # apply the patch in the current directory, chop off the leading directories
 git am -3 -p 3 0001-my-test.patch
 cd ../../..
 git ls-files

Expected output: foo/bar/baz/file foo/bar/baz/other

Actual output: baz/other # the file addition was applied to the root of the repository, instead of the current directory foo/bar/baz/file # the file modification was correctly applied, yay

Is this expected behavior?
-- 
Cheers,

Sverre Rabbelier
Next: Junio C Hamano
Message 1 of 3 in “git am oddity”
  1. Sverre RabbelierMar 31, 2014
  2. Junio C HamanoMar 31, 2014
  3. Sverre RabbelierMar 31, 2014

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.