Subject: [PATCH] git-svn: improve git-svn find-rev output when given git commit is not an svn revision

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For one of my projects I've been using 'svnversion' to automatically
generate a 'build number' to include in the version string of the
project.

'svnversion' will output the revision of the current checkout,
possibly with an 'M' appended if you've made local modifications.

This obviously wont work if you have a git-svn repository instead of
an svn checkout.

This patch adds this behaviour to git-svn find-rev, so 'git-svn
find-rev HEAD' should be usable instead of 'svnversion'.

Previously 'git-svn find-rev HEAD' would return nothing if HEAD was
not a commit from the remote svn repository.

Anyone besides me finding this more useful?

Simon Sasburg

---
  git-svn.perl |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 4e325b7..b15fa51 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -456,6 +456,12 @@ sub cmd_find_rev {
 		$result = $gs->rev_db_get($desired_revision);
 	} else {
  		my (undef, $rev, undef) = cmt_metadata($revision_or_hash);
+		if (!$rev) {
+			my @refs;
+			(undef, $rev, undef, undef) = working_head_info($revision_or_hash, \@refs);
+			# return 'xxxM' like 'svnversion' does
+			$rev .= 'M' if $rev;
+		}
 		$result = $rev;
 	}
 	print "$result\n" if $result;
-- 
1.5.3.GIT
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux