Commit Graph

1106 Commits

Author SHA1 Message Date
Martin von Zweigbergk
c14e138698 cli: expand ~ in core.excludesFile, don't crash when missing
I thought that `std::fs::canonicalize()` expanded "~", but it doesn't
seem to do that, which caused #131. Git seems to do the expansion
itself, so we probably also should. More importantly
`std::fs::canonicalize()` crashes when the file doesn't exist. The
manual expansion we do now does not.

Closes #131.
2022-03-13 12:40:37 -07:00
Martin von Zweigbergk
43e1f42c63 github: include version number in issue template again
Now that we have a changelog and I plan to do releases once in a
while, it makes sense again to have the version number in the issue
template.
2022-03-12 23:34:37 -08:00
Martin von Zweigbergk
1777d85550 release: add a changelog 2022-03-12 23:03:01 -08:00
Martin von Zweigbergk
8f4949d2e4 release: bump version to 0.3.0
There's been *a lot* of changes since 0.2.0 almost a year ago. With
the attention the project has gotten recently, I feel like I should
cut a new release and start keeping a changelog. So let's start by
bumping the version to 0.3.0.
2022-03-12 23:03:01 -08:00
Martin von Zweigbergk
de5d0d44a7 github: clarify a few things in the issue template 2022-03-12 22:10:18 -08:00
Martin von Zweigbergk
bf21e65c5d github: attempt to build release using rust-build/rust-build.action (#73)
I just copied from the examples on
https://github.com/rust-build/rust-build.action. Let's see if it
works.
2022-03-12 22:10:18 -08:00
Martin von Zweigbergk
326654952e cli: respect Git's core.excludesFile config (#87)
It probably doesn't make sense to respect Git's `core.excludesFile`
config when not running in a Git-backed repo, but we also already
respect `.gitignore` files in the working copy regardless of backend,
so at least it's consistent with that. We can revisit it when the
native backend becomes a reasonable choice.

Closes #87.
2022-03-12 10:48:06 -08:00
Martin von Zweigbergk
8336c489fa cli: respect .git/info/exclude if in Git-backed repo (#65)
Closes #65.
2022-03-12 10:48:06 -08:00
Martin von Zweigbergk
d56ae79d3f working_copy: let caller pass in base Git ignores (#65, #87)
The library crate shouldn't look up the user's `$HOME` directory
(maybe the library is used by a server process), so let's have the
caller pass it into the library crate instead.
2022-03-12 10:48:06 -08:00
Martin von Zweigbergk
2291bfffce cli: add a WorkspaceCommandHelper::edit_diff() proxy (#65, #87)
I'm about to make callers pass in "base" Git ignores when writing a
tree from the working copy. `edit_diff()` will then need to pass
that. It'll be easier to do that if we have a proxy on
`WorkspaceCommandHelper`.
2022-03-12 10:48:06 -08:00
Martin von Zweigbergk
51da2a2dc1 gitignore: move function for chaining .gitignore to central place (#65, #87)
I want to be able to reuse the code for chaining two `.gitignore`
files outside of `working_copy.rs`.
2022-03-12 10:48:06 -08:00
Martin von Zweigbergk
e7a7cb8ea5 gitignores: remove error type that's never instantiated 2022-03-12 10:48:06 -08:00
Martin von Zweigbergk
124a064169 tests: set RUST_BACKTRACE=1 in e2e tests
This should be very useful when tests fail because of a panic.
2022-03-12 10:48:06 -08:00
Martin von Zweigbergk
cdc7a0c242 cli: when pushing all branches (the default), skip open commit
Open commits are work-in-progress and `jj git push --branch <name>`
therefore errors out if the branch points to an open commit. However,
we don't do the same check if you run `jj git push` to push all
branches. This patch introduces such a check. Rather than error out,
we skip such branches instead.

I didn't make it check for open commits in ancestors. It's quite
unusual (at least in my workflow) to have a closed commit on top of an
open one. We can revisit if users get surprised by it.
2022-03-12 10:46:58 -08:00
Martin von Zweigbergk
6902c703b3 docs: start describing differences compared to Git
I've surely missed a lot here, but one has to start somewhere.
2022-03-11 22:47:36 -08:00
Martin von Zweigbergk
05734138e8 docs: add cherry-picking to Git-comparison table 2022-03-11 22:47:36 -08:00
Martin von Zweigbergk
f86c3b488b docs: add jj move to Git-comparison table 2022-03-11 22:47:36 -08:00
Martin von Zweigbergk
9a189fea91 docs: list supported and unsupported Git features 2022-03-11 22:47:36 -08:00
Martin von Zweigbergk
6fabf89529 diff: add helpers for finding index for non-base side
We have some repeated code doing `wrapping_add()`, so let's add
helpers to reduce repetition.
2022-03-10 22:00:45 -08:00
Martin von Zweigbergk
16c68ab821 cleanup: fix a Clippy warning about an unnecessary to_path_buf() 2022-03-10 22:00:45 -08:00
Martin von Zweigbergk
f6ba34f3c3 cli: when initializing repo backed by Git repo, check out Git's HEAD
Closes #102.
2022-03-10 12:53:40 -08:00
Martin von Zweigbergk
d475710d29 cli: print relative path to newly initialized repo
It's easier to test relative paths (no need to strip some prefix) and
it seems more user-friendly as well.
2022-03-10 12:53:40 -08:00
Martin von Zweigbergk
ea05f8f1e5 cli: prevent pushing commits with conflicts
It rarely makes sense to push commits with conflicts to a remote Git
repo (which is the only kind of remote we support so far), so let's
just error out instead of pushing a commit that others pulling from
the remote probably can't make sense of.

I've only added a simple test for the error case for now. `libgit2`
doesn't support pushing to a local repo, so it's harder to test the
success case. I suppose we'll have to have the regular `git` binary
running local servers in test eventually.

Closes #60.
2022-03-10 12:38:07 -08:00
Martin von Zweigbergk
a9eebe779e tests: set user and email in e2e tests
We don't display the user and email yet, so the only visible effect
this has on the tests is that some hashes change.
2022-03-10 12:38:07 -08:00
Martin von Zweigbergk
9702684a4d settings: read and parse timestamp from config only once 2022-03-10 12:38:07 -08:00
Martin von Zweigbergk
18861c67c3 settings: allow setting author/commit timestamp via config
I'm not sure it'll be useful, but it seems nice to be able to set the
same values via config or environment variables. Perhap we should
simply use `config::Environment` to make everything configurable via
environment variables, but I'll leave that for later.
2022-03-10 12:38:07 -08:00
Martin von Zweigbergk
e0115d2af7 commit_builder: move signature() to UserSettings
It's useful to have `signature()` live on `UserSettings` because that
will let us cache information (such as the timestamp) in the
instance. It will also make it easier to have the timestamp settable
via regular config files. I don't know that that will be useful, but
it seems like a clean way of implementing it if we can have
environment variables simply as an overlay of configs.
2022-03-10 12:38:07 -08:00
Martin von Zweigbergk
fc1731a180 diff: switch from BTreeMap to sorted Vec for unchanged ranges
We don't really need a BTreeMap for keeping the unchanged ranges. The
only place it helps a bit is when refining a diff because we may then
insert some more unchanged ranges in the list. I think there has to be
very many unchanged ranges for that to matter, however. This patch
therefore replace the BTreeMap by a sorted Vec. `cargo bench` says
that a few tests got ~20% faster.

I'm looking into this code now because I'm thinking of copying some of
it for the "partial conflict resolution" tool I'm working on for
Mercurial.
2022-03-10 00:33:17 -08:00
Martin von Zweigbergk
934564bf8d diff: also sort base ranges by end point
I wanted to replace the BTreeMap by a Vec and noticed that we actually
sometimes end up having a `0..n` range followed by a `0..0` after
refinement. We currently compare those two as equal because I had not
thought that we could end up attempting to add two ranges with the
same start point. When trying to insert the second range (`0..0`), the
BTreeMap will keep the existing key (`0..n`) and replace the
value. That's probably works, but it's clearly not what I
intended. Let's fix by sorting by the end point if the start point is
equal. This actually improves some benchmarks by a few percent (maybe
because the subsequent compaction can then remove the `0..0` range).
2022-03-10 00:33:17 -08:00
Martin von Zweigbergk
b64ee147ae docs: add technical doc about a conflict design
We used to have documention about how conflicts are implemented, but I
removed that a long time ago when I rewrote the README to target users
rather than VCS hackers. Let's have a doc for the VCS hackers (and
curious users) as well, though.
2022-03-09 21:08:41 -08:00
Waleed Khan
625f15cb3e gitignore: fix typo 2022-03-09 20:03:00 -08:00
Martin von Zweigbergk
c3b5c5e72a gitignore: add *.pending-snap created by the insta crate 2022-03-09 13:21:20 -08:00
Martin von Zweigbergk
382be623b8 docs: correct a mention about getting long vs. short help
I haven't checked, but I think `jj help git push` used to give the
short form with `clap` 2. With `clap` 3, it's definitely the long form
anyway.
2022-03-09 07:48:31 -08:00
Martin von Zweigbergk
630f8069d0 docs: explain that the there's no reason to use the native backend
A few people in different forums asked if there's any reason to use
the native backend and what the reason for its existance is, so let's
document that.
2022-03-09 07:48:31 -08:00
Martin von Zweigbergk
32e22831fc github: make CI check formatting
I've forgotten to run `rustfmt` many times (most recently in
5721436558), so let's have CI check for it.
2022-03-07 22:16:57 -08:00
Martin von Zweigbergk
3a306e6a23 cleanup: fix formatting (missed in 5721436558) 2022-03-07 22:16:57 -08:00
Martin von Zweigbergk
e0cd81cab4 github: use actions-rs/cargo instead of run
From https://github.com/actions-rs/cargo#use-cases, it sounds like
errors may be presented in a nicer way if we use `actions-rs/cargo`
instead of a simple `run`, so let's try it.
2022-03-07 22:16:57 -08:00
Martin von Zweigbergk
f112b5225c github: use minimal profile for clippy actions
We should only need the `minimal` profile. Also, we already have
configured the action to use the `clippy` component, so I don't think
we need to explicitly add it with a separate `run` action.
2022-03-07 22:16:57 -08:00
Martin von Zweigbergk
5721436558 tests: use insta crate where appropriate
Thanks to @arxanas for the suggestion.
2022-03-07 20:23:55 -08:00
Martin von Zweigbergk
0c1734a19d editorconfig: disable trim_trailing_whitespace due to multi-line bugs
The `trim_trailing_whitespace` config is not working well with
multi-line string literals. I've tried to work around
intellij-rust/intellij-rust#5368 twice and now I want to use the
`insta` crate so I'd need to find another workaround. Let's just
disable the config instead. I wouldn't be surprised if other editors
have similar bugs as IntelliJ.
2022-03-07 20:23:55 -08:00
Martin von Zweigbergk
891641670c tests: don't propagate environment variables to tests
We don't want variables from the developer's environment to affect
tests. You can make tests fail if you set `XDG_CONFIG_HOME` such that
`$XDG_CONFIG_HOME/jj/config.toml` exists and has e.g. an email
set. The fix is to not propagate any environment variables. Thanks for
@arxanas for pointing this out in #104.

We still need to set `$HOME` to prevent configs from being read from
the process owner's home directory (because that's what
`dirs::config_dir()` seems to fall back to if `$HOME` is not set). By
the way, I suspect we'd still not immune to configs from the
developers home directory on Windows, because that doesn't seem to be
controlled by `$HOME`.
2022-03-07 20:23:55 -08:00
Martin von Zweigbergk
42252a2f00 cli: on jj init --git-repo=., use relative path to .git/
When the backing Git repo is inside the workspace (typically directly
in `.git/`), let's point to it by a relative path so the whole
workspace can be moved without breaking the link.

Closes #72.
2022-03-05 09:37:48 -08:00
Martin von Zweigbergk
bbf4ba4118 cli: on jj init --git-repo, point to Git repo's .git/
When using an internal Git repo (`jj init --git`), we make
`.jj/repo/store/git_target` point directly to the repo (which is bare
in that case). It makes sense to do the same when using an external
Git repo (`jj init --git-repo`), so the contents of
`.jj/repo/store/git_target` doesn't depend on whether the user
included the `.git/` on the CLI.
2022-03-05 09:37:48 -08:00
Martin von Zweigbergk
0c6d89581e tests: pass timestamps via env vars for reproducible hashes
This patch introduces a `JJ_TIMESTAMP` environment variable that lets
us specify the timestamp to use in tests. It also updates the tests to
use it, which means we get to simplify the tests a lot now that that
the hashes are predictable.
2022-03-05 08:48:42 -08:00
Martin von Zweigbergk
b7942ad55a tests: use another workaround for intellij-rust/intellij-rust#5368
I'm about to make these strings not be regular expressions, so I need
to get rid of the `[ ]` workaround.
2022-03-05 08:48:42 -08:00
Martin von Zweigbergk
20ff88461b cli: error out if -R is not applicable
Closes #101.
2022-03-03 16:36:13 -08:00
Martin von Zweigbergk
eed9d48bf7 cli: pass clap app around instead of creating it in multiple places
We need the app (top-level `clap::Command`) in order to check if
e.g. `-R` was passed to `jj init` (for #101), and it seems cleaner to
pass the instance around than to re-create it when needed.
2022-03-03 16:36:13 -08:00
Martin von Zweigbergk
858776d3ee cli: leverage Clap's checking for conflicting arguments
I don't know why I didn't think of doing this earlier...
2022-03-03 16:36:13 -08:00
Martin von Zweigbergk
b45bada00f cli: clarify error message when jj untrack argument is not ignored
As pointed out by @arxanas in #88, the message saying something like
"At least 'bin/.DS_Store' was added back ..." is confusing especially
when the command you ran was just `jj untrack bin/.DS_Store`. Let's
clarify the message by saying exactly how many more files there are,
and specialize the message for when there is only one file. Also
update the message to say "would be added back" instead of "was added
back" since we don't actually change anything if some files would be
added back (since 4b91ad408c).

Should we even list all the files? I'm concerned that such a list
could be very long. On the other hand, it can also be annoying to have
to run `jj untrack some/dir/` and only be told about single file to
add to the ignore patterns every time.
2022-03-02 22:43:09 -08:00
Martin von Zweigbergk
6747a6c59c cli: add test of --no-commit-working-copy
I didn't add a test in #90 because the test cases needed to be cleaned
up first. They now look a bit better, so we can add test for the
flag.
2022-03-02 22:00:24 -08:00