[nagiosplug] sfsnapshotgit: Better handling of remote refs

"Thomas Guyot-Sionnest" <[email protected]>
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
 Module: nagiosplug
 Branch: master
 Commit: 654086f1117ee22d9f7e8270330daff6c463c9ad
 Author: Thomas Guyot-Sionnest <[email protected]>
   Date: Mon Oct 11 21:38:42 2010 -0400
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=654086f

sfsnapshotgit: Better handling of remote refs

This commit allow to track branches from unusually-named remote refs and
makes possible using external remotes (other than origin) for snapshots.

---

 tools/sfsnapshotgit |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/sfsnapshotgit b/tools/sfsnapshotgit
index e79dd55..8bc19fc 100755
--- a/tools/sfsnapshotgit
+++ b/tools/sfsnapshotgit
@@ -44,11 +44,17 @@ cd "$SFSNAP_REPO"
 # Sometimes "make dist" can modify versioned files so we must reset first
 git reset --hard
 git clean -qfdx
-# Any branch used to create snapshots must already exist
+
+# Any branch used to create snapshots must already exist and be properly configured
 git checkout "$HEAD"
-git fetch "$SFSNAP_ORIGIN"
-git reset --hard "$SFSNAP_ORIGIN"/"$HEAD"
-# Tags are important for git-describe
+
+# Get the remote tracking branch from config
+origin=$(git config branch.$HEAD.remote)
+ref=$(git config branch.$HEAD.merge |sed -e 's|^refs/heads/||')
+git fetch "$origin"
+git reset --hard "$origin/$ref"
+
+# Tags are important for git-describe, but take only the ones from the hard-coded origin
 git fetch --tags "$SFSNAP_ORIGIN"
 
 # Write our snapshot version string (similar to NP-VERSION-GEN) to "release"


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.