]> git.ipfire.org Git - thirdparty/git.git/blame - git-prune-script
The test of the basic diff functionality
[thirdparty/git.git] / git-prune-script
CommitLineData
839a7a06 1#!/bin/sh
ae7c0c92
JH
2dryrun=
3while case "$#" in 0) break ;; esac
4do
5 case "$1" in
6 -n) dryrun=echo ;;
7 --) break ;;
8 -*) echo >&2 "usage: git-prune-script [ -n ] [ heads... ]"; exit 1 ;;
9 *) break ;;
10 esac
11 shift;
12done
13
8ac069ac
JH
14: ${GIT_DIR=.git}
15: ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
16
ae7c0c92
JH
17# Defaulting to include .git/refs/*/* may be debatable from the
18# purist POV but power users can always give explicit parameters
19# to the script anyway.
20
21case "$#" in
220)
23 x_40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
24 x_40="$x_40$x_40$x_40$x_40$x_40$x_40$x_40$x_40"
8ac069ac
JH
25 set x $(sed -ne "/^$x_40\$/p" \
26 "$GIT_DIR"/HEAD "$GIT_DIR"/refs/*/* /dev/null 2>/dev/null)
ae7c0c92
JH
27 shift ;;
28esac
29
30git-fsck-cache --cache --unreachable "$@" |
31sed -ne '/unreachable /{
32 s/unreachable [^ ][^ ]* //
33 s|\(..\)|\1/|p
34}' | {
8ac069ac 35 cd "$GIT_OBJECT_DIRECTORY" || exit
ae7c0c92
JH
36 xargs -r $dryrun rm -f
37}
8ac069ac 38