[gimp] app: fix abbreviated commit hashes



commit c97209ba4a17ac70284be1bb5162a5c5e19d5be4
Author: Ell <ell_se yahoo com>
Date:   Tue Mar 21 22:54:11 2017 -0400

    app: fix abbreviated commit hashes
    
    The abbreviated commit hash we show in the shell and the about
    dialog is currently just the last 7 characters of 'git describe',
    based on the assumption that abbreviated hashes are always 7-digits
    long.  When the hash is longer than that, we're just showing a
    nonsense commit.
    
    This was never a good idea, since users can override this, and
    since disambiguation can result in longer hashes, but since git
    2.11, the default abbreviated hash length is determined based on
    the size of the repository, which currently results in 10 digits
    for us.
    
    Let's just do it right.

 app/Makefile.am                          |    3 +++
 app/dialogs/about-dialog.c               |   11 +++--------
 app/display/gimpdisplayshell-callbacks.c |    7 +------
 3 files changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/app/Makefile.am b/app/Makefile.am
index b7933f3..ff914fd 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -272,9 +272,11 @@ dist-hook: dist-check-gimp-console dist-dump-gimprc
 git-version.h: update-git-version-header
        @if test -d "$(top_srcdir)/.git"; then \
          git_version="`git --git-dir=$(top_srcdir)/.git describe --always`"; \
+         git_version_abbrev="`git --git-dir=$(top_srcdir)/.git rev-parse --short HEAD`"; \
          git_last_commit_year="`git --git-dir=$(top_srcdir)/.git log -n1 --reverse --pretty=%ci | cut -b 
1-4`"; \
        elif test ! -f "$@"; then \
          git_version="Unknown, shouldn't happen"; \
+         git_version_abbrev="$$git_version"; \
          git_last_commit_timestamp=-1; \
          git_last_commit_year="`date -u '+%Y'`"; \
        fi; \
@@ -282,6 +284,7 @@ git-version.h: update-git-version-header
          echo "#ifndef __GIT_VERSION_H__" > "$@.tmp"; \
          echo "#define __GIT_VERSION_H__" >> "$@.tmp"; \
          echo "#define GIMP_GIT_VERSION \"$$git_version\"" >> "$@.tmp"; \
+         echo "#define GIMP_GIT_VERSION_ABBREV \"$$git_version_abbrev\"" >> "$@.tmp"; \
          echo "#define GIMP_GIT_LAST_COMMIT_YEAR \"$$git_last_commit_year\"" >> "$@.tmp"; \
          echo "#endif /* __GIT_VERSION_H__ */" >> "$@.tmp"; \
        fi
diff --git a/app/dialogs/about-dialog.c b/app/dialogs/about-dialog.c
index 72eaca6..58850c0 100644
--- a/app/dialogs/about-dialog.c
+++ b/app/dialogs/about-dialog.c
@@ -601,18 +601,13 @@ about_dialog_timer (gpointer data)
 static void
 about_dialog_add_unstable_message (GtkWidget *vbox)
 {
-  GtkWidget   *label;
-  const gchar *version;
-  gchar       *short_hash;
-  gchar       *text;
+  GtkWidget *label;
+  gchar     *text;
 
-  version = GIMP_GIT_VERSION;
-  short_hash = g_strdup (version + strlen (version) - 7);
   text = g_strdup_printf (_("This is an unstable development release\n"
-                            "commit %s"), short_hash);
+                            "commit %s"), GIMP_GIT_VERSION_ABBREV);
   label = gtk_label_new (text);
   g_free (text);
-  g_free (short_hash);
 
   gtk_label_set_selectable (GTK_LABEL (label), TRUE);
   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index b8834a3..7cd1f0c 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -525,8 +525,6 @@ gimp_display_shell_canvas_draw_drop_zone (GimpDisplayShell *shell,
 #ifdef GIMP_UNSTABLE
   {
     PangoLayout   *layout;
-    const gchar   *version;
-    gchar         *short_hash;
     gchar         *msg;
     GtkAllocation  allocation;
     gint           width;
@@ -535,17 +533,14 @@ gimp_display_shell_canvas_draw_drop_zone (GimpDisplayShell *shell,
 
     layout = gtk_widget_create_pango_layout (shell->canvas, NULL);
 
-    version = GIMP_GIT_VERSION;
-    short_hash = g_strdup (version + strlen (version) - 7);
     msg = g_strdup_printf (_("<big>Unstable Development Version</big>\n\n"
                              "<small>commit <tt>%s</tt></small>\n\n"
                              "<small>Please test bugs against "
                              "latest git master branch\n"
                              "before reporting them.</small>"),
-                             short_hash);
+                             GIMP_GIT_VERSION_ABBREV);
     pango_layout_set_markup (layout, msg, -1);
     g_free (msg);
-    g_free (short_hash);
     pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
 
     pango_layout_get_pixel_size (layout, &width, &height);


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