Specify log format to avoid malfunctions and unexpected errors. (#305)
authorYoichi NAKAYAMA <yoichi.nakayama@gmail.com>
Mon, 11 Apr 2022 15:57:19 +0000 (00:57 +0900)
committerGitHub <noreply@github.com>
Mon, 11 Apr 2022 15:57:19 +0000 (08:57 -0700)
Solve the following problems:
* mishandling of commit message lines similar to committer lines
* UnicodeDecodeError with commit messages that cannot be interpreted
  as utf-8

support/git-set-file-times

index 24b3fde54875af66b4db23b331037826559ae01d..e06f07370abeaba0d56a0ecb557c239b282a98c8 100755 (executable)
@@ -38,7 +38,7 @@ def main():
                 print_line(fn, mtime, mtime)
             ls.discard(fn)
 
-    cmd = git + 'log -r --name-only --no-color --pretty=raw --no-renames -z'.split()
+    cmd = git + 'log -r --name-only --format=%x00commit%x20%H%n%x00commit_time%x20%ct%n --no-renames -z'.split()
     if args.tree:
         cmd.append(args.tree)
     cmd += ['--'] + args.files
@@ -46,7 +46,7 @@ def main():
     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding='utf-8')
     for line in proc.stdout:
         line = line.strip()
-        m = re.match(r'^committer .*? (\d+) [-+]\d+$', line)
+        m = re.match(r'^\0commit_time (\d+)$', line)
         if m:
             commit_time = int(m[1])
         elif NULL_COMMIT_RE.search(line):