builtin/ls-remote: initialize repository based on fetch

ls-remote may or may not operate within a repository, and as such will
not have been initialized with the repository's hash algorithm.  Even if
it were, the remote side could be using a different algorithm and we
would still want to display those refs properly.  Find the hash
algorithm used by the remote side by querying the transport object and
set our hash algorithm accordingly.

Without this change, if the remote side is using SHA-256, we truncate
the refs to 40 hex characters, since that's the length of the default
hash algorithm (SHA-1).

Note that technically this is not a correct setting of the repository
hash algorithm since, if we are in a repository, it might be one of a
different hash algorithm from the remote side.  However, our current
code paths don't handle multiple algorithms and won't for some time, so
this is the best we can do.  We rely on the fact that ls-remote never
modifies the current repository, which is a reasonable assumption to
make.

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