convert: permit passing additional metadata to filter processes

There are a variety of situations where a filter process can make use of
some additional metadata.  For example, some people find the ident
filter too limiting and would like to include the commit or the branch
in their smudged files.  This information isn't available during
checkout as HEAD hasn't been updated at that point, and it wouldn't be
available in archives either.

Let's add a way to pass this metadata down to the filter.  We pass the
blob we're operating on, the treeish (preferring the commit over the
tree if one exists), and the ref we're operating on.  Note that we won't
pass this information in all cases, such as when renormalizing or when
we're performing diffs, since it doesn't make sense in those cases.

The data we currently get from the filter process looks like the
following:

  command=smudge
  pathname=git.c
  0000

With this change, we'll get data more like this:

  command=smudge
  pathname=git.c
  refname=refs/tags/v2.25.1
  treeish=c522f061d551c9bb8684a7c3859b2ece4499b56b
  blob=7be7ad34bd053884ec48923706e70c81719a8660
  0000

There are a couple things to note about this approach.  For operations
like checkout, treeish will always be a commit, since we cannot check
out individual trees, but for other operations, like archive, we can end
up operating on only a particular tree, so we'll provide only a tree as
the treeish.  Similar comments apply for refname, since there are a
variety of cases in which we won't have a ref.

This commit wires up the code to print this information, but doesn't
pass any of it at this point.  In a future commit, we'll have various
code paths pass the actual useful data down.

