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.

81 lines
1.7 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 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>] [LOCATIONS...]
  22. EOT
  23. }
  24. shortopts='C:'
  25. longopts='directory:'
  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. while [ $# -gt 0 ]; do
  35. case "$1" in
  36. -C|--directory) root="$2"; shift ;;
  37. --) shift; break ;;
  38. *) echo_abort 1 "Unknown argument '$1', aborting."
  39. esac
  40. shift
  41. done
  42. print_error() { echo "$@" >&2; }
  43. # validate root directory, and jump there
  44. [ -d "$root" ] || echo_abort 1 "$root: Invalid root directory."
  45. cd "$root"
  46. if [ -d '.git' ]; then
  47. # git
  48. #
  49. # changed files
  50. git-diff-index --name-only HEAD "$@" -M -C &
  51. # untracked files
  52. exclude=
  53. [ ! -f '.gitignore' ] || exclude="-X .gitignore"
  54. git-ls-files --others --directory $exclude "$@" | while read f; do
  55. # be sure to not include sub-projects
  56. if [ -d "$f/.git" -o -d "$f/.svn" ]; then
  57. # skip sub-projects
  58. continue
  59. else
  60. echo "$f"
  61. fi
  62. done
  63. # wait for git-diff-index
  64. wait
  65. else
  66. print_error "$root: Invalid Version Control System."
  67. fi