attr.c: read .gitattributes from index as well.

This makes .gitattributes files to be read from the index when
they are not checked out to the work tree.  This is in line with
the way we always allowed low-level tools to operate in sparsely
checked out work tree in a reasonable way.

It swaps the order of new file creation and converting the blob
to work tree representation; otherwise when we are in the middle
of checking out .gitattributes we would notice an empty but
unwritten .gitattributes file in the work tree and will ignore
the copy in the index.

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