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.

45 lines
766 B

  1. #!/bin/sh
  2. COLOUR=auto
  3. case "${1:-}" in
  4. --color|--colour) COLOUR=true; shift ;;
  5. --color=no|--colour=no) COLOUR=false; shift ;;
  6. esac
  7. if [ "$COLOUR" = auto -a -t 1 ]; then
  8. COLOUR=true
  9. elif [ "$COLOUR" != true ]; then
  10. COLOUR=false
  11. fi
  12. if $COLOUR; then
  13. COLOUR="$(printf '\x1b[32m')"
  14. NORMAL="$(printf '\x1b[39;49m')"
  15. else
  16. COLOUR=
  17. NORMAL=
  18. fi
  19. while [ "$PWD" != / -a ! -s "$PWD/.repo/manifest.xml" ]; do
  20. cd ..
  21. done
  22. if [ ! -s "$PWD/.repo/manifest.xml" ]; then
  23. echo "not in a repo tree" >&2
  24. exit 1
  25. fi
  26. GIT="`which git`"
  27. git() {
  28. local dir="$1"
  29. shift
  30. "$GIT" --git-dir "$dir/.git" --work-tree "$dir" "$@"
  31. }
  32. repo list -p | while read p; do
  33. if [ $# -gt 0 ]; then
  34. git "$p" ls-files | grep "$@"
  35. else
  36. git "$p" ls-files
  37. fi | sed -e "s|^|$COLOUR$p$NORMAL/|"
  38. done