Disabling "git svn dcommit"

51 views
Skip to first unread message

Mark Seaborn

unread,
Jan 11, 2012, 7:37:49 PM1/11/12
to Chromium-dev, ncb...@chromium.org
Does anyone know of a way to disable "git svn dcommit" in a Git repo?  It's a bit too easy to type this by mistake instead of "git cl dcommit", and end up committing many intermediate changesets without review URLs etc.

I haven't done it yet, but others have, and I worry that I will too. :-)

Cheers,
Mark

Evan Martin

unread,
Jan 11, 2012, 7:40:18 PM1/11/12
to msea...@chromium.org, Chromium-dev, ncb...@chromium.org

You could put a 'git-svn' binary in your path ahead of the real
git-svn that examines the current world and errors out if necessary,
or otherwise calls the real one. But note that git cl dcommit shells
out to git svn as well, so you'd need to hack around that.

Nick Bray

unread,
Feb 16, 2012, 1:11:23 PM2/16/12
to Evan Martin, msea...@chromium.org, Chromium-dev, ncb...@chromium.org
A bit of investigation showed that disabling "git svn dcommit" would be difficult because git-svn is part of the git distribution, and I wasn't seeing a light weight way to intercept calls to it.  I decided to attack the problem from a different direction and increase the hamming distance between the command I always used and the command I never used.

git config --global alias.commitit "cl dcommit"

It takes a little retraining, but now I never screw up "git commitit".  I just wish I could think of a better name...

Mikhail Naganov

unread,
Feb 16, 2012, 5:36:50 PM2/16/12
to msea...@chromium.org, Evan Martin, Chromium-dev, ncb...@chromium.org
Maybe, instead of disabling "git svn dcommit", train yourself to
always use "git cl dcommit", and teach git-cl to fallback to git svn
dcommit, if the repository isn't served by gclient / git-cl?

> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev

Evan Martin

unread,
Feb 16, 2012, 5:42:14 PM2/16/12
to Nick Bray, msea...@chromium.org, Chromium-dev, ncb...@chromium.org
On Thu, Feb 16, 2012 at 10:11 AM, Nick Bray <ncb...@google.com> wrote:
> A bit of investigation showed that disabling "git svn dcommit" would be
> difficult because git-svn is part of the git distribution, and I wasn't
> seeing a light weight way to intercept calls to it.  I decided to attack the
> problem from a different direction and increase the hamming distance between
> the command I always used and the command I never used.

Idea1: if git-svn had a precommit hook, you could make the hook check
for an environment variable, and then have git-cl set that environment
variable when shelling out to git-svn. Unfortunately git-svn appears
to not support any hooks, maybe you could add them.

Idea2: maybe you could put something in your PATH that *shadows* the
real git-svn, then do the same environment hack to let git-cl through.

Sreeram Ramachandran

unread,
Feb 16, 2012, 5:43:03 PM2/16/12
to ncb...@google.com, Evan Martin, msea...@chromium.org, Chromium-dev, ncb...@chromium.org
On Thu, Feb 16, 2012 at 10:11, Nick Bray <ncb...@google.com> wrote:
> A bit of investigation showed that disabling "git svn dcommit" would be
> difficult because git-svn is part of the git distribution, and I wasn't
> seeing a light weight way to intercept calls to it.

Shell alias? Something like (pseudocode):
function git() {
if $1 == "svn" and $2 == "dcommit"; then
\git cl dcommit "rest of args (perhaps $@ after shifting out the
first two)"
else
\git "$@"
fi
}

Fred Akalin

unread,
Feb 16, 2012, 5:50:50 PM2/16/12
to sre...@chromium.org, ncb...@google.com, Evan Martin, msea...@chromium.org, Chromium-dev, ncb...@chromium.org
It should error out, not 'helpfully' forward to 'cl dcommit'.  You don't want to train people to use 'svn dcommit'.

 }

Reply all
Reply to author
Forward
0 new messages