[OpenStack-Infra] git review -d without check out

Tony Breeds tony at bakeyournoodle.com
Wed Mar 28 03:21:15 UTC 2018


On Tue, Mar 27, 2018 at 02:16:32PM +0300, Ram Rachum wrote:
> Hi,
> 
> Is there a way to do `git review -d` without having it do a checkout? i.e.
> I just want to have these commits in my Git database so I could cherrypick
> them on some other branch. We've got tons of submodules so checking out
> often creates problems.
> 
> I tried `git fetch gerrit my_commit_hash:temporary_branch_name` but that's
> insanely slow for some reason.

Thanks more or less what I do.

This is my ~bin/git-os-change
---
#!/usr/bin/env bash

review=$1
revision=${2:-1}

if [ -z "$review" ] ; then
    echo Need an OpenStack gerrit review number >&2
    exit 1
fi

ref=$(printf "refs/changes/%d/%d/%d" "${review: -2}" "${review}" "${revision}")
git fetch gerrit "${ref}:${ref}"
---

It's about the same speed as git review.

---
[tony at thor ~]$ cd tmp
/home/tony/tmp
[tony at thor tmp]$ cp -a ~/projects/openstack/openstack-dev/devstack devstack-1
[tony at thor tmp]$ cp -a ~/projects/openstack/openstack-dev/devstack devstack-2
[tony at thor tmp]$ cd devstack-1
/home/tony/tmp/devstack-1
[tony at thor devstack-1]$ time git review -d 554977
Downloading refs/changes/77/554977/3 from gerrit
Switched to branch "review/eric_berglund/etcd_version"

real	0m3.892s
user	0m0.508s
sys	    0m0.225s
[tony at thor devstack-1]$ cd ../devstack-2
[tony at thor devstack-2]$ time git os-change 554977 3
remote: Counting objects: 7, done
remote: Finding sources: 100% (4/4)
remote: Total 4 (delta 3), reused 3 (delta 3)
Unpacking objects: 100% (4/4), done.
From ssh://review.openstack.org:29418/openstack-dev/devstack
 * [new ref]           refs/changes/77/554977/3 -> refs/changes/77/554977/3

real	0m2.813s
user	0m0.182s
sys	    0m0.152s
---

Yours Tony.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.openstack.org/pipermail/openstack-infra/attachments/20180328/de424f08/attachment-0001.sig>


More information about the OpenStack-Infra mailing list