[Development] Looking for a way to batch-upload independent changes to Gerrit
Thiago Macieira
thiago.macieira at intel.com
Tue Aug 19 18:06:00 CEST 2014
On Tuesday 19 August 2014 09:38:03 Marc Mutz wrote:
> On Tuesday 19 August 2014 00:38:48 Thiago Macieira wrote:
> > git push gerrit `list all cherry-picked commits | sed
> > 's,$,:refs/for/5.4,'`
commits=
git rev-list @{upstream}.. | while read commit; do
git reset --hard
git checkout -f @{upstream}
git cherry-pick $commit || { commits=; break; }
commits="$commits $(git rev-parse HEAD):refs/for/5.4"
done
[ -n "$commits" ] && git push gerrit "$commits"
It's possible to do the same without touching your local tree by creating a
temp file, setting GIT_INDEX to it, like so (untested):
export GIT_INDEX=`mktemp`
trap "rm $GIT_INDEX" 0 1 2 15
commits=
git rev-list @{upstream}.. | while read commit; do
git read-tree @{upstream}
git apply --cached -C1 $commit || { commits=; break; }
commit=$(git cat-file $commit | sed '1,/^$/d' | \
git commit-tree `git write-tree` -p @{upstream})
commits="$commits $commit:refs/for/5.4"
done
[ -n "$commits" ] && git push gerrit "$commits"
The second script will not keep the commit and author dates, unfortunately.
That's a little more complex than I'm willing to write in an email. See git-
gpush and git-gerrit-pick.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list