upload/receive-pack: allow hiding ref hierarchies

A repository may have refs that are only used for its internal
bookkeeping purposes that should not be exposed to the others that
come over the network.

Teach upload-pack to omit some refs from its initial advertisement
by paying attention to the uploadpack.hiderefs multi-valued
configuration variable.  Do the same to receive-pack via the
receive.hiderefs variable.  As a convenient short-hand, allow using
transfer.hiderefs to set the value to both of these variables.

Any ref that is under the hierarchies listed on the value of these
variable is excluded from responses to requests made by "ls-remote",
"fetch", etc. (for upload-pack) and "push" (for receive-pack).

Because these hidden refs do not count as OUR_REF, an attempt to
fetch objects at the tip of them will be rejected, and because these
refs do not get advertised, "git push :" will not see local branches
that have the same name as them as "matching" ones to be sent.

An attempt to update/delete these hidden refs with an explicit
refspec, e.g. "git push origin :refs/hidden/22", is rejected.  This
is not a new restriction.  To the pusher, it would appear that there
is no such ref, so its push request will conclude with "Now that I
sent you all the data, it is time for you to update the refs.  I saw
that the ref did not exist when I started pushing, and I want the
result to point at this commit".  The receiving end will apply the
compare-and-swap rule to this request and rejects the push with
"Well, your update request conflicts with somebody else; I see there
is such a ref.", which is the right thing to do. Otherwise a push to
a hidden ref will always be "the last one wins", which is not a good
default.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 files changed
tree: 46a71938843dae2dade7b121a5d7c5eb7d6a65a9
  1. block-sha1/
  2. builtin/
  3. compat/
  4. contrib/
  5. Documentation/
  6. git-gui/
  7. git_remote_helpers/
  8. gitk-git/
  9. gitweb/
  10. mergetools/
  11. perl/
  12. po/
  13. ppc/
  14. t/
  15. templates/
  16. vcs-svn/
  17. xdiff/
  18. .gitattributes
  19. .gitignore
  20. .mailmap
  21. abspath.c
  22. aclocal.m4
  23. advice.c
  24. advice.h
  25. alias.c
  26. alloc.c
  27. archive-tar.c
  28. archive-zip.c
  29. archive.c
  30. archive.h
  31. argv-array.c
  32. argv-array.h
  33. attr.c
  34. attr.h
  35. base85.c
  36. bisect.c
  37. bisect.h
  38. blob.c
  39. blob.h
  40. branch.c
  41. branch.h
  42. builtin.h
  43. bulk-checkin.c
  44. bulk-checkin.h
  45. bundle.c
  46. bundle.h
  47. cache-tree.c
  48. cache-tree.h
  49. cache.h
  50. check-builtins.sh
  51. check-racy.c
  52. check_bindir
  53. color.c
  54. color.h
  55. column.c
  56. column.h
  57. combine-diff.c
  58. command-list.txt
  59. commit.c
  60. commit.h
  61. config.c
  62. config.mak.in
  63. config.mak.uname
  64. configure.ac
  65. connect.c
  66. connected.c
  67. connected.h
  68. convert.c
  69. convert.h
  70. copy.c
  71. COPYING
  72. credential-cache--daemon.c
  73. credential-cache.c
  74. credential-store.c
  75. credential.c
  76. credential.h
  77. csum-file.c
  78. csum-file.h
  79. ctype.c
  80. daemon.c
  81. date.c
  82. decorate.c
  83. decorate.h
  84. delta.h
  85. diff-delta.c
  86. diff-lib.c
  87. diff-no-index.c
  88. diff.c
  89. diff.h
  90. diffcore-break.c
  91. diffcore-delta.c
  92. diffcore-order.c
  93. diffcore-pickaxe.c
  94. diffcore-rename.c
  95. diffcore.h
  96. dir.c
  97. dir.h
  98. editor.c
  99. entry.c
  100. environment.c
  101. exec_cmd.c
  102. exec_cmd.h
  103. fast-import.c
  104. fetch-pack.c
  105. fetch-pack.h
  106. fixup-builtins
  107. fmt-merge-msg.h
  108. fsck.c
  109. fsck.h
  110. generate-cmdlist.sh
  111. gettext.c
  112. gettext.h
  113. git-add--interactive.perl
  114. git-am.sh
  115. git-archimport.perl
  116. git-bisect.sh
  117. git-compat-util.h
  118. git-cvsexportcommit.perl
  119. git-cvsimport.perl
  120. git-cvsserver.perl
  121. git-difftool--helper.sh
  122. git-difftool.perl
  123. git-filter-branch.sh
  124. git-instaweb.sh
  125. git-lost-found.sh
  126. git-merge-octopus.sh
  127. git-merge-one-file.sh
  128. git-merge-resolve.sh
  129. git-mergetool--lib.sh
  130. git-mergetool.sh
  131. git-p4.py
  132. git-parse-remote.sh
  133. git-pull.sh
  134. git-quiltimport.sh
  135. git-rebase--am.sh
  136. git-rebase--interactive.sh
  137. git-rebase--merge.sh
  138. git-rebase.sh
  139. git-relink.perl
  140. git-remote-testgit
  141. git-remote-testpy.py
  142. git-repack.sh
  143. git-request-pull.sh
  144. git-send-email.perl
  145. git-sh-i18n.sh
  146. git-sh-setup.sh
  147. git-stash.sh
  148. git-submodule.sh
  149. git-svn.perl
  150. GIT-VERSION-GEN
  151. git-web--browse.sh
  152. git.c
  153. git.spec.in
  154. gpg-interface.c
  155. gpg-interface.h
  156. graph.c
  157. graph.h
  158. grep.c
  159. grep.h
  160. hash.c
  161. hash.h
  162. help.c
  163. help.h
  164. hex.c
  165. http-backend.c
  166. http-fetch.c
  167. http-push.c
  168. http-walker.c
  169. http.c
  170. http.h
  171. ident.c
  172. imap-send.c
  173. INSTALL
  174. kwset.c
  175. kwset.h
  176. levenshtein.c
  177. levenshtein.h
  178. LGPL-2.1
  179. list-objects.c
  180. list-objects.h
  181. ll-merge.c
  182. ll-merge.h
  183. lockfile.c
  184. log-tree.c
  185. log-tree.h
  186. mailmap.c
  187. mailmap.h
  188. Makefile
  189. match-trees.c
  190. merge-blobs.c
  191. merge-blobs.h
  192. merge-recursive.c
  193. merge-recursive.h
  194. merge.c
  195. mergesort.c
  196. mergesort.h
  197. name-hash.c
  198. notes-cache.c
  199. notes-cache.h
  200. notes-merge.c
  201. notes-merge.h
  202. notes.c
  203. notes.h
  204. object.c
  205. object.h
  206. pack-check.c
  207. pack-refs.c
  208. pack-refs.h
  209. pack-revindex.c
  210. pack-revindex.h
  211. pack-write.c
  212. pack.h
  213. pager.c
  214. parse-options-cb.c
  215. parse-options.c
  216. parse-options.h
  217. patch-delta.c
  218. patch-ids.c
  219. patch-ids.h
  220. path.c
  221. pkt-line.c
  222. pkt-line.h
  223. preload-index.c
  224. pretty.c
  225. progress.c
  226. progress.h
  227. prompt.c
  228. prompt.h
  229. quote.c
  230. quote.h
  231. reachable.c
  232. reachable.h
  233. read-cache.c
  234. README
  235. reflog-walk.c
  236. reflog-walk.h
  237. refs.c
  238. refs.h
  239. remote-curl.c
  240. remote-testsvn.c
  241. remote.c
  242. remote.h
  243. replace_object.c
  244. rerere.c
  245. rerere.h
  246. resolve-undo.c
  247. resolve-undo.h
  248. revision.c
  249. revision.h
  250. run-command.c
  251. run-command.h
  252. send-pack.c
  253. send-pack.h
  254. sequencer.c
  255. sequencer.h
  256. server-info.c
  257. setup.c
  258. sh-i18n--envsubst.c
  259. sha1-array.c
  260. sha1-array.h
  261. sha1-lookup.c
  262. sha1-lookup.h
  263. sha1_file.c
  264. sha1_name.c
  265. shallow.c
  266. shell.c
  267. shortlog.h
  268. show-index.c
  269. sideband.c
  270. sideband.h
  271. sigchain.c
  272. sigchain.h
  273. strbuf.c
  274. strbuf.h
  275. streaming.c
  276. streaming.h
  277. string-list.c
  278. string-list.h
  279. submodule.c
  280. submodule.h
  281. symlinks.c
  282. tag.c
  283. tag.h
  284. tar.h
  285. test-chmtime.c
  286. test-ctype.c
  287. test-date.c
  288. test-delta.c
  289. test-dump-cache-tree.c
  290. test-genrandom.c
  291. test-index-version.c
  292. test-line-buffer.c
  293. test-match-trees.c
  294. test-mergesort.c
  295. test-mktemp.c
  296. test-parse-options.c
  297. test-path-utils.c
  298. test-regex.c
  299. test-revision-walking.c
  300. test-run-command.c
  301. test-scrap-cache-tree.c
  302. test-sha1.c
  303. test-sha1.sh
  304. test-sigchain.c
  305. test-string-list.c
  306. test-subprocess.c
  307. test-svn-fe.c
  308. test-wildmatch.c
  309. thread-utils.c
  310. thread-utils.h
  311. trace.c
  312. transport-helper.c
  313. transport.c
  314. transport.h
  315. tree-diff.c
  316. tree-walk.c
  317. tree-walk.h
  318. tree.c
  319. tree.h
  320. unimplemented.sh
  321. unix-socket.c
  322. unix-socket.h
  323. unpack-trees.c
  324. unpack-trees.h
  325. upload-pack.c
  326. url.c
  327. url.h
  328. usage.c
  329. userdiff.c
  330. userdiff.h
  331. utf8.c
  332. utf8.h
  333. varint.c
  334. varint.h
  335. version.c
  336. version.h
  337. walker.c
  338. walker.h
  339. wildmatch.c
  340. wildmatch.h
  341. wrap-for-bin.sh
  342. wrapper.c
  343. write_or_die.c
  344. ws.c
  345. wt-status.c
  346. wt-status.h
  347. xdiff-interface.c
  348. xdiff-interface.h
  349. zlib.c