git svn: handle errors and concurrent commits in dcommit

dcommit didn't handle errors returned by SVN and coped very
poorly with concurrent commits that appear in SVN repository
while dcommit was running. In both cases it left git repository
in inconsistent state: index (which was reset with `git reset
--mixed' after a successful commit to SVN) no longer matched the
checkouted tree, when the following commit failed or needed to be
rebased. See http://bugs.debian.org/676904 for examples.

This patch fixes the issues by:
- introducing error handler for dcommit. The handler will try
  to rebase or reset working tree before returning error to the
  end user. dcommit_rebase function was extracted out of cmd_dcommit
  to ensure consistency between cmd_dcommit and the error handler.
- calling `git reset --mixed' only once after all patches are
  successfully committed to SVN. This ensures index is not touched
  for most of the time of dcommit run.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2 files changed
tree: a66089e92d4b41fc6c31b2f64b9264f2839f0a4f
  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. configure.ac
  64. connect.c
  65. connected.c
  66. connected.h
  67. convert.c
  68. convert.h
  69. copy.c
  70. COPYING
  71. credential-cache--daemon.c
  72. credential-cache.c
  73. credential-store.c
  74. credential.c
  75. credential.h
  76. csum-file.c
  77. csum-file.h
  78. ctype.c
  79. daemon.c
  80. date.c
  81. decorate.c
  82. decorate.h
  83. delta.h
  84. diff-delta.c
  85. diff-lib.c
  86. diff-no-index.c
  87. diff.c
  88. diff.h
  89. diffcore-break.c
  90. diffcore-delta.c
  91. diffcore-order.c
  92. diffcore-pickaxe.c
  93. diffcore-rename.c
  94. diffcore.h
  95. dir.c
  96. dir.h
  97. editor.c
  98. entry.c
  99. environment.c
  100. exec_cmd.c
  101. exec_cmd.h
  102. fast-import.c
  103. fetch-pack.h
  104. fixup-builtins
  105. fmt-merge-msg.h
  106. fsck.c
  107. fsck.h
  108. generate-cmdlist.sh
  109. gettext.c
  110. gettext.h
  111. git-add--interactive.perl
  112. git-am.sh
  113. git-archimport.perl
  114. git-bisect.sh
  115. git-compat-util.h
  116. git-cvsexportcommit.perl
  117. git-cvsimport.perl
  118. git-cvsserver.perl
  119. git-difftool--helper.sh
  120. git-difftool.perl
  121. git-filter-branch.sh
  122. git-instaweb.sh
  123. git-lost-found.sh
  124. git-merge-octopus.sh
  125. git-merge-one-file.sh
  126. git-merge-resolve.sh
  127. git-mergetool--lib.sh
  128. git-mergetool.sh
  129. git-p4.py
  130. git-parse-remote.sh
  131. git-pull.sh
  132. git-quiltimport.sh
  133. git-rebase--am.sh
  134. git-rebase--interactive.sh
  135. git-rebase--merge.sh
  136. git-rebase.sh
  137. git-relink.perl
  138. git-remote-testgit.py
  139. git-repack.sh
  140. git-request-pull.sh
  141. git-send-email.perl
  142. git-sh-i18n.sh
  143. git-sh-setup.sh
  144. git-stash.sh
  145. git-submodule.sh
  146. git-svn.perl
  147. GIT-VERSION-GEN
  148. git-web--browse.sh
  149. git.c
  150. git.spec.in
  151. gpg-interface.c
  152. gpg-interface.h
  153. graph.c
  154. graph.h
  155. grep.c
  156. grep.h
  157. hash.c
  158. hash.h
  159. help.c
  160. help.h
  161. hex.c
  162. http-backend.c
  163. http-fetch.c
  164. http-push.c
  165. http-walker.c
  166. http.c
  167. http.h
  168. ident.c
  169. imap-send.c
  170. INSTALL
  171. kwset.c
  172. kwset.h
  173. levenshtein.c
  174. levenshtein.h
  175. LGPL-2.1
  176. list-objects.c
  177. list-objects.h
  178. ll-merge.c
  179. ll-merge.h
  180. lockfile.c
  181. log-tree.c
  182. log-tree.h
  183. mailmap.c
  184. mailmap.h
  185. Makefile
  186. match-trees.c
  187. merge-file.c
  188. merge-file.h
  189. merge-recursive.c
  190. merge-recursive.h
  191. mergesort.c
  192. mergesort.h
  193. name-hash.c
  194. notes-cache.c
  195. notes-cache.h
  196. notes-merge.c
  197. notes-merge.h
  198. notes.c
  199. notes.h
  200. object.c
  201. object.h
  202. pack-check.c
  203. pack-refs.c
  204. pack-refs.h
  205. pack-revindex.c
  206. pack-revindex.h
  207. pack-write.c
  208. pack.h
  209. pager.c
  210. parse-options-cb.c
  211. parse-options.c
  212. parse-options.h
  213. patch-delta.c
  214. patch-ids.c
  215. patch-ids.h
  216. path.c
  217. pkt-line.c
  218. pkt-line.h
  219. preload-index.c
  220. pretty.c
  221. progress.c
  222. progress.h
  223. prompt.c
  224. prompt.h
  225. quote.c
  226. quote.h
  227. reachable.c
  228. reachable.h
  229. read-cache.c
  230. README
  231. reflog-walk.c
  232. reflog-walk.h
  233. refs.c
  234. refs.h
  235. remote-curl.c
  236. remote.c
  237. remote.h
  238. replace_object.c
  239. rerere.c
  240. rerere.h
  241. resolve-undo.c
  242. resolve-undo.h
  243. revision.c
  244. revision.h
  245. run-command.c
  246. run-command.h
  247. send-pack.h
  248. sequencer.c
  249. sequencer.h
  250. server-info.c
  251. setup.c
  252. sh-i18n--envsubst.c
  253. sha1-array.c
  254. sha1-array.h
  255. sha1-lookup.c
  256. sha1-lookup.h
  257. sha1_file.c
  258. sha1_name.c
  259. shallow.c
  260. shell.c
  261. shortlog.h
  262. show-index.c
  263. sideband.c
  264. sideband.h
  265. sigchain.c
  266. sigchain.h
  267. strbuf.c
  268. strbuf.h
  269. streaming.c
  270. streaming.h
  271. string-list.c
  272. string-list.h
  273. submodule.c
  274. submodule.h
  275. symlinks.c
  276. tag.c
  277. tag.h
  278. tar.h
  279. test-chmtime.c
  280. test-ctype.c
  281. test-date.c
  282. test-delta.c
  283. test-dump-cache-tree.c
  284. test-genrandom.c
  285. test-index-version.c
  286. test-line-buffer.c
  287. test-match-trees.c
  288. test-mergesort.c
  289. test-mktemp.c
  290. test-parse-options.c
  291. test-path-utils.c
  292. test-revision-walking.c
  293. test-run-command.c
  294. test-scrap-cache-tree.c
  295. test-sha1.c
  296. test-sha1.sh
  297. test-sigchain.c
  298. test-subprocess.c
  299. test-svn-fe.c
  300. thread-utils.c
  301. thread-utils.h
  302. trace.c
  303. transport-helper.c
  304. transport.c
  305. transport.h
  306. tree-diff.c
  307. tree-walk.c
  308. tree-walk.h
  309. tree.c
  310. tree.h
  311. unimplemented.sh
  312. unix-socket.c
  313. unix-socket.h
  314. unpack-trees.c
  315. unpack-trees.h
  316. upload-pack.c
  317. url.c
  318. url.h
  319. usage.c
  320. userdiff.c
  321. userdiff.h
  322. utf8.c
  323. utf8.h
  324. varint.c
  325. varint.h
  326. version.c
  327. version.h
  328. walker.c
  329. walker.h
  330. wrap-for-bin.sh
  331. wrapper.c
  332. write_or_die.c
  333. ws.c
  334. wt-status.c
  335. wt-status.h
  336. xdiff-interface.c
  337. xdiff-interface.h
  338. zlib.c