-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Improve recovery form #11753
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
Improve recovery form #11753
Conversation
78233dc
to
167f698
Compare
@@ -78,6 +78,30 @@ private LostObject(LostObjectType objectType, string rawType, ObjectId objectId) | |||
ObjectId = objectId ?? throw new ArgumentNullException(nameof(objectId)); | |||
} | |||
|
|||
public static string[] GetCommitsMetadata(IGitModule module, string commits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this method used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a comment (and changed a little the interface)
UpdateFilteredLostObjects(); | ||
} | ||
} | ||
|
||
private bool _typeDetected = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep fields at the top.
Initialisation is not required, it gets initialised implicitly.
4778105
to
d9df8d1
Compare
@@ -32,9 +32,9 @@ private sealed partial class LostObject | |||
/// %s - subject. | |||
/// %ct - committer date, UNIX timestamp (easy to parse format). | |||
/// </summary> | |||
private static readonly string LogCommandArgumentsFormat = (ArgumentString)new GitArgumentBuilder("log") | |||
private static readonly string LogsCommandArgumentsFormat = (ArgumentString)new GitArgumentBuilder("show") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static readonly string LogsCommandArgumentsFormat = (ArgumentString)new GitArgumentBuilder("show") | |
private static readonly string ShowCommandArgumentsFormat = (ArgumentString)new GitArgumentBuilder("show") |
@@ -26,9 +27,12 @@ public sealed partial class FormVerify : GitModuleForm | |||
|
|||
private LostObject? _previewedItem; | |||
private string _defaultFilename = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private string _defaultFilename = null; | |
private string? _defaultFilename; |
int currentBatch = 0; | ||
|
||
while (currentBatch * batchSize < commits.Length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int currentBatch = 0; | |
while (currentBatch * batchSize < commits.Length) | |
for (int currentBatch = 0; currentBatch * batchSize < commits.Length; ++currentBatch ) |
@@ -18,6 +18,7 @@ public sealed partial class FormVerify : GitModuleForm | |||
private readonly TranslationString _xTagsCreated = new("{0} Tags created." + Environment.NewLine + Environment.NewLine + "Do not forget to delete these tags when finished."); | |||
private readonly TranslationString _selectLostObjectsToRestoreMessage = new("Select objects to restore."); | |||
private readonly TranslationString _selectLostObjectsToRestoreCaption = new("Restore lost objects"); | |||
private readonly TranslationString _seems = new("seems"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private readonly TranslationString _seems = new("seems"); | |
private readonly TranslationString _seems = new("seemingly"); |
item.RawType += $" ({_seems.Text}: {GuessFileTypeWithContent(content)})"; | ||
} | ||
|
||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | |
await this.SwitchToMainThreadAsync(); |
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) | ||
{ | ||
return mnuLostObjects.PreProcessMessage(ref msg) || base.ProcessCmdKey(ref msg, keyData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment why this is needed.
Doesn't have Form
an option like KeyPreview
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an expert on this but your comment made me reevaluate.
I made some changes...
d9df8d1
to
4d02ad1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have not run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid force push during pending reviews.
protected override bool ProcessKeyPreview(ref Message msg) | ||
{ | ||
// Check if keyboard shortcut is one provided by the contextual menu | ||
return mnuLostObjects.PreProcessMessage(ref msg) || base.ProcessKeyPreview(ref msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more elegant way, @RussKie?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the bothering you here @mstv?
Looks good to me. I don't think this dialog sees particularly high use, so I don't think it's worth spending too much time to try to super-optimise it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the bothering you here @mstv?
Because it is a workaround.
I don't think it's worth spending too much time to try to super-optimise it.
I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this dialog sees particularly high use,
I wish everyone that this dialog will be the less used of the application but with this PR and the previous ones, GE is maybe now the best Git GUI to recover lost commits and especially mistakenly deleted staged files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid your thought was lost in translation, sorry... though I think I got the idea that this dialog could be useful in recovering accidentally discarded stages files. If this is correct, could you elaborate on this further please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have decrypted my bad English well to understand right.
In this screen, the checkbox "Show commits and tags" allows you to recover commits that are not in the reflog (and so that you can't retrieve easily with GE "Show all reflog references" or reflog features).
And "Show other objects" allows you to recover blobs that are not linked to a commit. And these blobs are contents that were added to the git objects
database when you staged files (i.e. do a git add
) but are no more pointed by a commit or the index.
So if you discard, by mistake, all the files after having staged these files, you are able to retrieve the contents (and only the content) with this recovery form.
Unfortunately, you can't retrieve the path of the files as the "tree" objects are still not stored in the git object database when you stage (they are stored in the .git\index
file during the staging and will be stored only when you commit).
But the fact that now the form display the creation date of the blob ( #4882 ), try to determine the type of all the files based on there content ( #11727 and this PR) and display a content of the blob ( #8212 ) makes as convenient as possible to find the deleted content of the file you want to retrieve.
And I don't know a git GUI that provide such features that's why I said that maybe GE is the best tool to retrieve files in such case (before, as a last chance, having to try a recovery tool). Doing all that from the command line is also much more challenging.
The only missing feature is maybe the "search in blobs" feature but it should not be too difficult to do as everything is in place to be able to do it.
I think I will take some time later to add that to GE documentation ( or wiki?) later. At the moment, you could find some more explanation in stack overflow:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. @pmiossec you're a legend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this PR is ready for rebase in order to resolve the MC and for merging.
protected override bool ProcessKeyPreview(ref Message msg) | ||
{ | ||
// Check if keyboard shortcut is one provided by the contextual menu | ||
return mnuLostObjects.PreProcessMessage(ref msg) || base.ProcessKeyPreview(ref msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the bothering you here @mstv?
Because it is a workaround.
I don't think it's worth spending too much time to try to super-optimise it.
I agree.
for 1074 commits: 0.8s instead of 41.5s PR gitextensions#11753
without needing to open contextual menu first PR gitextensions#11753
45615a5
to
3ae292c
Compare
for 1074 commits: 0.8s instead of 41.5s PR #11753
without needing to open contextual menu first PR #11753
Proposed changes
git fsck
command --25s-- is now taking time. Overall: 1m5s before/ 25s after )Before
After
Test methodology
Test environment(s)
Merge strategy
I agree that the maintainer rebase merge this PR (if the commit message is clear).
✒️ I contribute this code under The Developer Certificate of Origin.