OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
2.6 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: bin/sde-list-changes
  6. # Copyright (C) 2007 - 2008 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 ---
  15. [ -n "$SDEROOT" ] ||
  16. export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
  17. . $SDEROOT/lib/libsde.in
  18. list_usage() {
  19. local progname=${0##*/}
  20. cat <<EOT
  21. Usage: $progname [-C <directory>] [--status] [LOCATIONS...]
  22. EOT
  23. }
  24. shortopts='C:'
  25. longopts='directory:,status'
  26. options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
  27. if [ $? -ne 0 ]; then
  28. list_usage
  29. exit -1
  30. fi
  31. # load new arguments list
  32. eval set -- "$options"
  33. root=.
  34. show_status=
  35. while [ $# -gt 0 ]; do
  36. case "$1" in
  37. -C|--directory) root="$2"; shift ;;
  38. --status) show_status=1 ;;
  39. --) shift; break ;;
  40. *) echo_abort 1 "Unknown argument '$1', aborting."
  41. esac
  42. shift
  43. done
  44. print_error() { echo "$@" >&2; }
  45. # validate root directory, and jump there
  46. [ -d "$root" ] || echo_abort 1 "$root: Invalid root directory."
  47. cd "$root"
  48. if [ -d '.git' ]; then
  49. # git
  50. #
  51. # changed files
  52. if [ -n "$show_status" ]; then
  53. status=--name-status
  54. else
  55. status=--name-only
  56. fi
  57. git diff-index $status HEAD "$@" &
  58. # untracked files
  59. exclude=
  60. [ ! -f '.gitignore' ] || exclude="-X .gitignore"
  61. git ls-files --others --directory $exclude "$@" | while read f; do
  62. # be sure to not include sub-projects
  63. if [ -d "$f/.git" -o -d "$f/.svn" ]; then
  64. # skip sub-projects
  65. continue
  66. elif [ -n "$show_status" ]; then
  67. echo "? $f"
  68. else
  69. echo "$f"
  70. fi
  71. done
  72. # wait for git-diff-index
  73. wait
  74. elif [ -d '.svn' ]; then
  75. # svn
  76. #
  77. svn st --ignore-externals -- "$@" | while read l; do
  78. s1="${l:0:1}" # ' ' A C D I M R X ? ! ~
  79. s2="${l:1:1}" # ' ' C M
  80. f="${l:7}"
  81. # be sure to not include sub-projects
  82. if [ -d "$f/.git" -o -d "$f/.svn" ]; then
  83. # skip sub-projects
  84. continue
  85. elif [ -n "$show_status" ]; then
  86. # the status is wanted
  87. if [ "$s2" != ' ' ]; then
  88. # changes on the properties go first
  89. echo "$s2 $f"
  90. elif [ "$s1" != ' ' ]; then
  91. # and changes on the item, next
  92. echo "$s1 $f"
  93. fi # other changes, ignored
  94. elif [ "$s1$s2" != ' ' ]; then
  95. # only the filename is wanted, but when the change is interesting
  96. echo "$f"
  97. fi
  98. done
  99. else
  100. print_error "$root: Invalid Version Control System."
  101. fi