Commit Graph

155 Commits

Author SHA1 Message Date
Kiril Videlov
6ff0d551eb
fix test 2024-04-27 23:43:25 +02:00
Kiril Videlov
d65f723ec0
test: Add tests for set_reference_to_oplog function 2024-04-27 23:27:39 +02:00
Kiril Videlov
8b0dd6cc21 skip tempfile under windows 2024-04-27 17:15:08 +02:00
Sebastian Thiel
4f58883bd4
try to fix regression on Windows due to tempfiles semantics (#3601)
Until `perist()` is truly atomic also on Windows, and modelled
[after Git](https://github.com/git/git/blob/master/compat/mingw.c#L2159-L2209),
sans the retries, it seems to work to just perform ordinary writes.

Before going there though, we try to call `sync_all()` on Windows to truly
finish the operation. On Unix, a rename is already supposed to be atomic.
2024-04-27 16:11:28 +02:00
Sebastian Thiel
91d892882e
Deduplicate all 'write' code
GB writes files atomically and in the end it boils down to allocating bytes
and writing them all at once.

Now this capability lives in the `fs` module.
2024-04-27 16:11:27 +02:00
Kiril Videlov
9d534b09ca
snapshots - read full commit meesage 2024-04-26 23:33:39 +02:00
Kiril Videlov
5420fc3e3c
use new snapshot types 2024-04-26 23:20:31 +02:00
Kiril Videlov
371a944e71
add types for the different kinds of snapshots
Serializing and deserializing snapshot trailers
2024-04-26 22:35:09 +02:00
Josh Junon
adcba68220
move multi-file modules to mod.rs and single-file modules to <name>.rs 2024-04-26 11:56:35 +02:00
Sebastian Thiel
a08e2be07e
OwnershipClaims now allocates less
This is done by allowing to take (rust) ownership where internally
the item is consumed.
2024-04-26 07:08:43 +02:00
Sebastian Thiel
6c90381bcf
Use iterators for transformation, and avoid copies by default. 2024-04-26 07:08:41 +02:00
Mattias Granlund
c5c2df1b93 Surface warning if hunk locked to multiple branches
- now returning `HunkLock` to front end
- detect if locked to more than one branch and warn user
2024-04-26 00:06:01 +02:00
Kiril Videlov
fd1ac5d65b
improved snapshot labels 2024-04-25 21:44:30 +02:00
Kiril Videlov
33859c89ef
adds some documentation 2024-04-25 21:09:02 +02:00
Kiril Videlov
bedc918b84
simplify reflog reference setting 2024-04-25 20:51:24 +02:00
Kiril Videlov
9a499575c4 fixes a bug with the reflog editing 2024-04-25 19:23:13 +02:00
Kiril Videlov
4c92caafd4 create simple snapshots on branch operations 2024-04-25 19:23:13 +02:00
Kiril Videlov
9a07f50244 fix: correctly handle the case of the feature flag being absent 2024-04-25 19:23:13 +02:00
Kiril Videlov
b3c05b7948 fix signatures 2024-04-25 19:23:13 +02:00
Kiril Videlov
432aeeaf2a feature flag for snapshot creation 2024-04-25 19:23:13 +02:00
Kiril Videlov
753953a7d5 remove tauri endpoint for creating snapshots 2024-04-25 19:23:13 +02:00
Kiril Videlov
5e395a3700 snapshot reflog doesnt need to be exposed 2024-04-25 19:23:13 +02:00
Kiril Videlov
3d04c7fc5b set target ref on snapshot 2024-04-25 19:23:13 +02:00
Kiril Videlov
0911212a9c handle commit not found 2024-04-25 19:23:13 +02:00
Kiril Videlov
ca4f79f7ff reflog entry for the snapshots 2024-04-25 19:23:13 +02:00
Kiril Videlov
a2682e2535 implement undo stack snapshotting 2024-04-25 19:23:13 +02:00
Sebastian Thiel
066d520f1a less cumbersome error handling for Git errors 2024-04-25 16:42:11 +02:00
Mattias Granlund
e0c2d82127 Reset files into the same branch they were committted to
- regressed when switching to blame for hunk locking
2024-04-25 16:42:11 +02:00
Kiril Videlov
bb48dff72a project deleteion cleans up virtual_branches.toml 2024-04-24 17:50:39 +02:00
Josh Junon
40f7234708
Merge pull request #3596 from Byron/fix-mode-windows
avoid to make files executable on Windows (#3329).
2024-04-24 16:23:35 +02:00
Kiril Videlov
7f4aec50cf make git system executable the default auth flow 2024-04-24 16:13:05 +02:00
Sebastian Thiel
34770a4b77
avoid forcefully making files executable on Windows (#3329).
Instead, respect the existing bit if set in Git, but do not try
to derive it from the filesystem which is something Git doesn't
seem to be doing on Windows either.

This also makes me think that `gitoxide` should make it easy
to build a tree from a file and deal with this.
2024-04-24 15:14:22 +02:00
Sebastian Thiel
6033a62a94 use gix::tempfile in place of the tempfile.
This allows to unify handling of filewrites in more places.
2024-04-24 13:14:20 +02:00
Sebastian Thiel
6665bc9289
Use a temp-file to write new content atomically in storage layer (#2807)
This will prevent half-written content on disk in case the write is interrupted.

Lock files are *not* used as the assumption is that a lock is held centrally.
2024-04-24 10:38:48 +02:00
Mattias Granlund
c202d83b6b Allow hunk locking to multiple commits
- adds `locked_to` field to `GitHunk` to avoid looking it up again
- sends array to ui instead of single commit id
2024-04-24 08:15:01 +01:00
Mattias Granlund
a664c85a9a Fix typo 2024-04-24 08:15:01 +01:00
Mattias Granlund
0a1fbdce9a Add integration_commit_id as optional param to update_gitbutler_integration 2024-04-24 08:15:01 +01:00
Mattias Granlund
811f0ee35b Blame across workspace instead of by branch
- refactors `update_gitbutler_integration`
- creates new `get_workspace_head` function
- ignore locking when resolving merge conflicts
2024-04-24 08:15:01 +01:00
Mattias Granlund
2f7b396ab8 Remove extra indirector for blame function 2024-04-24 08:15:01 +01:00
Mattias Granlund
8dd4a92622 Use empty vector instead of None 2024-04-24 08:15:01 +01:00
Mattias Granlund
055c7e7119 Use blame for hunk locking
- replaces commit walking with a git blame
- limited to specific hunk lines
- earliest_commit set to default target
- lock if any blame other than boundary commit
- intersection uses context lines
2024-04-24 08:15:01 +01:00
Sebastian Thiel
aa3d3cb7da fix rustfmt formatting issues due to line-length (#3039)
The trick is to temporarily set `max_width` in `rustfmt.toml` to 120,
then set it back to the default of 100 (or remove the file).
2024-04-23 12:53:56 +02:00
Sebastian Thiel
5ea4bb3c58 don't fail if a ref can't be peeled (#3129)
Sometimes, symbolic refs are used as tracking branches, like
`refs/remotes/origin/HEAD`, and after some changes are dangling,
pointing to a ref which doesn't exist anymore (maybe it was renamed
from `master` to `main`).

Now, this isn't fatal anymore, but will be logged instead.
2024-04-23 12:53:56 +02:00
Sebastian Thiel
118bea95d1 for HTTP-based errors, attach Code to allow UI to show improved message (#2886)
Now thanks to a specific `Code`, the UI could display special text to help users
solve the issue related to workflow files.
2024-04-23 11:32:53 +02:00
Sebastian Thiel
bb7824e7c0 assure that root-causes are always provided instead of "Something went wrong". (#2886)
In the previous commit it was stated that the 'unfolding' of errors might
have been intentional to surface root causes of error messages.

However, this might have been wrong, and this commit brings back root-causes explicitly,
while erroring on the side of caution. That is, "Something went wrong" probably won't
be shown anymore, instead, possibly too much will be displayed and we'd rather tune
that down once it becomes clear which messages are needed, or should be improved.

Overall, I think it's best to show more, and then tune errors with custom context
where needed.
2024-04-23 11:32:53 +02:00
Sebastian Thiel
6f764f5fd6 assure important errors are passed as context (#2886)
Previously, errors would be 'unfolded' so there was no error chain,
but the lowest error would become the top-most one that way.

I thought this was accidental, but it turns out that it wasn't.
To fix this generally, make sure that we always use the message
of the lowest-possible error if no context is provided.
2024-04-23 11:32:53 +02:00
Sebastian Thiel
9bbba057f4 fix some typos that could be user-facing 2024-04-23 11:32:53 +02:00
Josh Junon
31ce4574bd
Merge pull request #3575 from gitbutlerapp/Fix-Gitea
Allow SSH remotes to use any port
2024-04-22 11:47:04 +02:00
Sebastian Thiel
b60d49f752 a clear error message when bare repositories are encountered and rejected (#2704)
This also rewrites some other checks in preference of opening the git directory
in isolation. Doing so is very fast, and the only way to know for certain if a
repository is bare.

In future, once the repository is more separated from the worktree (in terms of mindset)
it should be possible to handle bare repos with worktrees as well.
2024-04-22 11:01:07 +02:00
Sebastian Thiel
a5bda226ef provide better errors when adding a project (#2608)
The issue initially was that the wrapping of anyhow around a `thiserror`
type, which is when manually added context gets lost as there is no way
to downcast such an `anyhow` error back to a concrete type without
wanting to know it.

The solution was to remove the intermediate `thiserror` type which didn't
serve an actual purpose.
2024-04-22 10:59:03 +02:00