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