Chose better tag names in git-describe after merges.

Recently git.git itself encountered a situation on its master and
next branches where git-describe stopped reporting 'v1.5.0-rc0-gN'
and instead started reporting 'v1.4.4.4-gN'.  This appeared to be
a backward jump in version numbering.

  maint     o-------------------4
            \                    \
  master     o-o-o-o-o-o-o-5-o-C-o-W

The issue is that commit C in the diagram claims it is version
1.5.0, as the tag v1.5.0 is placed on commit 5.  Yet commit W
claims it is version 1.4.4.4 as the tag v1.5.0 has an older tag
date than the v1.4.4.4 tag.

As it turns out this situation is very common.  A bug fix applied
to maint and later merged into master occurs frequently enough that
it should Just Work Right(tm).

Rather than taking the first tag that gets found git-describe will
now generate a list of all possible tags and select the one which
has the most number of commits in common with HEAD (or whatever
revision the user requested the description of).

This rule is based on the principle shown in the diagram above.
There are a large number of commits on the primary development branch
'master' which do not appear in the 'maint' branch, and many of
these are already tagged as part of v1.5.0-rc0.  Additionally these
commits are not in v1.4.4.4, as they are part of the v1.5.0 release
still being developed.  The v1.5.0-rc0 tag is more descriptive of
W than v1.4.4.4 is, and therefore should be used.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 file changed
tree: c7c335d8b79d0a485968bb4e2a397212cc4104cf
  1. arm/
  2. compat/
  3. contrib/
  4. Documentation/
  5. gitweb/
  6. mozilla-sha1/
  7. perl/
  8. ppc/
  9. t/
  10. templates/
  11. xdiff/
  12. .gitignore
  13. .mailmap
  14. alloc.c
  15. archive-tar.c
  16. archive-zip.c
  17. archive.h
  18. base85.c
  19. blob.c
  20. blob.h
  21. builtin-add.c
  22. builtin-annotate.c
  23. builtin-apply.c
  24. builtin-archive.c
  25. builtin-blame.c
  26. builtin-branch.c
  27. builtin-cat-file.c
  28. builtin-check-ref-format.c
  29. builtin-checkout-index.c
  30. builtin-commit-tree.c
  31. builtin-count-objects.c
  32. builtin-describe.c
  33. builtin-diff-files.c
  34. builtin-diff-index.c
  35. builtin-diff-stages.c
  36. builtin-diff-tree.c
  37. builtin-diff.c
  38. builtin-fmt-merge-msg.c
  39. builtin-for-each-ref.c
  40. builtin-grep.c
  41. builtin-init-db.c
  42. builtin-log.c
  43. builtin-ls-files.c
  44. builtin-ls-tree.c
  45. builtin-mailinfo.c
  46. builtin-mailsplit.c
  47. builtin-merge-file.c
  48. builtin-mv.c
  49. builtin-name-rev.c
  50. builtin-pack-objects.c
  51. builtin-pack-refs.c
  52. builtin-prune-packed.c
  53. builtin-prune.c
  54. builtin-push.c
  55. builtin-read-tree.c
  56. builtin-reflog.c
  57. builtin-repo-config.c
  58. builtin-rerere.c
  59. builtin-rev-list.c
  60. builtin-rev-parse.c
  61. builtin-rm.c
  62. builtin-runstatus.c
  63. builtin-shortlog.c
  64. builtin-show-branch.c
  65. builtin-show-ref.c
  66. builtin-stripspace.c
  67. builtin-symbolic-ref.c
  68. builtin-tar-tree.c
  69. builtin-unpack-objects.c
  70. builtin-update-index.c
  71. builtin-update-ref.c
  72. builtin-upload-archive.c
  73. builtin-verify-pack.c
  74. builtin-write-tree.c
  75. builtin.h
  76. cache-tree.c
  77. cache-tree.h
  78. cache.h
  79. check-builtins.sh
  80. check-racy.c
  81. color.c
  82. color.h
  83. combine-diff.c
  84. commit.c
  85. commit.h
  86. config.c
  87. config.mak.in
  88. configure.ac
  89. connect.c
  90. convert-objects.c
  91. copy.c
  92. COPYING
  93. csum-file.c
  94. csum-file.h
  95. ctype.c
  96. daemon.c
  97. date.c
  98. delta.h
  99. diff-delta.c
  100. diff-lib.c
  101. diff.c
  102. diff.h
  103. diffcore-break.c
  104. diffcore-delta.c
  105. diffcore-order.c
  106. diffcore-pickaxe.c
  107. diffcore-rename.c
  108. diffcore.h
  109. dir.c
  110. dir.h
  111. dump-cache-tree.c
  112. entry.c
  113. environment.c
  114. exec_cmd.c
  115. exec_cmd.h
  116. fetch-pack.c
  117. fetch.c
  118. fetch.h
  119. fsck-objects.c
  120. generate-cmdlist.sh
  121. git-add--interactive.perl
  122. git-am.sh
  123. git-applymbox.sh
  124. git-applypatch.sh
  125. git-archimport.perl
  126. git-bisect.sh
  127. git-checkout.sh
  128. git-clean.sh
  129. git-clone.sh
  130. git-commit.sh
  131. git-compat-util.h
  132. git-cvsexportcommit.perl
  133. git-cvsimport.perl
  134. git-cvsserver.perl
  135. git-fetch.sh
  136. git-gc.sh
  137. git-instaweb.sh
  138. git-lost-found.sh
  139. git-ls-remote.sh
  140. git-merge-octopus.sh
  141. git-merge-one-file.sh
  142. git-merge-ours.sh
  143. git-merge-resolve.sh
  144. git-merge-stupid.sh
  145. git-merge.sh
  146. git-p4import.py
  147. git-parse-remote.sh
  148. git-pull.sh
  149. git-quiltimport.sh
  150. git-rebase.sh
  151. git-relink.perl
  152. git-remote.perl
  153. git-repack.sh
  154. git-request-pull.sh
  155. git-reset.sh
  156. git-resolve.sh
  157. git-revert.sh
  158. git-send-email.perl
  159. git-sh-setup.sh
  160. git-svn.perl
  161. git-svnimport.perl
  162. git-tag.sh
  163. git-verify-tag.sh
  164. GIT-VERSION-GEN
  165. git.c
  166. git.spec.in
  167. gitk
  168. grep.c
  169. grep.h
  170. hash-object.c
  171. help.c
  172. http-fetch.c
  173. http-push.c
  174. http.c
  175. http.h
  176. ident.c
  177. imap-send.c
  178. index-pack.c
  179. INSTALL
  180. interpolate.c
  181. interpolate.h
  182. list-objects.c
  183. list-objects.h
  184. local-fetch.c
  185. lockfile.c
  186. log-tree.c
  187. log-tree.h
  188. Makefile
  189. merge-base.c
  190. merge-file.c
  191. merge-index.c
  192. merge-recursive.c
  193. merge-tree.c
  194. mktag.c
  195. mktree.c
  196. object-refs.c
  197. object.c
  198. object.h
  199. pack-check.c
  200. pack-redundant.c
  201. pack.h
  202. pager.c
  203. patch-delta.c
  204. patch-id.c
  205. path-list.c
  206. path-list.h
  207. path.c
  208. peek-remote.c
  209. pkt-line.c
  210. pkt-line.h
  211. quote.c
  212. quote.h
  213. reachable.c
  214. reachable.h
  215. read-cache.c
  216. README
  217. receive-pack.c
  218. refs.c
  219. refs.h
  220. revision.c
  221. revision.h
  222. rsh.c
  223. rsh.h
  224. run-command.c
  225. run-command.h
  226. send-pack.c
  227. server-info.c
  228. setup.c
  229. sha1_file.c
  230. sha1_name.c
  231. shallow.c
  232. shell.c
  233. show-index.c
  234. sideband.c
  235. sideband.h
  236. ssh-fetch.c
  237. ssh-pull.c
  238. ssh-push.c
  239. ssh-upload.c
  240. strbuf.c
  241. strbuf.h
  242. tag.c
  243. tag.h
  244. tar.h
  245. test-date.c
  246. test-delta.c
  247. test-sha1.c
  248. test-sha1.sh
  249. trace.c
  250. tree-diff.c
  251. tree-walk.c
  252. tree-walk.h
  253. tree.c
  254. tree.h
  255. unpack-file.c
  256. unpack-trees.c
  257. unpack-trees.h
  258. update-server-info.c
  259. upload-pack.c
  260. usage.c
  261. utf8.c
  262. utf8.h
  263. var.c
  264. write_or_die.c
  265. wt-status.c
  266. wt-status.h
  267. xdiff-interface.c
  268. xdiff-interface.h