[OpenWrt-Devel] SVN to GIT transition

Bruno Randolf br1 at thinktube.com
Sat Oct 10 18:44:34 EDT 2015


On 10/10/2015 07:55 PM, Florian Fainelli wrote:
> There is a big problem with git, which is identifying what OpenWrt
> release your image is based off. With subversion, it is fairly easy,
> you have a revision number that keeps incrementing. With git, asking
> people to give you their git-describe output might be a little harder.
> On the plus side, we would know if someone had tampered with the
> sources (-dirty), but we would not be able to track down changes
> easily if someone just created branches and added patches there, since
> these would be objects and references that are not accessible.

Using git describe and tagging works very well for that. When you have a
tag, say "15.05" then your version number (Revision) will be just that
("15.05"), if you are 16 commits after the last tag, the version would
be e.g. "15.05-16-gb2abd7e". As far as I can see that gives you the same
benefits as incremental SVN revisions (the -16 part) + the benefit of
the unique hash (gb2abd7e) + the benfit of having the dirty mark.

For reference, to do that, I carry the following simple changes in my
various OpenWRT trees:

diff --git a/include/version.mk b/include/version.mk
index 9348a24..8bc5319 100644
--- a/include/version.mk
+++ b/include/version.mk
@@ -21,7 +21,7 @@ qstrip_escape=$(subst ','\'',$(call qstrip,$(1)))
 #'

 VERSION_NUMBER:=$(call qstrip_escape,$(CONFIG_VERSION_NUMBER))
-VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),15.05)
+VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),$(REVISION))

diff --git a/scripts/getver.sh b/scripts/getver.sh
index 4643ca6..fa542f1 100755
--- a/scripts/getver.sh
+++ b/scripts/getver.sh
@@ -17,9 +17,7 @@ try_svn() {
 }

 try_git() {
-       [ -e .git ] || return 1
-       REV="$(git log | grep -m 1 git-svn-id | awk '{ gsub(/.*@/, "",
$0); print $1 }')"
-       REV="${REV:+r$REV}"
+       REV="$(git describe --tags --dirty)"
        [ -n "$REV" ]
 }

Another benefit of git in my point of view is better merging. I
regularly have a problem when I have to merge a new OpenWRT release into
my "branch" (with vendor/project specific changes). I have mentioned
that about a few weeks ago on openwrt-devel
(https://www.mail-archive.com/openwrt-devel@lists.openwrt.org/msg33992.html)
but here I often have to use something like "git merge -s recursive -X
theirs upstream-15.05/master" or worse + manual diffing + fixup of merge
errors. I assume when all would be in the same git repo, that should be
easier...

bruno
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list