diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 6fa394a4959edd94e572df183ee823cf68a7742c..6921135b0f8896fb216b7a3c3f0b7d198de91199 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -404,6 +404,8 @@ def get_matched_defconfigs(defconfigs_file):
         line = line.strip()
         if not line:
             continue # skip blank lines silently
+        if ' ' in line:
+            line = line.split(' ')[0]  # handle 'git log' input
         matched = get_matched_defconfig(line)
         if not matched:
             print >> sys.stderr, "warning: %s:%d: no defconfig matched '%s'" % \