Skip to content

Instantly share code, notes, and snippets.

@bartman
Created February 12, 2010 15:21
Show Gist options
  • Save bartman/302639 to your computer and use it in GitHub Desktop.
Save bartman/302639 to your computer and use it in GitHub Desktop.
#!/usr/bin/make -f
# find all git repos and run gc in them
# options:
# DEPTH=<number> pass to find
# DIR=<path> where to look
# NICE=<lvl> nice level (-20..19)
# IONICE=<lvl> ionice level (0..7)
#
# Why a makefile? so you can pass it a -j
FIND_CMD = find ${DIR} $(if ${DEPTH},-maxdepth ${DEPTH}) -type d -name .git | sed -e 's,^\./,,'
GIT_DIRS = $(shell ${FIND_CMD})
ACT_PREFIX = do-gc-in-
GC_ACTIONS = $(foreach dir,${GIT_DIRS},${ACT_PREFIX}${dir})
DIR ?= .
DEPTH ?=
NICE ?= 20
IONICE ?= 7
NICE_CMD = $(if ${NICE},nice -n${NICE}) $(if ${IONICE},ionice -n ${IONICE})
.PHONY: all
all: ${GC_ACTIONS}
.PHONY: ${GIT_DIRS}
${GC_ACTIONS}: ${ACT_PREFIX}%: %
### Cleaning $<
test -f $</HEAD && ${NICE_CMD} git --git-dir $< gc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment