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

Re: git-cherry-pick(1) -- path

From
ACAlejandro Colomar <alx@kernel.org>
Date
May 12, 2024, 15:35 UTC
Message-ID
<xnzks3eybwx5lj7vnf66pfacjvcn4anhgfe7fx3ljvtysxpsrv@tt2wvkwezh3l>
In-Reply-To
<fz7tgtvp6qp7h3vcaviibn3rktkwg5q4qjeuvmciejqn2m7uow@3o5hi6hdbkt5>
Hi,
On Sat, May 11, 2024 at 10:08:47PM GMT, Alejandro Colomar wrote:
Show 13 quoted lines
> Hi Phillip,
> 
> On Sat, May 11, 2024 at 04:01:18PM GMT, Phillip Wood wrote:
> > sequencer.c. If we go for the "write new trees and use those in the merge"
> > approach then we'd need to change do_pick_commit() to create the trees and
> > we'd probably want to change do_recursive_merge() to take trees rather than
> > commits. We'd also need to add a new pathspec member to struct replay_opts
> > to pass the pathspec around.
> 
> I've been thinking this evening that since
> `git format-patch ... | git am -3` works so well, and since the behavior
> of cherry-pick -- path isn't so obvious (we're discussing different
> strategies), maybe we should just not do it.  I fell in love with am -3.
In the end, I'm using the following:
$ git log --oneline 2024a..tz/main -- tzfile.5 tzselect.8 zic.8 zdump.8 \
| awk '{print $1}' \
| tac \
| while read c; do
	git format-patch --stdout -1 $c -- tzfile.5 tzselect.8 z*.8 \
	| sed '/^---$/s/^/\n/' \
	| sed "/^---$/i Cherry-picked-from: tz.git $( \
			git log -1 --oneline --abbrev=12 $c \
			| awk '{print $1}' \
		) (\"$( \
			git log -1 --oneline $c \
			| sed 's/[^ ]* //' \
		)\")";
done \
| git am -3 -s;

And it works like a charm. If I had to spell that as a git-cherry-pick(1) command, I'd say `git cherry-pick -x -s 2024a..tz/main -- tzfile.5 tzselect.8 zic.8 zdump.8`

BTW, there's something I noticed when I had an accident (forgot to tac(1) the commit list): the git-am(1) conflicts session isn't as good as a cherry-pick one: it doesn't show which commits are being applied. If you're in the middle of a 50-commit cherry-pick, it's hard to see where it's going wrong. So maybe adding this functionallity to git-cherry-pick(1) could be a good thing.

Have a lovely day! Alex

-- 
<https://www.alejandro-colomar.es/>
Previous: Alejandro ColomarNext: Phillip Wood
Message 9 of 10 in “git-cherry-pick(1) -- path”
  1. Alejandro ColomarMay 9, 2024
  2. Junio C HamanoMay 10, 2024
  3. Alejandro ColomarMay 10, 2024
  4. Phillip WoodMay 10, 2024
  5. Junio C HamanoMay 10, 2024
  6. Alejandro ColomarMay 11, 2024
  7. Phillip WoodMay 11, 2024
  8. Alejandro ColomarMay 11, 2024
  9. Alejandro ColomarMay 12, 2024
  10. Phillip WoodMay 13, 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.