Skip to Content.
Sympa Menu

sm-discuss - Re: [SM-Discuss] git: cherry-pick whole directories

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: Jeremy Blosser <jblosser-smgl AT firinn.org>
  • To: sm-discuss AT lists.ibiblio.org
  • Subject: Re: [SM-Discuss] git: cherry-pick whole directories
  • Date: Mon, 22 Jan 2007 00:28:45 -0600

On Jan 21, Jeremy Blosser [jblosser-smgl AT firinn.org] wrote:
> On Jan 21, Jeremy Blosser [jblosser-smgl AT firinn.org] wrote:
> > On Jan 22, Jaka Kranjc [lynx AT mages.ath.cx] wrote:
> > > Today I needed this p4 integration functionality too (and someone was
> > > bickering again), so after many git resets, here it is, a wrapper
> > > script that does just that in git. It takes a path argument and
> > > optionally an "upstream" branch. It is not interactive, but there is a
> > > slightly more powerful interactive version cat at the end, double
> > > commented.
> > >
> > > I'll add it to the wiki tommorow. Comments?
> >
> > There actually are potentially ways to have git do the diffing for you but
> > your approach is probably better since it's readable by bash gurus
> > (instead
> > of just git gurus) and it's very clear what it is doing.
>
> Actually I'm not sure about this... observe:
>
> $ git log --pretty=one-line -- smgl/init.d
> ef2ef4c4f71bae44e01f87480bf7ed492d86f51b init.d: Try to fix bug 9177 some
> more;
> f55dbdb052a0cb237eb2f0c5df04ec2e28451332 Revert "init.d: fix #7311, proc
> not sho
>
> $ git log --pretty=one-line master -- smgl/init.d
> d799c9f7d0863829c5fb7c701be785216314090c init.d: Try to fix bug 9177 some
> more;
> ecc1547d4dcc9fb9052d4ddd07e6999cf0989bd5 Revert "init.d: fix #7311, proc
> not sho
>
> Comparing the sha1s may not suffice.

Looking into this more, the problem appears to be that once you cherry-pick
out of order, the hashes diverge as the state of the files diverges.
Which makes sense.

master:
6352d3b4b03bf3210204704dbcc239d1fcff56fb fix #9772 for good
...
1b1ec0fd66472cd4e6caa69238c4a7fe0407bdb7 use TRACK_ROOT when linking #9163
95f13eb1ac5a9dc00b73497abf8ed6c792b0d0c7 init.d: fix #7311, proc not showing
in
1a6f74b75cc8755eaafb369ab5d17629aa9cf52f init.d: Check which udev version
should
a00f744269041025eb0f84f6bb4c51320680b6ec init.d: [automated] Removed
BUILD_API=2

vs stable-rc-0.6:
a4042802297fa08f207314947eb2637ac4d8ff58 fix #9772 for good
95f13eb1ac5a9dc00b73497abf8ed6c792b0d0c7 init.d: fix #7311, proc not showing
in
1a6f74b75cc8755eaafb369ab5d17629aa9cf52f init.d: Check which udev version
should
a00f744269041025eb0f84f6bb4c51320680b6ec init.d: [automated] Removed
BUILD_API=2

So the hashes are the same until we skip cherry-picking a few commits, then
it's all over.

> git-log's man page suggests:
> git log -r --name-status release..test
> Show the commits that are in the "test" branch but not yet in
> the "release" branch, along with the list of paths each commit
> modifies.
>
> But I'm not sure how hard it tries.

This actually does the exact same thing as above, it just compares the
hashes internally. And like the above it will show as 'not yet committed'
any commits that actually were committed, but resulted in a different hash.

> Another thing about this approach is it only works if we assume each commit
> only affected the directory in question...

What about this:

path=$1
master=${2:-master}
[[ -e $path ]] || { echo bad path; exit 1; }

git log --pretty=one-line HEAD..$master $path
echo "Cut and paste desired commits below, then ctrl-D"
while read commit junk; do
git-cherry-pick $commit || {
echo
echo fix the conflict, then restart me
exit 123; }
done

Attachment: pgpPgZ0Ag7Okk.pgp
Description: PGP signature




Archive powered by MHonArc 2.6.24.

Top of Page