GitRepository: Fix diff_status() for renames and copies 45/89945/2
authorJiankang Fan <jiankang.fan@samsung.com>
Wed, 28 Sep 2016 02:26:09 +0000 (10:26 +0800)
committerSoonKyu Park <sk7.park@samsung.com>
Mon, 26 Dec 2016 13:20:35 +0000 (22:20 +0900)
When file has been renamed or copied git places two filepaths
in a status line.

Previously, we concatenated them (with additional \x00)
and put into a single record in results dictionary.
This leads to records like:
    'libusbg.pc.in\x00libusbgx.pc.in'
and result in a exception while trying to invoke git diff
on such record:

error: Traceback (most recent call last):
File "/usr/bin/gbs", line 628, in <module>
     sys.exit(main(sys.argv))
File "/usr/bin/gbs", line 622, in main
     return module.main(args)
File "/usr/lib/pymodules/python2.7/gitbuildsys/cmd_export.py", line 302, in main
     export_sources(repo, commit, export_dir, main_spec, args)
File "/usr/lib/pymodules/python2.7/gitbuildsys/cmd_export.py", line 222, in export_sources
     ret = gbp_build(gbp_args)
File "/usr/lib/python2.7/dist-packages/gbp/scripts/buildpackage_rpm.py", line 588, in main
     export_patches(repo, spec, patch_tree, options)
File "/usr/lib/python2.7/dist-packages/gbp/scripts/buildpackage_rpm.py", line 283, in export_patches
     update_patch_series(repo, spec, upstream_tree, export_treeish, options)
File "/usr/lib/python2.7/dist-packages/gbp/scripts/pq_rpm.py", line 211, in update_patch_series
     spec.specdir, options)
File "/usr/lib/python2.7/dist-packages/gbp/scripts/pq_rpm.py", line 144, in generate_patches
     options.patch_export_ignore_path)
File "/usr/lib/python2.7/dist-packages/gbp/scripts/common/pq.py", line 290, in format_diff
     text=True)
File "/usr/lib/python2.7/dist-packages/gbp/git/repository.py", line 1813, in diff
     output, stderr, ret = self._git_inout('diff', options.args)
File "/usr/lib/python2.7/dist-packages/gbp/git/repository.py", line 187, in _git_inout
     capture_stdout):
File "/usr/lib/python2.7/dist-packages/gbp/git/repository.py", line 245, in __git_inout
     cwd=cwd)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
     errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1252, in _execute_child
     raise child_exception
TypeError: execv() arg 2 must contain only strings

To fix this let's add each filepath as a seprate record as git diff
command will understand our intentions perfectly.

Change-Id: I4955bf341147d84880fb2aac49b19a290f1465e5
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
gbp/git/repository.py

index 20251a00386936ec738d891703c94fc9d69c6c28..d7eb271ea26a3e8eee3f7ccdee69da35be9a7149 100644 (file)
@@ -1837,7 +1837,8 @@ class GitRepository(object):
             filepath = elements.pop(0)
             # Expect to have two filenames for renames and copies
             if status in ['R', 'C']:
-                filepath = elements.pop(0) + '\x00' + filepath
+                result[status].append(filepath)
+                filepath = elements.pop(0)
             result[status].append(filepath)
 
         return result