setup_reflog_action: document the rules for using GIT_REFLOG_ACTION

The set_reflog_action helper (in git-sh-setup) is designed to be
used once at the very top of a program, like this in "git am", for
example:

	set_reflog_action am

The helper function sets the given string to GIT_REFLOG_ACTION only
when GIT_REFLOG_ACTION is not yet set.  Thanks to this, "git am",
when run as the top-level program, will use "am" in GIT_REFLOG_ACTION
and the reflog entries made by whatever it does will record the
updates of refs done by "am".

Because of the conditional assignment, when "git am" is run as a
subprogram (i.e. an implementation detail) of "git rebase" that
already sets GIT_REFLOG_ACTION to its own name, the call in "git am"
to the helper function at the beginning will *not* have any effect.

So "git rebase" can do this:

	set_reflog_action rebase
	... do its own preparation, like checking out "onto" commit
        ... decide to do "format-patch" to "am" pipeline
        	git format-patch --stdout >mbox
		git am mbox

and the reflog entries made inside "git am" invocation will say
"rebase", not "am".

Calls to "git" commands that update refs would use GIT_REFLOG_ACTION
to record who did that update.  Most such calls in scripted Porcelains
do not define custom reflog message and rely on GIT_REFLOG_ACTION to
contain its (or its caller's, when it is called as a subprogram) name.

If a scripted Porcelain wants to record a custom reflog message for
a single invocation of "git" command (e.g. when "git rebase" uses
"git checkout" to detach HEAD at the commit a series is to be
replayed on), it needs to set GIT_REFLOG_ACTION to the custom
message and export it while calling the "git" command, but such an
assignment must be restricted to that single "git" invocation and
should not be left behind to affect later codepath.

Document the rules to avoid future confusion.

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