fast-import: don't allow 'ls' of path with empty components

As the fast-import manual explains:

	The value of <path> must be in canonical form. That is it must
	not:
	. contain an empty directory component (e.g. foo//bar is invalid),
	. end with a directory separator (e.g. foo/ is invalid),
	. start with a directory separator (e.g. /foo is invalid),

Unfortunately the "ls" command accepts these invalid syntaxes and
responds by declaring that the indicated path is missing.  This is too
subtle and causes importers to silently misbehave; better to error out
so the operator knows what's happening.

The C, R, and M commands already error out for such paths.

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