Skip to content

Commit f293059

Browse files
committed
Stat instead of full diff in per-patch metadata
The per-patch metadata stored in the stack log branch (e.g. patches/p0 in the master.stgit branch) is only consumed by humans. As such, inserting the full diff of the patch into the metadata file is not required for stgit to function. In #44, attempting to refresh a very large patch affecting many files caused an apparent hang. Serializing a very large diff can consume an overwhelming amount of CPU an memory resources. It also puts a large magnitude of data in the stack log branch (and thus in the repo), which can be considered wasteful. Instead of the full diff, only the diff stat is inlined in the per-patch metadata. With this change, `stg refresh` has been measured to be an order of magnitude faster for very large patches. Signed-off-by: Peter Grayson <[email protected]>
1 parent aaccad1 commit f293059

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

stgit/lib/log.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ def patch_file(repo, cd):
136136
'',
137137
'---',
138138
'',
139+
'',
139140
]).encode('utf-8')
140-
diff = repo.diff_tree(cd.parent.data.tree, cd.tree, ['-M']).strip()
141+
diff = repo.diff_tree(cd.parent.data.tree, cd.tree, stat=True).strip()
141142
return repo.commit(BlobData(metadata + diff + b'\n'))
142143

143144

0 commit comments

Comments
 (0)