Michal Marek 8f13a0
#! /bin/bash
Michal Marek 8f13a0
Michal Marek 0a417c
#############################################################################
Michal Marek 0a417c
# Copyright (c) 2004-2006,2008,2009 Novell, Inc.
Michal Marek 0a417c
# All Rights Reserved.
Michal Marek 8f13a0
#
Michal Marek 0a417c
# This program is free software; you can redistribute it and/or
Michal Marek 0a417c
# modify it under the terms of version 2 of the GNU General Public License as
Michal Marek 0a417c
# published by the Free Software Foundation.
Michal Marek 8f13a0
#
Michal Marek 0a417c
# This program is distributed in the hope that it will be useful,
Michal Marek 0a417c
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Michal Marek 0a417c
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
Michal Marek 0a417c
# GNU General Public License for more details.
Michal Marek 0a417c
#
Michal Marek 0a417c
# You should have received a copy of the GNU General Public License
Michal Marek 0a417c
# along with this program; if not, contact Novell, Inc.
Michal Marek 0a417c
#
Michal Marek 0a417c
# To contact Novell about this file by physical or electronic mail,
Michal Marek 0a417c
# you may find current contact information at www.novell.com
Michal Marek 0a417c
#############################################################################
Michal Marek 0a417c
 
Michal Marek b2d14f
# Check if all files referenced by series.conf are in GIT and vice versa.
Michal Marek b2d14f
# Also check that none of the referenced files is deleted in the working tree.
Michal Marek 0a417c
 
Michal Marek 8f13a0
Michal Marek 8f13a0
. ${0%/*}/wd-functions.sh
Michal Marek 8f13a0
Michal Marek 3952fd
if ! $using_git || test ! -e series.conf; then
Michal Marek 8f13a0
	exit 0
Michal Marek 8f13a0
fi
Michal Marek 8f13a0
Michal Marek 8f13a0
export LANG=C
Michal Marek 8f13a0
Michal Marek b2d14f
if test "$1" = "--committed"; then
Michal Marek b2d14f
	cmd="git ls-tree -r --name-only HEAD"
Michal Marek b2d14f
	# The kabi/ and sysctl/ directories are packaged as whole, so we need
Michal Marek b2d14f
	# to ensure that there are no untracked files in them
Michal Marek b2d14f
	kabi_untracked=$(git ls-files -d -o -m --directory --exclude-standard kabi/ sysctl/ | sort -u)
Michal Marek 8f13a0
else
Michal Marek b2d14f
	cmd="git ls-files --cached"
Michal Marek b2d14f
	kabi_untracked=
Michal Marek 8f13a0
fi
Michal Marek b2d14f
in_repo="$($cmd | grep '^patches\..*/' | sort -u)"
Michal Marek b2d14f
in_series="$(scripts/guards --list < series.conf | sort -u)"
Michal Marek b2d14f
deleted=$(git ls-files --deleted | grep '^patches\..*/' | sort -u)
Michal Marek b2d14f
in_repo=$(join -v1 <(echo "$in_repo") <(echo "$deleted"))
Michal Marek b2d14f
Michal Marek b2d14f
series_missing=$(join -v1 <(echo "$in_repo") <(echo "$in_series"))
Michal Marek b2d14f
repo_missing=$(join -v2 <(echo "$in_repo") <(echo "$in_series"))
Michal Marek b2d14f
Michal Marek b2d14f
status=0
Michal Marek b2d14f
if test -n "$series_missing"; then
Michal Marek b2d14f
	printf 'Not in series.conf: %s\n' $series_missing >&2
Michal Marek b2d14f
	status=1
Michal Marek b2d14f
fi
Michal Marek b2d14f
if test -n "$repo_missing$kabi_untracked"; then
Michal Marek b2d14f
	printf 'Not in GIT: %s\n' $repo_missing $kabi_untracked >&2
Michal Marek b2d14f
	status=1
Michal Marek 8f13a0
fi
Borislav Petkov cdbf42
Michal Marek b2d14f
exit $status