fromupstream: Support --replace for gitfetch commands

If the user wants to replace a CL with something from upstream while
using the git://url#branch/hash or https://url#branch/hash syntax it
will fail because we don't rewind HEAD to HEAD~. Add the replace code
that we use everywhere else.

BUG=None --replace git://

Change-Id: I1c7bde18b636b07900e43576bebda5b4079e6d18
Commit-Queue: Stephen Boyd <>
Commit-Queue: Douglas Anderson <>
Tested-by: Stephen Boyd <>
Auto-Submit: Stephen Boyd <>
Reviewed-by: Douglas Anderson <>
diff --git a/contrib/ b/contrib/
index 433ee85..62d9771 100755
--- a/contrib/
+++ b/contrib/
@@ -311,6 +311,9 @@
     if args['tag'] is None:
         args['tag'] = 'FROMGIT: '
+    if args['replace']:
+        _git(['reset', '--hard', 'HEAD~1'])
     return _git_returncode(['cherry-pick', commit])
 def main(args):