After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 611645 - gnc-svnversion returns "too long" a string for git users
gnc-svnversion returns "too long" a string for git users
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Build system
git-master
Other Windows
: Normal minor
: ---
Assigned To: Derek Atkins
Derek Atkins
Depends on:
Blocks:
 
 
Reported: 2010-03-02 22:52 UTC by Jeff Kletsky
Modified: 2018-06-29 22:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to change git "version strong" to something less unwieldy (1.23 KB, patch)
2010-03-02 23:21 UTC, Jeff Kletsky
none Details | Review
Same as before, but in "plain text" (628 bytes, patch)
2010-03-02 23:44 UTC, Jeff Kletsky
none Details | Review
Use git ls-files and use --git-dir for out-of-tree use (746 bytes, patch)
2010-03-03 00:27 UTC, Jeff Kletsky
none Details | Review
Checks for untracked files as well (930 bytes, patch)
2010-03-04 17:07 UTC, Jeff Kletsky
committed Details | Review

Description Jeff Kletsky 2010-03-02 22:52:04 UTC
The version string returned bu gnc-svnversion is used in the splash screen and the about acreen to indicate the vc version used for the build. For git users, the current behavior is to return the full hash of the commit, such as 1a2528c8ca1d43e8e9e21b0661f844d2b496f47d

The below patch shortens this to the abbreviated hash, such as
1a2528c
as well as adding a plus sign (+) to the end if there were uncommited changes in the repository at the time it was generated.

The SVN-specific formatting (...SVN (r%s ...) still remains at this time.

$ git diff origin/master
diff --git a/util/gnc-svnversion b/util/gnc-svnversion
index d70c22f..17085ac 100755
--- a/util/gnc-svnversion
+++ b/util/gnc-svnversion
@@ -45,9 +45,11 @@ fi
 # Maybe it's git?
 if test -d "${real_srcdir}"/.git
 then
-  githead=`git --git-dir "${real_srcdir}"/.git rev-parse HEAD 2>/dev/null`
+  githead=`git --git-dir "${real_srcdir}"/.git log -1 --pretty=%h HEAD 2>/dev/null`  # short hash only
   if test $? = 0 ; then
-    echo $githead
+    echo -n $githead
+    git diff HEAD 2>&1 > /dev/null && echo -n "+"  # Add a "+" to the hash if there are unstaged changes
+    echo
     exit 0
   else
     exit 1
Comment 1 Jeff Kletsky 2010-03-02 23:21:57 UTC
Created attachment 155081 [details] [review]
Patch to change git "version strong" to something less unwieldy
Comment 2 Jeff Kletsky 2010-03-02 23:41:57 UTC
Comment on attachment 155081 [details] [review]
Patch to change git "version strong" to something less unwieldy

Unicode
Comment 3 Jeff Kletsky 2010-03-02 23:43:07 UTC
Comment on attachment 155081 [details] [review]
Patch to change git "version strong" to something less unwieldy

diff --git a/util/gnc-svnversion b/util/gnc-svnversion
index d70c22f..17085ac 100755
--- a/util/gnc-svnversion
+++ b/util/gnc-svnversion
@@ -45,9 +45,11 @@ fi
 # Maybe it's git?
 if test -d "${real_srcdir}"/.git
 then
-  githead=`git --git-dir "${real_srcdir}"/.git rev-parse HEAD 2>/dev/null`
+  githead=`git --git-dir "${real_srcdir}"/.git log -1 --pretty=%h HEAD 2>/dev/null`  # short hash only
   if test $? = 0 ; then
-    echo $githead
+    echo -n $githead
+    git diff HEAD 2>&1 > /dev/null && echo -n "+"  # Add a "+" to the hash if there are unstaged changes
+    echo
     exit 0
   else
     exit 1
Comment 4 Jeff Kletsky 2010-03-02 23:44:31 UTC
Created attachment 155084 [details] [review]
Same as before, but in "plain text" 

Saved as "text" under WindowsXP, instead of Unicode
Comment 5 Jeff Kletsky 2010-03-03 00:27:00 UTC
Created attachment 155093 [details] [review]
Use git ls-files and use --git-dir for out-of-tree use

Properly detects changes and deletions
in a non-language-specific way

Will not detect changes in untracked files
Comment 6 Jeff Kletsky 2010-03-04 17:07:16 UTC
Created attachment 155245 [details] [review]
Checks for untracked files as well

Made against r18811 -- after recent change to gnc-svnversion

Adds checking for untracked files. Code for "ignoring" untracked files present as well, but line is commented out.

Code that writes the version string is
./src/gnome-utils/gnc-splash.c:    ver_string = g_strdup_printf(_("Version: GnuCash-%s svn (r%s built %s)"),
and has not been changed.
Comment 7 Geert Janssens 2010-03-09 18:28:49 UTC
Comment on attachment 155245 [details] [review]
Checks for untracked files as well

Committed in r18880
Comment 8 Geert Janssens 2010-03-09 18:29:17 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Comment 9 John Ralls 2018-06-29 22:35:59 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=611645. Please update any external references or bookmarks.