From c9e768bb77762765f739fffb5c09d0888f3de20e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Lindstr=C3=B6m?= Date: Fri, 23 May 2014 12:29:45 +0200 Subject: remote: repack packed-refs once when deleting multiple refs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When 'git remote rm' or 'git remote prune' were used in a repository with many refs, and needed to delete many remote-tracking refs, a lot of time was spent deleting those refs since for each deleted ref, repack_without_refs() was called to rewrite packed-refs without just that deleted ref. To avoid this, call repack_without_refs() first to repack without all the refs that will be deleted, before calling delete_ref() to delete each one completely. The call to repack_without_ref() in delete_ref() then becomes a no-op, since packed-refs already won't contain any of the deleted refs. Signed-off-by: Jens Lindström Signed-off-by: Junio C Hamano --- refs.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'refs.h') diff --git a/refs.h b/refs.h index 87a1a79ad6..f287c7aa65 100644 --- a/refs.h +++ b/refs.h @@ -132,6 +132,8 @@ extern void rollback_packed_refs(void); */ int pack_refs(unsigned int flags); +extern int repack_without_refs(const char **refnames, int n); + extern int ref_exists(const char *); /* -- cgit v1.2.3 From e6bea66db6229a0975ebba510a1d2827bf09cb7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Lindstr=C3=B6m?= Date: Fri, 23 May 2014 12:30:25 +0200 Subject: remote prune: optimize "dangling symref" check/warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When 'git remote prune' was used to delete many refs in a repository with many refs, a lot of time was spent checking for (now) dangling symbolic refs pointing to the deleted ref, since warn_dangling_symref() was once per deleted ref to check all other refs in the repository. Avoid this using the new warn_dangling_symrefs() function which makes one pass over all refs and checks for all the deleted refs in one go, after they have all been deleted. Signed-off-by: Jens Lindström Signed-off-by: Junio C Hamano --- refs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'refs.h') diff --git a/refs.h b/refs.h index f287c7aa65..1440acc06c 100644 --- a/refs.h +++ b/refs.h @@ -89,6 +89,7 @@ static inline const char *has_glob_specials(const char *pattern) extern int for_each_rawref(each_ref_fn, void *); extern void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname); +extern void warn_dangling_symrefs(FILE *fp, const char *msg_fmt, const struct string_list* refnames); /* * Lock the packed-refs file for writing. Flags is passed to -- cgit v1.2.3