Playing with Git

Brent Putman putmanb at georgetown.edu
Thu Apr 6 21:43:29 EDT 2017


So IIUC what you ideally want is to 1) use git to version your local IdP
config 2) be able to easily diff your local config against tags, etc
from the IdP repo?

That really got me thinking that one ought to be able to set up a remote
in the local config repo that points at the IdP, pull in selected
commits and tags and relevant reachable objects from it, and then be
able to diff and so on against it directly.

What I came up with is below.  Essentially you use a custom refspec to
only pull down the remote's tags, mapping them to namespace-qualified
tags in the local repo.

cd <your IdP> (the local IdP dir to be versioned)
git init
(git add and commit whatever you want to version locally)

Here's the special sauce:

# Use a repo HTTP URL, etc if not a committer
git remote add shibidp git at git.shibboleth.net:java-identity-provider
git config remote.shibidp.fetch +refs/tags/*:refs/tags/shibidp/*
git config remote.shibidp.tagOpt --no-tags
git fetch shibidp

Now you have a bunch of local tags imported from the shibidp remote with
a shibidp/ prefix:

# git tag --list

shibidp/3.0.0
shibidp/3.0.0-alpha1
shibidp/3.0.0-alpha2
shibidp/3.0.0-alpha3
shibidp/3.0.0-beta1
shibidp/3.0.0.11
shibidp/3.1.0
shibidp/3.1.0.1
shibidp/3.1.1
shibidp/3.1.1.1
shibidp/3.1.1.2
shibidp/3.1.2
shibidp/3.1.2.1
shibidp/3.2.0
shibidp/3.2.0.2
shibidp/3.2.1
shibidp/3.2.1.0
shibidp/3.2.1.1
shibidp/3.3.0
shibidp/3.3.0.0
shibidp/3.3.0.1
shibidp/3.3.1
shibidp/3.3.1.0
shibidp/3.3.1.1

So I think you can still create your own (unqualified) local tags
without stepping on one another.  You also haven't polluted your repo's
branches with any remote tracking branches (although you could if you
wanted, by adding additional refspecs).

Now one can use any of the git diffing and other tools as normal, taking
advantage of the fact that a commit-ish or tree-ish can (usually) take
an optional path (often colon-delimited), so you are diffing apples to
apples:

git diff master:conf   shibidp/3.3.0:idp-conf/src/main/resources/conf

git diff --ignore-all-space --ignore-blank-lines master:conf/logback.xml
shibidp/3.3.0:idp-conf/src/main/resources/conf/logback.xml

git diff-tree -r HEAD:conf  shibidp/3.3.0:idp-conf/src/main/resources/conf

And so on.

I was slightly amazed that this actually (seems to) work.  Probably
there's some stuff that needs to be fine-tuned or tweaked, but maybe is
the skeleton of a general approach.

Fwiw, I had this idea based on the well-known (?) historical way that
one can do something similar, even in Subversion and (gasp!) CVS, to
maintain local changes to third-party source, using so-called vendor
branches (import of a versioned tarball, etc) and 3-way merges.  Maybe
there is also some canonical Git workflow for that as well.

--Brent

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20170406/86d5d97c/attachment.html>


More information about the dev mailing list