[patch 03/11] stg diff / files: don't update directory cache unless needed
From: Paolo 'Blaisorblade' Giarrusso <hidden>
Date: 2016-06-15 22:42:06
Subsystem:
the rest · Maintainer:
Linus Torvalds
Do git-update-cache only when diffing with the working tree, not otherwise. Spending something like 1min for a stg files is bad - yes, my laptop was really busy and the Linux tree was probably cache-cold, but that's just not needed. Also, in diffstat we currently do it both by hand and by calling git.diff. And in files there's no need at all for that - even the comments says that "files" has only to do with committed changes. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <redacted> --- stgit/git.py | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/stgit/git.py b/stgit/git.py
--- a/stgit/git.py
+++ b/stgit/git.py@@ -376,11 +376,11 @@ def status(files = [], modified = False, def diff(files = [], rev1 = 'HEAD', rev2 = None, out_fd = None): """Show the diff between rev1 and rev2 """ - os.system('git-update-cache --refresh > /dev/null') if rev2: diff_str = _output(['git-diff-tree', '-p', rev1, rev2] + files) else: + os.system('git-update-cache --refresh > /dev/null') diff_str = _output(['git-diff-cache', '-p', rev1] + files) if out_fd:
@@ -392,7 +392,6 @@ def diffstat(files = [], rev1 = 'HEAD', """Return the diffstat between rev1 and rev2 """ - os.system('git-update-cache --refresh > /dev/null') p=popen2.Popen3('git-apply --stat') diff(files, rev1, rev2, p.tochild) p.tochild.close()
@@ -404,7 +403,6 @@ def diffstat(files = [], rev1 = 'HEAD', def files(rev1, rev2): """Return the files modified between rev1 and rev2 """ - os.system('git-update-cache --refresh > /dev/null') str = '' for line in _output_lines('git-diff-tree -r %s %s' % (rev1, rev2)):