revision.c: propagate tag names from pending array

When we unwrap a tag to find its commit for a traversal, we
do not propagate the "name" field of the tag in the pending
array (i.e., the ref name the user gave us in the first
place) to the commit (instead, we use an empty string). This
means that "git log --source" will never show the tag-name
for commits we reach through it.

This was broken in 2073949 (traverse_commit_list: support
pending blobs/trees with paths, 2014-10-15). That commit
tried to be careful and avoid propagating the path
information for a tag (which would be nonsensical) to trees
and blobs. But it should not have cut off the "name" field,
which should carry forward to children.

Note that this does mean that the "name" field will carry
forward to blobs and trees, too. Whereas prior to 2073949,
we always gave them an empty string. This is the right thing
to do, but in practice no callers probably use it (since now
we have an explicit separate "path" field, which was the
point of 2073949).

We add tests here not only for the broken case, but also a
basic sanity test of "log --source" in general, which did
not have any coverage in the test suite.

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