Fossil Forum
Post: [2.28] List files in repository?
Hello,
Neither Google, a search in the archives here, nor "fossil --help" helped: Does Fossil offer a command to list files in a repository without checking them out with "fossil open"?
d:\>fossil ls --repository myrepo.fossil
the "ls" command only works from within an open check-out
Cheers,
Do you want
- All files across all check-ins
- All files in a particular check-in
- All files across some subset of check-ins, such as on a particular branch
Any of the above is relatively easy to determine using an SQL query against the repository database. But I do not recall any built-in command that does that for you. It would probably be easy to add if you want to submit a patch. The hard part will be deciding on a good command syntax.
Hi, you need to provide a check-in, e.g. fossil ls -R myrepo.fossil -r tip. Please see fossil ls --help for more details.
Option 1, but others could be useful too.
Alternatively, it looks like I can simply run a SELECT against the Fossil DB:
d:\>sqlite3 myrepo.fossil
sqlite> select name from filename;
It's one of the commands I tried before asking, but no-go:
d:\>fossil ls --repository myrepo.fossil
the "ls" command only works from within an open check-out
the "ls" command only works from within an open check-out
Huh. i'll look into that limitation. Until then, you "could" use:
$ f- ls -R myrepo.fossil ; # libfossil's "fossil-minus" client
the "ls" command only works from within an open check-out
Huh. i'll look into that limitation.
Edit: it's not obvious looking at anything but the code, but it supports -R REPO but then requires -r because it otherwise cannot determine which version to show. In a checkout it shows whatever is checked out. The help will be tweaked to clarify that soon.
Until then, you "could" use:
$ f- ls -R myrepo.fossil ; # libfossil's "fossil-minus" client
Edit reply: [2.28] List files in repository?
I'm in no hurry. It's just nice to know what files live in a repo without having to do a check-out just fo find out.
I don't known why, but it seems that --repository doesn't give a very useful error message, while -R will tell you that you need to specify a version with -r <version>.
$ fossil ls -R fossil-scm.fossil
the -r is required in addition to -R
$ fossil ls -r trunk -R fossil-scm.fossil
editorconfig
.fossil-settings/binary-glob
.fossil-settings/clean-glob
.fossil-settings/crlf-glob
.fossil-settings/encoding-glob
.fossil-settings/ignore-glob
.project
.settings/org.eclipse.core.resources.prefs
.settings/org.eclipse.core.runtime.prefs
auto.def
autosetup/autosetup
...
...
I tested, even if error is misleading, --repository will works if you specify a version with -r.
Not so much a limitation as a requirement?
I look at it this way:
-
-R defaults to the repo linked to the current check-out, if there is one
-
-r also defaults to the current check-out, if there is one
So if there is no current check-out you have to specify both.
The key is that ls only makes sense in the context of a specific version.
Consider sequences of check-ins that do things like:
- add A; rename A B
Is that two files or one file with two names?
- add X; delete X; add X
Is that one X or two?
- have both of those on different branches, and put A instead of X
One, two, three, four?
It would be possible to default -r to something like tip if -R was specified - but maybe that's confusing. What if -R matches the current check-out, but the current check-out is something other than tip?
My bottom line: perhaps the error message needs tweaking: ls needs to know a version either by being in a check-out or from -r.
Thanks for the answer.
c:>fossil --help ls List all files in the current check-out. If PATHS is included, only the named files (or their children if directories) are shown. The ls command has grown by accretion, with multiple contributors, over many years, and is hence a little confused."
As a newbie, I suggest "ls" should 1) be able to list files in the repo (not just the checkout dir), and 2) withouth having to supply the -r option, in which case it should assume it's "current".
fossil ls d:\myrepo.fossil
Edit reply: [2.28] List files in repository?
Thanks for the answer.
c:>fossil --help ls List all files in the current check-out. If PATHS is included, only the named files (or their children if directories) are shown. The ls command has grown by accretion, with multiple contributors, over many years, and is hence a little confused."
As a newbie, I suggest "ls" should 1) be able to list files in the repo (not just the checkout dir), and 2) without having to supply the -r option, in which case it should assume it's "current".
fossil ls d:\myrepo.fossil
Additionally, although I don't know if it makes sense, it'd be nice if ls -v also included the full path to a file, eg.
\somedir\somesubdir\test.txt instead of just test.txt
2) withouth having to supply the -r option, in which case it should assume it's "current".
The problem is that "current" means nothing without a checkout. A checkout has a well-defined current version, and "current" is an alias for whatever that version is.
For a repo only, there's no such thing. We "could" assume that the value of the 'main-branch' setting were provided, defaulting to "trunk", but after having implemented exactly that in libfossil yesterday1 (in response to this thread), i'm convinced that that's more of a foot gun than not for one reason: its output is indeterminate. Calling it twice in a row might give you different lists, even from different branches.
That said: we "could" do that if people are generally agreed that that's the right thing to do.
Additionally, but I don't know if it makes sense, it'd be nice if ls -v also included the full path to a file
That's doable for checkouts but should probably be a separate flag to avoid breaking anyone's automated ls use. For a repo-only ls there is no path prefix to add.
Turns out the following does display the path to each file, in an open/closed repo:
fossil ls --tree -v
fossil close
fossil ls --tree -v -r trunk -R d:\myrepo.fossil