cogito: understand permissions written as "100755"
[cogito.git] / cg-admin-ls
blob1731d2aace983c238607bdf6591a723b9d84484c
1 #!/usr/bin/env bash
3 # List contents of a particular tree in the repository
4 # Copyright (c) Petr Baudis, 2005
6 # Optionally takes a commit or tree ID as a parameter, defaulting to
7 # 'HEAD'.
9 # OPTIONS
10 # -------
11 # -r TREE_ID:: List contents of the given tree (you can use revisions here)
12 # List the contents of the given TREE_ID (which can be any tree
13 # id, but most usually you will just use a revision id here).
15 # OUTPUT FORMAT
16 # -------------
17 # Each line in the output has the following format:
19 # <mode> <type> <sha1> <name>
21 # where
23 # <mode>::
24 # The file permission information in octal format.
26 # <type>::
27 # The type can be the following: `blob` refers to files
28 # and `tree` refers to directories.
30 # <sha1>::
31 # The object ID.
33 # <name>::
34 # The file or directory name.
36 # Example line:
38 # 100644 blob c7dacd0ea28994e3c754ca4eadb2e08c011ee3d3 README
40 # Testsuite: TODO
42 USAGE="cg-admin-ls [-r TREE_ID] [PATH]"
43 _git_wc_unneeded=1
45 . "${COGITO_LIB}"cg-Xlib || exit 1
47 tree_id=
48 while optparse; do
49 if optparse -t=; then
50 # Deprecated as of 2006-11-17
51 warn "cg-admin-ls -t is deprecated, please use -r instead"
52 tree_id="$OPTARG"
53 elif optparse -r=; then
54 tree_id="$OPTARG"
55 else
56 optfail
58 done
60 id="$(cg-object-id -t "$tree_id")" || exit 1
62 git-ls-tree "$id" "${ARGS[@]}"