Improve error message on gclient sync failure

The new error message should clarify what we expect from user to do.

Also, git v2.42.0 introduced new advice on merge failure, which breaks
existing regex match. Instead, use search.

R=aravindvasudev@google.com

Fixed: 1475622
Change-Id: Ib4e60947aaa7994715cfae3260dd27f85f2380b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4823716
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
diff --git a/gclient_scm.py b/gclient_scm.py
index 0bbc940..5294cea 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -906,8 +906,8 @@
         merge_output = self._Capture(merge_args)
       except subprocess2.CalledProcessError as e:
         rebase_files = []
-        if re.match(b'fatal: Not possible to fast-forward, aborting.',
-                    e.stderr):
+        if re.search(b'fatal: Not possible to fast-forward, aborting.',
+                     e.stderr):
           if not printed_path:
             self.Print('_____ %s at %s' % (self.relpath, revision),
                        timestamp=False)
@@ -1375,8 +1375,9 @@
     except subprocess2.CalledProcessError:
       raise gclient_utils.Error('\n____ %s at %s\n'
                                 '\tYou have unstaged changes.\n'
-                                '\tPlease commit, stash, or reset.\n'
-                                  % (self.relpath, revision))
+                                '\tcd into %s, run git status to see changes,\n'
+                                '\tand commit, stash, or reset.\n' %
+                                (self.relpath, revision, self.relpath))
     try:
       scm.GIT.Capture(['diff-index', '--cached', '--name-status', '-r',
                        '--ignore-submodules', 'HEAD', '--'],
@@ -1384,8 +1385,9 @@
     except subprocess2.CalledProcessError:
       raise gclient_utils.Error('\n____ %s at %s\n'
                                 '\tYour index contains uncommitted changes\n'
-                                '\tPlease commit, stash, or reset.\n'
-                                  % (self.relpath, revision))
+                                '\tcd into %s, run git status to see changes,\n'
+                                '\tand commit, stash, or reset.\n' %
+                                (self.relpath, revision, self.relpath))
 
   def _CheckDetachedHead(self, revision, _options):
     # HEAD is detached. Make sure it is safe to move away from (i.e., it is