gitweb: use HEAD as secondary sort key in git_get_heads_list()

The "heads" section on the gitweb summary page shows heads in
`-committerdate` order (ie. the most recently-modified ones at the
top), tie-breaking equal-dated refs using the implicit `refname` sort
fallback. This recency-based ordering appears in multiple places in the
UI, such as the project listing, the tags list, and even the
shortlog and log views.

Given two equal-dated refs, however, sorting the `HEAD` ref before
the non-`HEAD` ref provides more useful signal than merely sorting by
refname. For example, say we had "master" and "trunk" both pointing at
the same commit but "trunk" was `HEAD`, sorting "trunk" first helps
communicate its special status as the default branch that you'll check
out if you clone the repo.

Add `-HEAD` as a secondary sort key to the `git for-each-ref` call
in `git_get_heads_list()` to provide the desired behavior. The most
recently committed refs will appear first, but `HEAD`-ness will be used
as a tie-breaker. Note that `refname` is the implicit fallback sort key,
which means that two same-dated non-`HEAD` refs will continue to be
sorted in lexicographical order, as they are today.

Signed-off-by: Greg Hurrell <greg@hurrell.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 file changed
tree: 921d33096db6608c89f227dfd0be3d01786bf57f
  1. .github/
  2. block-sha1/
  3. builtin/
  4. ci/
  5. compat/
  6. contrib/
  7. Documentation/
  8. ewah/
  9. git-gui/
  10. gitk-git/
  11. gitweb/
  12. mergetools/
  13. negotiator/
  14. perl/
  15. po/
  16. ppc/
  17. refs/
  18. sha1dc/
  19. sha256/
  20. t/
  21. templates/
  22. trace2/
  23. xdiff/
  24. .cirrus.yml
  25. .clang-format
  26. .editorconfig
  27. .gitattributes
  28. .gitignore
  29. .gitmodules
  30. .mailmap
  31. .travis.yml
  32. .tsan-suppressions
  33. abspath.c
  34. aclocal.m4
  35. add-interactive.c
  36. add-interactive.h
  37. add-patch.c
  38. advice.c
  39. advice.h
  40. alias.c
  41. alias.h
  42. alloc.c
  43. alloc.h
  44. apply.c
  45. apply.h
  46. archive-tar.c
  47. archive-zip.c
  48. archive.c
  49. archive.h
  50. attr.c
  51. attr.h
  52. banned.h
  53. base85.c
  54. bisect.c
  55. bisect.h
  56. blame.c
  57. blame.h
  58. blob.c
  59. blob.h
  60. bloom.c
  61. bloom.h
  62. branch.c
  63. branch.h
  64. builtin.h
  65. bulk-checkin.c
  66. bulk-checkin.h
  67. bundle.c
  68. bundle.h
  69. cache-tree.c
  70. cache-tree.h
  71. cache.h
  72. chdir-notify.c
  73. chdir-notify.h
  74. check-builtins.sh
  75. check_bindir
  76. checkout.c
  77. checkout.h
  78. chunk-format.c
  79. chunk-format.h
  80. CODE_OF_CONDUCT.md
  81. color.c
  82. color.h
  83. column.c
  84. column.h
  85. combine-diff.c
  86. command-list.txt
  87. commit-graph.c
  88. commit-graph.h
  89. commit-reach.c
  90. commit-reach.h
  91. commit-slab-decl.h
  92. commit-slab-impl.h
  93. commit-slab.h
  94. commit.c
  95. commit.h
  96. common-main.c
  97. config.c
  98. config.h
  99. config.mak.dev
  100. config.mak.in
  101. config.mak.uname
  102. configure.ac
  103. connect.c
  104. connect.h
  105. connected.c
  106. connected.h
  107. convert.c
  108. convert.h
  109. copy.c
  110. COPYING
  111. credential.c
  112. credential.h
  113. csum-file.c
  114. csum-file.h
  115. ctype.c
  116. daemon.c
  117. date.c
  118. decorate.c
  119. decorate.h
  120. delta-islands.c
  121. delta-islands.h
  122. delta.h
  123. detect-compiler
  124. diff-delta.c
  125. diff-lib.c
  126. diff-merges.c
  127. diff-merges.h
  128. diff-no-index.c
  129. diff.c
  130. diff.h
  131. diffcore-break.c
  132. diffcore-delta.c
  133. diffcore-order.c
  134. diffcore-pickaxe.c
  135. diffcore-rename.c
  136. diffcore-rotate.c
  137. diffcore.h
  138. dir-iterator.c
  139. dir-iterator.h
  140. dir.c
  141. dir.h
  142. editor.c
  143. entry.c
  144. environment.c
  145. environment.h
  146. exec-cmd.c
  147. exec-cmd.h
  148. fetch-negotiator.c
  149. fetch-negotiator.h
  150. fetch-pack.c
  151. fetch-pack.h
  152. fmt-merge-msg.c
  153. fmt-merge-msg.h
  154. fsck.c
  155. fsck.h
  156. fsmonitor.c
  157. fsmonitor.h
  158. fuzz-commit-graph.c
  159. fuzz-pack-headers.c
  160. fuzz-pack-idx.c
  161. generate-cmdlist.sh
  162. generate-configlist.sh
  163. gettext.c
  164. gettext.h
  165. git-add--interactive.perl
  166. git-archimport.perl
  167. git-bisect.sh
  168. git-compat-util.h
  169. git-cvsexportcommit.perl
  170. git-cvsimport.perl
  171. git-cvsserver.perl
  172. git-difftool--helper.sh
  173. git-filter-branch.sh
  174. git-instaweb.sh
  175. git-merge-octopus.sh
  176. git-merge-one-file.sh
  177. git-merge-resolve.sh
  178. git-mergetool--lib.sh
  179. git-mergetool.sh
  180. git-p4.py
  181. git-quiltimport.sh
  182. git-rebase--preserve-merges.sh
  183. git-request-pull.sh
  184. git-send-email.perl
  185. git-sh-i18n.sh
  186. git-sh-setup.sh
  187. git-submodule.sh
  188. git-svn.perl
  189. GIT-VERSION-GEN
  190. git-web--browse.sh
  191. git.c
  192. git.rc
  193. gpg-interface.c
  194. gpg-interface.h
  195. graph.c
  196. graph.h
  197. grep.c
  198. grep.h
  199. hash-lookup.c
  200. hash-lookup.h
  201. hash.h
  202. hashmap.c
  203. hashmap.h
  204. help.c
  205. help.h
  206. hex.c
  207. http-backend.c
  208. http-fetch.c
  209. http-push.c
  210. http-walker.c
  211. http.c
  212. http.h
  213. ident.c
  214. imap-send.c
  215. INSTALL
  216. iterator.h
  217. json-writer.c
  218. json-writer.h
  219. khash.h
  220. kwset.c
  221. kwset.h
  222. levenshtein.c
  223. levenshtein.h
  224. LGPL-2.1
  225. line-log.c
  226. line-log.h
  227. line-range.c
  228. line-range.h
  229. linear-assignment.c
  230. linear-assignment.h
  231. list-objects-filter-options.c
  232. list-objects-filter-options.h
  233. list-objects-filter.c
  234. list-objects-filter.h
  235. list-objects.c
  236. list-objects.h
  237. list.h
  238. ll-merge.c
  239. ll-merge.h
  240. lockfile.c
  241. lockfile.h
  242. log-tree.c
  243. log-tree.h
  244. ls-refs.c
  245. ls-refs.h
  246. mailinfo.c
  247. mailinfo.h
  248. mailmap.c
  249. mailmap.h
  250. Makefile
  251. match-trees.c
  252. mem-pool.c
  253. mem-pool.h
  254. merge-blobs.c
  255. merge-blobs.h
  256. merge-ort-wrappers.c
  257. merge-ort-wrappers.h
  258. merge-ort.c
  259. merge-ort.h
  260. merge-recursive.c
  261. merge-recursive.h
  262. merge.c
  263. mergesort.c
  264. mergesort.h
  265. midx.c
  266. midx.h
  267. name-hash.c
  268. notes-cache.c
  269. notes-cache.h
  270. notes-merge.c
  271. notes-merge.h
  272. notes-utils.c
  273. notes-utils.h
  274. notes.c
  275. notes.h
  276. object-file.c
  277. object-name.c
  278. object-store.h
  279. object.c
  280. object.h
  281. oid-array.c
  282. oid-array.h
  283. oidmap.c
  284. oidmap.h
  285. oidset.c
  286. oidset.h
  287. pack-bitmap-write.c
  288. pack-bitmap.c
  289. pack-bitmap.h
  290. pack-check.c
  291. pack-objects.c
  292. pack-objects.h
  293. pack-revindex.c
  294. pack-revindex.h
  295. pack-write.c
  296. pack.h
  297. packfile.c
  298. packfile.h
  299. pager.c
  300. parse-options-cb.c
  301. parse-options.c
  302. parse-options.h
  303. patch-delta.c
  304. patch-ids.c
  305. patch-ids.h
  306. path.c
  307. path.h
  308. pathspec.c
  309. pathspec.h
  310. pkt-line.c
  311. pkt-line.h
  312. preload-index.c
  313. pretty.c
  314. pretty.h
  315. prio-queue.c
  316. prio-queue.h
  317. progress.c
  318. progress.h
  319. promisor-remote.c
  320. promisor-remote.h
  321. prompt.c
  322. prompt.h
  323. protocol.c
  324. protocol.h
  325. prune-packed.c
  326. prune-packed.h
  327. quote.c
  328. quote.h
  329. range-diff.c
  330. range-diff.h
  331. reachable.c
  332. reachable.h
  333. read-cache.c
  334. README.md
  335. rebase-interactive.c
  336. rebase-interactive.h
  337. rebase.c
  338. rebase.h
  339. ref-filter.c
  340. ref-filter.h
  341. reflog-walk.c
  342. reflog-walk.h
  343. refs.c
  344. refs.h
  345. refspec.c
  346. refspec.h
  347. remote-curl.c
  348. remote.c
  349. remote.h
  350. replace-object.c
  351. replace-object.h
  352. repo-settings.c
  353. repository.c
  354. repository.h
  355. rerere.c
  356. rerere.h
  357. reset.c
  358. reset.h
  359. resolve-undo.c
  360. resolve-undo.h
  361. revision.c
  362. revision.h
  363. run-command.c
  364. run-command.h
  365. send-pack.c
  366. send-pack.h
  367. sequencer.c
  368. sequencer.h
  369. serve.c
  370. serve.h
  371. server-info.c
  372. setup.c
  373. sh-i18n--envsubst.c
  374. sha1dc_git.c
  375. sha1dc_git.h
  376. shallow.c
  377. shallow.h
  378. shell.c
  379. shortlog.h
  380. sideband.c
  381. sideband.h
  382. sigchain.c
  383. sigchain.h
  384. split-index.c
  385. split-index.h
  386. stable-qsort.c
  387. strbuf.c
  388. strbuf.h
  389. streaming.c
  390. streaming.h
  391. string-list.c
  392. string-list.h
  393. strmap.c
  394. strmap.h
  395. strvec.c
  396. strvec.h
  397. sub-process.c
  398. sub-process.h
  399. submodule-config.c
  400. submodule-config.h
  401. submodule.c
  402. submodule.h
  403. symlinks.c
  404. tag.c
  405. tag.h
  406. tar.h
  407. tempfile.c
  408. tempfile.h
  409. thread-utils.c
  410. thread-utils.h
  411. tmp-objdir.c
  412. tmp-objdir.h
  413. trace.c
  414. trace.h
  415. trace2.c
  416. trace2.h
  417. trailer.c
  418. trailer.h
  419. transport-helper.c
  420. transport-internal.h
  421. transport.c
  422. transport.h
  423. tree-diff.c
  424. tree-walk.c
  425. tree-walk.h
  426. tree.c
  427. tree.h
  428. unicode-width.h
  429. unimplemented.sh
  430. unix-socket.c
  431. unix-socket.h
  432. unpack-trees.c
  433. unpack-trees.h
  434. upload-pack.c
  435. upload-pack.h
  436. url.c
  437. url.h
  438. urlmatch.c
  439. urlmatch.h
  440. usage.c
  441. userdiff.c
  442. userdiff.h
  443. utf8.c
  444. utf8.h
  445. varint.c
  446. varint.h
  447. version.c
  448. version.h
  449. versioncmp.c
  450. walker.c
  451. walker.h
  452. wildmatch.c
  453. wildmatch.h
  454. worktree.c
  455. worktree.h
  456. wrap-for-bin.sh
  457. wrapper.c
  458. write-or-die.c
  459. ws.c
  460. wt-status.c
  461. wt-status.h
  462. xdiff-interface.c
  463. xdiff-interface.h
  464. zlib.c
README.md

Build status

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-<commandname>.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://lore.kernel.org/git/, http://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks