#!/bin/sh
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: bin/sde-list-changes
|
|
# Copyright (C) 2007 - 2008 The OpenSDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
|
# GNU General Public License can be found in the file COPYING.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
[ -n "$SDEROOT" ] ||
|
|
export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
|
|
|
|
. $SDEROOT/lib/libsde.in
|
|
|
|
list_usage() {
|
|
local progname=${0##*/}
|
|
cat <<EOT
|
|
Usage: $progname [-C <directory>] [--status] [LOCATIONS...]
|
|
EOT
|
|
}
|
|
|
|
shortopts='C:'
|
|
longopts='directory:,status'
|
|
options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
|
|
if [ $? -ne 0 ]; then
|
|
list_usage
|
|
exit -1
|
|
fi
|
|
|
|
# load new arguments list
|
|
eval set -- "$options"
|
|
|
|
root=.
|
|
show_status=
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
-C|--directory) root="$2"; shift ;;
|
|
--status) show_status=1 ;;
|
|
|
|
--) shift; break ;;
|
|
*) echo_abort 1 "Unknown argument '$1', aborting."
|
|
esac
|
|
shift
|
|
done
|
|
|
|
print_error() { echo "$@" >&2; }
|
|
|
|
# validate root directory, and jump there
|
|
[ -d "$root" ] || echo_abort 1 "$root: Invalid root directory."
|
|
cd "$root"
|
|
|
|
if [ -d '.git' ]; then
|
|
# git
|
|
#
|
|
|
|
# changed files
|
|
if [ -n "$show_status" ]; then
|
|
status=--name-status
|
|
else
|
|
status=--name-only
|
|
fi
|
|
git diff-index $status HEAD "$@" &
|
|
|
|
# untracked files
|
|
exclude=
|
|
[ ! -f '.gitignore' ] || exclude="-X .gitignore"
|
|
git ls-files --others --directory $exclude "$@" | while read f; do
|
|
# be sure to not include sub-projects
|
|
if [ -d "$f/.git" -o -d "$f/.svn" ]; then
|
|
# skip sub-projects
|
|
continue
|
|
elif [ -n "$show_status" ]; then
|
|
echo "? $f"
|
|
else
|
|
echo "$f"
|
|
fi
|
|
done
|
|
|
|
# wait for git-diff-index
|
|
wait
|
|
elif [ -d '.svn' ]; then
|
|
# svn
|
|
#
|
|
|
|
svn st --ignore-externals -- "$@" | while read l; do
|
|
s1="${l:0:1}" # ' ' A C D I M R X ? ! ~
|
|
s2="${l:1:1}" # ' ' C M
|
|
f="${l:7}"
|
|
|
|
# be sure to not include sub-projects
|
|
if [ -d "$f/.git" -o -d "$f/.svn" ]; then
|
|
# skip sub-projects
|
|
continue
|
|
elif [ -n "$show_status" ]; then
|
|
# the status is wanted
|
|
if [ "$s2" != ' ' ]; then
|
|
# changes on the properties go first
|
|
echo "$s2 $f"
|
|
elif [ "$s1" != ' ' ]; then
|
|
# and changes on the item, next
|
|
echo "$s1 $f"
|
|
fi # other changes, ignored
|
|
elif [ "$s1$s2" != ' ' ]; then
|
|
# only the filename is wanted, but when the change is interesting
|
|
echo "$f"
|
|
fi
|
|
done
|
|
else
|
|
print_error "$root: Invalid Version Control System."
|
|
fi
|