Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List files in a git repo #56

Open
hjwylde opened this issue Nov 9, 2015 · 1 comment
Open

List files in a git repo #56

hjwylde opened this issue Nov 9, 2015 · 1 comment
Labels

Comments

@hjwylde
Copy link

hjwylde commented Nov 9, 2015

Hey, I'm trying to list all files in a git repo but unsure how to accomplish to this. Ideally it would have similar behaviour to git ls-files.

I tried using:

+    tree <- lookupTree =<< createTree readIndex
+
+    files <- readFileTree' tree "." False

But that seemed to not list everything:

[9:02:00] hjwylde@poliwrath| issue/5> la                                                                                                                                                                                                                ~/git/hjwylde/git-fmt
total 64
drwxr-xr-x  15 hjwylde  staff   510  9 Nov 18:27 ./
drwxr-xr-x   4 hjwylde  staff   136  8 Nov 22:31 ../
drwxr-xr-x  13 hjwylde  staff   442 10 Nov 09:01 .git/
-rw-r--r--   1 hjwylde  staff    14  8 Nov 22:51 .gitignore
drwxr-xr-x   5 hjwylde  staff   170  8 Nov 23:43 .stack-work/
-rw-r--r--   1 hjwylde  staff   599  9 Nov 09:18 .travis.yml
-rw-r--r--   1 hjwylde  staff    39  8 Nov 22:51 CHANGELOG.md
-rw-r--r--   1 hjwylde  staff  1479  8 Nov 22:57 LICENSE
-rw-r--r--   1 hjwylde  staff  1847  8 Nov 22:55 README.md
-rw-r--r--   1 hjwylde  staff    46  8 Nov 22:57 Setup.hs
drwxr-xr-x   3 hjwylde  staff   102  8 Nov 23:44 app/
-rw-r--r--   1 hjwylde  staff  1768  9 Nov 18:55 git-fmt.cabal
drwxr-xr-x   3 hjwylde  staff   102  8 Nov 23:44 src/
-rw-r--r--   1 hjwylde  staff    37  9 Nov 17:42 stack.yaml
drwxr-xr-x   4 hjwylde  staff   136  9 Nov 09:18 test/
[9:02:05] hjwylde@poliwrath| issue/5> git fmt                                                                                                                                                                                                             ~/git/hjwylde/git-fmt
["git-fmt.cabal","CHANGELOG.md","Setup.hs","src/Git/Fmt/Options/Applicative/Parser.hs","test/app/Main.hs","README.md"]
[9:02:09] hjwylde@poliwrath| issue/5>

I'm probably misunderstanding how to use trees and the index, so any help is appreciated :).

@plredmond
Copy link
Contributor

At least in the current version, this works:

        Just ref <- Git.resolveReference "HEAD"
        commit <- Git.lookupCommit $ Tagged ref
        tree <- Git.lookupTree $ Git.commitTree commit
        xs <- Git.listTreeEntries True tree 
        return $ map fst xs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants