show_object(): push path_name() call further down

In particular, pushing the "path_name()" call _into_ the show() function
would seem to allow

 - more clarity into who "owns" the name (ie now when we free the name in
   the show_object callback, it's because we generated it ourselves by
   calling path_name())

 - not calling path_name() at all, either because we don't care about the
   name in the first place, or because we are actually happy walking the
   linked list of "struct name_path *" and the last component.

Now, I didn't do that latter optimization, because it would require some
more coding, but especially looking at "builtin-pack-objects.c", we really
don't even want the whole pathname, we really would be better off with the
list of path components.

Why? We use that name for two things:
 - add_preferred_base_object(), which actually _wants_ to traverse the
   path, and now does it by looking for '/' characters!
 - for 'name_hash()', which only cares about the last 16 characters of a
   name, so again, generating the full name seems to be just unnecessary
   work.

Anyway, so I didn't look any closer at those things, but it did convince
me that the "show_object()" calling convention was crazy, and we're
actually better off doing _less_ in list-objects.c, and giving people
access to the internal data structures so that they can decide whether
they want to generate a path-name or not.

This patch does that, and then for people who did use the name (even if
they might do something more clever in the future), it just does the
straightforward "name = path_name(path, component); .. free(name);" thing.

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