Fixed sde-update-tree to not error when there is no package/* because package/ is...
[opensde-nopast.git] / bin / sde-update-tree
blob9dec087961a7db288d0cd377b11b8f8e80a0431b
1 #!/bin/sh
2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 #
5 # Filename: bin/sde-update-tree
6 # Copyright (C) 2007 The OpenSDE Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
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 update_usage() {
22 local progname=${0##*/}
23 cat <<EOT
24 Usage: $progname [FILES...]
25 EOT
28 shortopts=''
29 longopts=''
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 GITSERVER=git://git.opensde.net
41 while [ $# -gt 0 ]; do
42 case "$1" in
44 --) shift; break ;;
45 *) echo_abort 1 "Unknown argument '$1', aborting."
46 esac
47 shift
48 done
50 # jump to the working tree's root
52 cd "$SDEROOT"
54 tree="${SDEROOT##*/}"
55 # hunt for the roots of the sub-working trees
57 for x in $( ls -1d . package package/* target/* 2> /dev/null ); do
58 if [ ! -d "$x" ]; then
59 case "$x" in
60 package)
61 echo -n "$tree/$x: "
62 git clone --quiet "$GITSERVER/opensde/$x-nopast.git" "$x"
65 echo "$tree/$x: missing" >&2
67 esac
68 elif [ -d "$x/.git" ]; then
69 cd "$x";
70 echo -n "$tree/$x: "
71 git fetch --quiet && git reset && git rebase origin
72 cd - > /dev/null
74 done