git-apply: require -p<n> when working in a subdirectory.

git-apply running inside a subdirectory, with or without --index,
used to always assume that the patch is formatted in such a way
to apply with -p1 from the toplevel, but it is more useful and
consistent with the use of "GNU patch -p1" if it defaulted to
assume that its input is meant to apply at the level it is
invoked in.

This changes the behaviour.  It used to be that the patch
generated this way would apply without any trick:

	edit Documentation/Makefile
	git diff >patch.file
	cd Documentation
	git apply ../patch.file

You need to give an explicit -p2 to git-apply now.  On the other
hand, if you got a patch from somebody else who did not follow
"patch is to apply from the top with -p1" convention, the input
patch would start with:

	diff -u Makefile.old Makefile
	--- Makefile.old
	+++ Makefile

and in such a case, you can apply it with:

	git apply -p0 patch.file

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