lock_any_ref_for_update(): do not accept malformatted refs.

We used to use lock_any_ref_for_update() because the command
needs to also update HEAD (which is not under refs/, so
lock_ref_sha1() cannot be used).  The function however did not
check for refs with illegal characters in them.

Use check_ref_format() to catch malformed refs.  For this check,
we specifically do not want to say having less than two levels
in the name is illegal to allow HEAD (and perhaps other special
refs in the future).

Signed-off-by: Junio C Hamano <junkio@cox.net>
2 files changed
tree: d1484466557729e27ba4dda475dd8c6a2e918f2c
  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-config.c
  32. builtin-count-objects.c
  33. builtin-describe.c
  34. builtin-diff-files.c
  35. builtin-diff-index.c
  36. builtin-diff-stages.c
  37. builtin-diff-tree.c
  38. builtin-diff.c
  39. builtin-fmt-merge-msg.c
  40. builtin-for-each-ref.c
  41. builtin-grep.c
  42. builtin-init-db.c
  43. builtin-log.c
  44. builtin-ls-files.c
  45. builtin-ls-tree.c
  46. builtin-mailinfo.c
  47. builtin-mailsplit.c
  48. builtin-merge-file.c
  49. builtin-mv.c
  50. builtin-name-rev.c
  51. builtin-pack-objects.c
  52. builtin-pack-refs.c
  53. builtin-prune-packed.c
  54. builtin-prune.c
  55. builtin-push.c
  56. builtin-read-tree.c
  57. builtin-reflog.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.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. reflog-walk.c
  219. reflog-walk.h
  220. refs.c
  221. refs.h
  222. revision.c
  223. revision.h
  224. rsh.c
  225. rsh.h
  226. run-command.c
  227. run-command.h
  228. send-pack.c
  229. server-info.c
  230. setup.c
  231. sha1_file.c
  232. sha1_name.c
  233. shallow.c
  234. shell.c
  235. show-index.c
  236. sideband.c
  237. sideband.h
  238. ssh-fetch.c
  239. ssh-pull.c
  240. ssh-push.c
  241. ssh-upload.c
  242. strbuf.c
  243. strbuf.h
  244. tag.c
  245. tag.h
  246. tar.h
  247. test-date.c
  248. test-delta.c
  249. test-sha1.c
  250. test-sha1.sh
  251. trace.c
  252. tree-diff.c
  253. tree-walk.c
  254. tree-walk.h
  255. tree.c
  256. tree.h
  257. unpack-file.c
  258. unpack-trees.c
  259. unpack-trees.h
  260. update-server-info.c
  261. upload-pack.c
  262. usage.c
  263. utf8.c
  264. utf8.h
  265. var.c
  266. write_or_die.c
  267. wt-status.c
  268. wt-status.h
  269. xdiff-interface.c
  270. xdiff-interface.h