Blob Blame History Raw
#! /bin/bash

#############################################################################
# Copyright (c) 2004-2006,2008,2009 Novell, Inc.
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail,
# you may find current contact information at www.novell.com
#############################################################################
 
# Check if all files referenced by series.conf are in GIT and vice versa.
# Also check that none of the referenced files is deleted in the working tree.
 

. ${0%/*}/wd-functions.sh

if ! $using_git || test ! -e series.conf; then
	exit 0
fi

export LANG=C

if test "$1" = "--committed"; then
	cmd="git ls-tree -r --name-only HEAD"
	# The kabi/ and sysctl/ directories are packaged as whole, so we need
	# to ensure that there are no untracked files in them
	kabi_untracked=$(git ls-files -d -o -m --directory --exclude-standard kabi/ sysctl/ | sort -u)
else
	cmd="git ls-files --cached"
	kabi_untracked=
fi
in_repo="$($cmd | grep '^patches\..*/' | sort -u)"
in_series="$(scripts/guards --list < series.conf | sort -u)"
deleted=$(git ls-files --deleted | grep '^patches\..*/' | sort -u)
in_repo=$(join -v1 <(echo "$in_repo") <(echo "$deleted"))

series_missing=$(join -v1 <(echo "$in_repo") <(echo "$in_series"))
repo_missing=$(join -v2 <(echo "$in_repo") <(echo "$in_series"))

status=0
if test -n "$series_missing"; then
	printf 'Not in series.conf: %s\n' $series_missing >&2
	status=1
fi
if test -n "$repo_missing$kabi_untracked"; then
	printf 'Not in GIT: %s\n' $repo_missing $kabi_untracked >&2
	status=1
fi

exit $status