Signed-off-by: brian m. carlson <bk2204@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 files changed
tree: 70956e3f2cd7b14b35bc0ef26c72475b27550bea
  1. .cirrus.yml
  2. .clang-format
  3. .editorconfig
  4. .gitattributes
  5. .github/
  6. .gitignore
  7. .gitmodules
  8. .mailmap
  9. .travis.yml
  10. .tsan-suppressions
  11. CODE_OF_CONDUCT.md
  12. COPYING
  13. Documentation/
  14. GIT-VERSION-GEN
  15. INSTALL
  16. LGPL-2.1
  17. Makefile
  18. README.md
  19. abspath.c
  20. aclocal.m4
  21. add-interactive.c
  22. add-interactive.h
  23. add-patch.c
  24. advice.c
  25. advice.h
  26. alias.c
  27. alias.h
  28. alloc.c
  29. alloc.h
  30. apply.c
  31. apply.h
  32. archive-tar.c
  33. archive-zip.c
  34. archive.c
  35. archive.h
  36. argv-array.c
  37. argv-array.h
  38. attr.c
  39. attr.h
  40. azure-pipelines.yml
  41. banned.h
  42. base85.c
  43. bisect.c
  44. bisect.h
  45. blame.c
  46. blame.h
  47. blob.c
  48. blob.h
  49. block-sha1/
  50. branch.c
  51. branch.h
  52. builtin.h
  53. builtin/
  54. bulk-checkin.c
  55. bulk-checkin.h
  56. bundle.c
  57. bundle.h
  58. cache-tree.c
  59. cache-tree.h
  60. cache.h
  61. chdir-notify.c
  62. chdir-notify.h
  63. check-builtins.sh
  64. check_bindir
  65. checkout.c
  66. checkout.h
  67. ci/
  68. color.c
  69. color.h
  70. column.c
  71. column.h
  72. combine-diff.c
  73. command-list.txt
  74. commit-graph.c
  75. commit-graph.h
  76. commit-reach.c
  77. commit-reach.h
  78. commit-slab-decl.h
  79. commit-slab-impl.h
  80. commit-slab.h
  81. commit.c
  82. commit.h
  83. common-main.c
  84. compat/
  85. config.c
  86. config.h
  87. config.mak.dev
  88. config.mak.in
  89. config.mak.uname
  90. configure.ac
  91. connect.c
  92. connect.h
  93. connected.c
  94. connected.h
  95. contrib/
  96. convert.c
  97. convert.h
  98. copy.c
  99. credential-cache--daemon.c
  100. credential-cache.c
  101. credential-store.c
  102. credential.c
  103. credential.h
  104. csum-file.c
  105. csum-file.h
  106. ctype.c
  107. daemon.c
  108. date.c
  109. decorate.c
  110. decorate.h
  111. delta-islands.c
  112. delta-islands.h
  113. delta.h
  114. detect-compiler
  115. diff-delta.c
  116. diff-lib.c
  117. diff-no-index.c
  118. diff.c
  119. diff.h
  120. diffcore-break.c
  121. diffcore-delta.c
  122. diffcore-order.c
  123. diffcore-pickaxe.c
  124. diffcore-rename.c
  125. diffcore.h
  126. dir-iterator.c
  127. dir-iterator.h
  128. dir.c
  129. dir.h
  130. editor.c
  131. entry.c
  132. environment.c
  133. ewah/
  134. exec-cmd.c
  135. exec-cmd.h
  136. fast-import.c
  137. fetch-negotiator.c
  138. fetch-negotiator.h
  139. fetch-pack.c
  140. fetch-pack.h
  141. fmt-merge-msg.h
  142. fsck.c
  143. fsck.h
  144. fsmonitor.c
  145. fsmonitor.h
  146. fuzz-commit-graph.c
  147. fuzz-pack-headers.c
  148. fuzz-pack-idx.c
  149. generate-cmdlist.sh
  150. gettext.c
  151. gettext.h
  152. git-add--interactive.perl
  153. git-archimport.perl
  154. git-bisect.sh
  155. git-compat-util.h
  156. git-cvsexportcommit.perl
  157. git-cvsimport.perl
  158. git-cvsserver.perl
  159. git-difftool--helper.sh
  160. git-filter-branch.sh
  161. git-gui/
  162. git-instaweb.sh
  163. git-legacy-stash.sh
  164. git-merge-octopus.sh
  165. git-merge-one-file.sh
  166. git-merge-resolve.sh
  167. git-mergetool--lib.sh
  168. git-mergetool.sh
  169. git-p4.py
  170. git-parse-remote.sh
  171. git-quiltimport.sh
  172. git-rebase--preserve-merges.sh
  173. git-request-pull.sh
  174. git-send-email.perl
  175. git-sh-i18n.sh
  176. git-sh-setup.sh
  177. git-submodule.sh
  178. git-svn.perl
  179. git-web--browse.sh
  180. git.c
  181. git.rc
  182. gitk-git/
  183. gitweb/
  184. gpg-interface.c
  185. gpg-interface.h
  186. graph.c
  187. graph.h
  188. grep.c
  189. grep.h
  190. hash.h
  191. hashmap.c
  192. hashmap.h
  193. help.c
  194. help.h
  195. hex.c
  196. http-backend.c
  197. http-fetch.c
  198. http-push.c
  199. http-walker.c
  200. http.c
  201. http.h
  202. ident.c
  203. imap-send.c
  204. interdiff.c
  205. interdiff.h
  206. iterator.h
  207. json-writer.c
  208. json-writer.h
  209. khash.h
  210. kwset.c
  211. kwset.h
  212. levenshtein.c
  213. levenshtein.h
  214. line-log.c
  215. line-log.h
  216. line-range.c
  217. line-range.h
  218. linear-assignment.c
  219. linear-assignment.h
  220. list-objects-filter-options.c
  221. list-objects-filter-options.h
  222. list-objects-filter.c
  223. list-objects-filter.h
  224. list-objects.c
  225. list-objects.h
  226. list.h
  227. ll-merge.c
  228. ll-merge.h
  229. lockfile.c
  230. lockfile.h
  231. log-tree.c
  232. log-tree.h
  233. ls-refs.c
  234. ls-refs.h
  235. mailinfo.c
  236. mailinfo.h
  237. mailmap.c
  238. mailmap.h
  239. match-trees.c
  240. mem-pool.c
  241. mem-pool.h
  242. merge-blobs.c
  243. merge-blobs.h
  244. merge-recursive.c
  245. merge-recursive.h
  246. merge.c
  247. mergesort.c
  248. mergesort.h
  249. mergetools/
  250. midx.c
  251. midx.h
  252. name-hash.c
  253. negotiator/
  254. notes-cache.c
  255. notes-cache.h
  256. notes-merge.c
  257. notes-merge.h
  258. notes-utils.c
  259. notes-utils.h
  260. notes.c
  261. notes.h
  262. object-store.h
  263. object.c
  264. object.h
  265. oidmap.c
  266. oidmap.h
  267. oidset.c
  268. oidset.h
  269. pack-bitmap-write.c
  270. pack-bitmap.c
  271. pack-bitmap.h
  272. pack-check.c
  273. pack-objects.c
  274. pack-objects.h
  275. pack-revindex.c
  276. pack-revindex.h
  277. pack-write.c
  278. pack.h
  279. packfile.c
  280. packfile.h
  281. pager.c
  282. parse-options-cb.c
  283. parse-options.c
  284. parse-options.h
  285. patch-delta.c
  286. patch-ids.c
  287. patch-ids.h
  288. path.c
  289. path.h
  290. pathspec.c
  291. pathspec.h
  292. perl/
  293. pkt-line.c
  294. pkt-line.h
  295. po/
  296. ppc/
  297. preload-index.c
  298. pretty.c
  299. pretty.h
  300. prio-queue.c
  301. prio-queue.h
  302. progress.c
  303. progress.h
  304. promisor-remote.c
  305. promisor-remote.h
  306. prompt.c
  307. prompt.h
  308. protocol.c
  309. protocol.h
  310. quote.c
  311. quote.h
  312. range-diff.c
  313. range-diff.h
  314. reachable.c
  315. reachable.h
  316. read-cache.c
  317. rebase-interactive.c
  318. rebase-interactive.h
  319. rebase.c
  320. rebase.h
  321. ref-filter.c
  322. ref-filter.h
  323. reflog-walk.c
  324. reflog-walk.h
  325. refs.c
  326. refs.h
  327. refs/
  328. refspec.c
  329. refspec.h
  330. remote-curl.c
  331. remote-testsvn.c
  332. remote.c
  333. remote.h
  334. replace-object.c
  335. replace-object.h
  336. repo-settings.c
  337. repository.c
  338. repository.h
  339. rerere.c
  340. rerere.h
  341. resolve-undo.c
  342. resolve-undo.h
  343. revision.c
  344. revision.h
  345. run-command.c
  346. run-command.h
  347. send-pack.c
  348. send-pack.h
  349. sequencer.c
  350. sequencer.h
  351. serve.c
  352. serve.h
  353. server-info.c
  354. setup.c
  355. sh-i18n--envsubst.c
  356. sha1-array.c
  357. sha1-array.h
  358. sha1-file.c
  359. sha1-lookup.c
  360. sha1-lookup.h
  361. sha1-name.c
  362. sha1dc/
  363. sha1dc_git.c
  364. sha1dc_git.h
  365. sha256/
  366. shallow.c
  367. shell.c
  368. shortlog.h
  369. sideband.c
  370. sideband.h
  371. sigchain.c
  372. sigchain.h
  373. split-index.c
  374. split-index.h
  375. stable-qsort.c
  376. strbuf.c
  377. strbuf.h
  378. streaming.c
  379. streaming.h
  380. string-list.c
  381. string-list.h
  382. sub-process.c
  383. sub-process.h
  384. submodule-config.c
  385. submodule-config.h
  386. submodule.c
  387. submodule.h
  388. symlinks.c
  389. t/
  390. tag.c
  391. tag.h
  392. tar.h
  393. tempfile.c
  394. tempfile.h
  395. templates/
  396. thread-utils.c
  397. thread-utils.h
  398. tmp-objdir.c
  399. tmp-objdir.h
  400. trace.c
  401. trace.h
  402. trace2.c
  403. trace2.h
  404. trace2/
  405. trailer.c
  406. trailer.h
  407. transport-helper.c
  408. transport-internal.h
  409. transport.c
  410. transport.h
  411. tree-diff.c
  412. tree-walk.c
  413. tree-walk.h
  414. tree.c
  415. tree.h
  416. unicode-width.h
  417. unimplemented.sh
  418. unix-socket.c
  419. unix-socket.h
  420. unpack-trees.c
  421. unpack-trees.h
  422. upload-pack.c
  423. upload-pack.h
  424. url.c
  425. url.h
  426. urlmatch.c
  427. urlmatch.h
  428. usage.c
  429. userdiff.c
  430. userdiff.h
  431. utf8.c
  432. utf8.h
  433. varint.c
  434. varint.h
  435. vcs-svn/
  436. version.c
  437. version.h
  438. versioncmp.c
  439. walker.c
  440. walker.h
  441. wildmatch.c
  442. wildmatch.h
  443. worktree.c
  444. worktree.h
  445. wrap-for-bin.sh
  446. wrapper.c
  447. write-or-die.c
  448. ws.c
  449. wt-status.c
  450. wt-status.h
  451. xdiff-interface.c
  452. xdiff-interface.h
  453. xdiff/
  454. zlib.c
README.md

Build Status

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-<commandname>.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://lore.kernel.org/git/, http://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks