]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'js/name-rev-use-oldest-ref'
authorJunio C Hamano <gitster@pobox.com>
Tue, 3 May 2016 21:08:13 +0000 (14:08 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 May 2016 21:08:13 +0000 (14:08 -0700)
"git describe --contains" often made a hard-to-justify choice of
tag to give name to a given commit, because it tried to come up
with a name with smallest number of hops from a tag, causing an old
commit whose close descendant that is recently tagged were not
described with respect to an old tag but with a newer tag.  It did
not help that its computation of "hop" count was further tweaked to
penalize being on a side branch of a merge.  The logic has been
updated to favor using the tag with the oldest tagger date, which
is a lot easier to explain to the end users: "We describe a commit
in terms of the (chronologically) oldest tag that contains the
commit."

* js/name-rev-use-oldest-ref:
  name-rev: include taggerdate in considering the best name

1  2 
builtin/name-rev.c
t/t9903-bash-prompt.sh

index 092e03c3cc9b24445ee5ed92cee5b202e04c9ec7,63b65885cbdcf8f79cd62dfe3cf061416d84109a..57be35faf583d5bcb112c9f487b67ae4df8bf368
@@@ -55,22 -60,26 +60,22 @@@ copy_data
                        parents;
                        parents = parents->next, parent_number++) {
                if (parent_number > 1) {
 -                      int len = strlen(tip_name);
 -                      char *new_name = xmalloc(len +
 -                              1 + decimal_length(generation) +  /* ~<n> */
 -                              1 + 2 +                           /* ^NN */
 -                              1);
 -
 -                      if (len > 2 && !strcmp(tip_name + len - 2, "^0"))
 -                              len -= 2;
 +                      size_t len;
 +                      char *new_name;
 +
 +                      strip_suffix(tip_name, "^0", &len);
                        if (generation > 0)
 -                              sprintf(new_name, "%.*s~%d^%d", len, tip_name,
 -                                              generation, parent_number);
 +                              new_name = xstrfmt("%.*s~%d^%d", (int)len, tip_name,
 +                                                 generation, parent_number);
                        else
 -                              sprintf(new_name, "%.*s^%d", len, tip_name,
 -                                              parent_number);
 +                              new_name = xstrfmt("%.*s^%d", (int)len, tip_name,
 +                                                 parent_number);
  
-                       name_rev(parents->item, new_name, 0,
+                       name_rev(parents->item, new_name, taggerdate, 0,
                                distance + MERGE_TRAVERSAL_WEIGHT, 0);
                } else {
-                       name_rev(parents->item, tip_name, generation + 1,
-                               distance + 1, 0);
+                       name_rev(parents->item, tip_name, taggerdate,
+                               generation + 1, distance + 1, 0);
                }
        }
  }
@@@ -162,8 -172,9 +168,9 @@@ static int name_ref(const char *path, c
                struct tag *t = (struct tag *) o;
                if (!t->tagged)
                        break; /* broken repository */
 -              o = parse_object(t->tagged->sha1);
 +              o = parse_object(t->tagged->oid.hash);
                deref = 1;
+               taggerdate = t->date;
        }
        if (o && o->type == OBJ_COMMIT) {
                struct commit *commit = (struct commit *)o;
Simple merge