From b8ea6621be6b96e8f2b187b503e1d788bf25b9ae Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 23 Dec 2016 21:03:10 +0100 Subject: pq: Hardcode commit abbrev to 7 when exporting patches This avoids path hurn with git >= 2.11.0 Closes: #848354 --- gbp/git/repository.py | 9 +++++++-- gbp/scripts/common/pq.py | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 654ec0b9..cc916a60 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1710,7 +1710,7 @@ class GitRepository(object): self._git_command("apply", args) def diff(self, obj1, obj2=None, paths=None, stat=False, summary=False, - text=False, ignore_submodules=True): + text=False, ignore_submodules=True, abbrev=None): """ Diff two git repository objects @@ -1732,6 +1732,7 @@ class GitRepository(object): @rtype: C{str} """ options = GitArgs('-p', '--no-ext-diff') + config_args = GitArgs() if stat is True: options.add('--stat') elif stat: @@ -1743,7 +1744,11 @@ class GitRepository(object): options.add_true(obj2, obj2) if paths: options.add('--', paths) - output, stderr, ret = self._git_inout('diff', options.args) + if abbrev is not None: + config_args.add('core.abbrev=%d' % abbrev) + output, stderr, ret = self._git_inout('diff', + options.args, + config_args=config_args.args) if ret: raise GitRepositoryError("Git diff failed") return output diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py index fca4ec31..0225a97e 100644 --- a/gbp/scripts/common/pq.py +++ b/gbp/scripts/common/pq.py @@ -227,7 +227,7 @@ def format_patch(outdir, repo, commit_info, series, numbered=True, patch = None if paths: diff = repo.diff('%s^!' % commit_info['id'], paths=paths, stat=80, - summary=True, text=True) + summary=True, text=True, abbrev=7) patch = write_patch_file(filepath, commit_info, diff) if patch: series.append(patch) @@ -252,7 +252,7 @@ def format_diff(outdir, filename, repo, start, end, path_exclude_regex=None): paths = patch_path_filter(file_status, path_exclude_regex) if paths: diff = repo.diff(start, end, paths=paths, stat=80, summary=True, - text=True) + text=True, abbrev=7) return write_patch_file(filename, info, diff) return None -- cgit v1.2.3