[initramfs] Enhanced output format to run `ldconfig` if etc/ld.so.conf is present
[opensde-nopast.git] / bin / sde-list-changes
blob0245bf5519ba96b2d5d034a20672a8e035f3bcb7
1 #!/bin/sh
2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: bin/sde-list-changes
6 # Copyright (C) 2007 The OpenSDE Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- SDE-COPYRIGHT-NOTE-END ---
16 [ -n "$SDEROOT" ] ||
17 export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
19 . $SDEROOT/lib/libsde.in
21 list_usage() {
22 local progname=${0##*/}
23 cat <<EOT
24 Usage: $progname [-C <directory>] [--status] [LOCATIONS...]
25 EOT
28 shortopts='C:'
29 longopts='directory:,status'
30 options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
31 if [ $? -ne 0 ]; then
32 list_usage
33 exit -1
36 # load new arguments list
37 eval set -- "$options"
39 root=.
40 show_status=
42 while [ $# -gt 0 ]; do
43 case "$1" in
44 -C|--directory) root="$2"; shift ;;
45 --status) show_status=1 ;;
47 --) shift; break ;;
48 *) echo_abort 1 "Unknown argument '$1', aborting."
49 esac
50 shift
51 done
53 print_error() { echo "$@" >&2; }
55 # validate root directory, and jump there
56 [ -d "$root" ] || echo_abort 1 "$root: Invalid root directory."
57 cd "$root"
59 if [ -d '.git' ]; then
60 # git
63 # changed files
64 if [ -n "$show_status" ]; then
65 status=--name-status
66 else
67 status=--name-only
69 git-diff-index $status HEAD "$@" &
71 # untracked files
72 exclude=
73 [ ! -f '.gitignore' ] || exclude="-X .gitignore"
74 git-ls-files --others --directory $exclude "$@" | while read f; do
75 # be sure to not include sub-projects
76 if [ -d "$f/.git" -o -d "$f/.svn" ]; then
77 # skip sub-projects
78 continue
79 elif [ -n "$show_status" ]; then
80 echo "? $f"
81 else
82 echo "$f"
84 done
86 # wait for git-diff-index
87 wait
88 elif [ -d '.svn' ]; then
89 # svn
92 svn st --ignore-externals -- "$@" | while read l; do
93 s1="${l:0:1}" # ' ' A C D I M R X ? ! ~
94 s2="${l:1:1}" # ' ' C M
95 f="${l:7}"
97 # be sure to not include sub-projects
98 if [ -d "$f/.git" -o -d "$f/.svn" ]; then
99 # skip sub-projects
100 continue
101 elif [ -n "$show_status" ]; then
102 # the status is wanted
103 if [ "$s2" != ' ' ]; then
104 # changes on the properties go first
105 echo "$s2 $f"
106 elif [ "$s1" != ' ' ]; then
107 # and changes on the item, next
108 echo "$s1 $f"
109 fi # other changes, ignored
110 elif [ "$s1$s2" != ' ' ]; then
111 # only the filename is wanted, but when the change is interesting
112 echo "$f"
114 done
115 else
116 print_error "$root: Invalid Version Control System."