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

SHA 256 #5483

Open
vbjay opened this issue Sep 25, 2018 · 9 comments · May be fixed by #11707
Open

SHA 256 #5483

vbjay opened this issue Sep 25, 2018 · 9 comments · May be fixed by #11707
Labels
type: discussion type: git issue Issues that attributable to git

Comments

@vbjay
Copy link
Contributor

vbjay commented Sep 25, 2018

Do you want to request a feature or report a bug?
Feature
What is the current behavior?
We only support sha1.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

What is the expected behavior?
Supporting sha 256 also as mentioned here. https://blog.github.com/2018-09-10-highlights-from-git-2-19/#transitioning-away-from-sha-1
Environment you encounter the issue:

  • GitExtensions version:Master
  • GIT version: 2.19 +
  • OS version: NA
  • .NET version: NA

Did this work in previous version of GitExtensions (which)?
no

@gerhardol
Copy link
Member

GE is being prepared with the ObjectId abstraction (also for memory and speed reasons).
But I see no need to support SHA256 officially yet.
I suggest that this is closed for now.

@vbjay
Copy link
Contributor Author

vbjay commented Sep 26, 2018 via email

@RussKie RussKie added the type: git issue Issues that attributable to git label Sep 27, 2018
@drewnoakes
Copy link
Member

I believe Git now supports arbitrary hashes, so any future work here should be thinking beyond SHA256.

@vbjay
Copy link
Contributor Author

vbjay commented Oct 2, 2018 via email

@Chri-s
Copy link

Chri-s commented Apr 24, 2024

Just wanted to give some feedback since git officially supports sha256 hashes now.

I just tried to open a git repo with sha256 hashes (created with git init --object-format=sha256) in Git extensions.
GE shows the commits, but all information except the commit message is wrong.

For the commit

$ git log
commit 82eddb6a8066867882c3e0caa3f4ff1d43120c48c956159b9bd3feb6f5d514e3 (HEAD -> master)
Author: chri-s <[email protected]>
Date:   Sat Apr 20 22:19:22 2024 +0200

    Add scripts and README

GE shows

Author: 438f6a3ef46fdae367f2ea5db809104376197f694dd40c448635de69cd05553e542eec8b77ab0d3c1c003290f405000b912ae531 <1713644362>
Author date: 31.12.9999 23:59:59
Committer: 1713644362 <chri-s>
Commit date: 01.01.1970 02:46:04
Commit hash: 82eddb6a8066867882c3e0caa3f4ff1d43120c48

Add scripts and README

The branches are not recognized in the left tree view.
If I click on the Diff tab in a commit, this exception is raised:

  • Git Extensions 4.2.1.17611
  • Build b0c0b28
  • Git 2.44.0.windows.1
  • Microsoft Windows NT 10.0.22631.0
  • .NET 6.0.29
  • DPI 96dpi (no scaling)
  • Portable: False

Exit code: 128
Command: C:\Program Files\Git\bin\git.exe
Arguments: ls-tree -z -r c956159b9bd3feb6f5d514e3c2c02eb9506f95d5
Working directory: D:\Development\svn2gitrules-sha256\

GitExtUtils.ExternalOperationException: fatal: Not a valid object name c956159b9bd3feb6f5d514e3c2c02eb9506f95d5
 ---> System.Exception: fatal: Not a valid object name c956159b9bd3feb6f5d514e3c2c02eb9506f95d5
   --- End of inner exception stack trace ---
   at async Task<string> GitCommands.ExecutableExtensions.GetOutputAsync(IExecutable executable, ArgumentString arguments, byte[] input, Encoding outputEncoding, CommandCache cache, bool stripAnsiEscapeCodes) in C:/projects/gitextensions/GitCommands/Git/ExecutableExtensions.cs:line 129
   at void Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
   at T Microsoft.VisualStudio.Threading.JoinableTask<T>.CompleteOnCurrentThread()
   at T Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run<T>(Func<Task<T>> asyncMethod, JoinableTaskCreationOptions creationOptions) x 2
   at string GitCommands.ExecutableExtensions.GetOutput(IExecutable executable, ArgumentString arguments, byte[] input, Encoding outputEncoding, CommandCache cache, bool stripAnsiEscapeCodes) in C:/projects/gitextensions/GitCommands/Git/ExecutableExtensions.cs:line 43
   at IEnumerable<INamedGitItem> GitCommands.GitModule.GetTree(ObjectId commitId, bool full) in C:/projects/gitextensions/GitCommands/Git/GitModule.cs:line 3397
   at IReadOnlyList<GitItemStatus> GitCommands.GitModule.GetTreeFiles(ObjectId commitId, bool full) in C:/projects/gitextensions/GitCommands/Git/GitModule.cs:line 2719
   at IReadOnlyList<FileStatusWithDescription> GitUI.FileStatusDiffCalculator.SetDiffs(IReadOnlyList<GitRevision> revisions, ObjectId headId, bool allowMultiDiff, CancellationToken cancellationToken) in C:/projects/gitextensions/GitUI/UserControls/FileStatusDiffCalculator.cs:line 51
   at async Task GitUI.FileStatusList.SetDiffsAsync(IReadOnlyList<GitRevision> revisions, ObjectId headId, CancellationToken cancellationToken) in C:/projects/gitextensions/GitUI/UserControls/FileStatusList.cs:line 765
   at async Task GitUI.CommandsDialogs.RevisionDiffControl.SetDiffsAsync(IReadOnlyList<GitRevision> revisions) in C:/projects/gitextensions/GitUI/CommandsDialogs/RevisionDiffControl.cs:line 280
   at async void GitUI.CommandsDialogs.RevisionDiffControl.DisplayDiffTab(IReadOnlyList<GitRevision> revisions)+(?) => { } in C:/projects/gitextensions/GitUI/CommandsDialogs/RevisionDiffControl.cs:line 244
   at async void GitUI.TaskManager.InvokeAndForget(Control control, Func<Task> asyncAction, CancellationToken cancellationToken)+(?) => { } [1] in C:/projects/gitextensions/GitExtUtils/GitUI/TaskManager.cs:line 111
   at async Task GitUI.TaskManager.HandleExceptionsAsync(Func<Task> asyncAction, Func<Exception, Task> handleExceptionAsync) in C:/projects/gitextensions/GitExtUtils/GitUI/TaskManager.cs:line 38

@gerhardol
Copy link
Member

GE internally stores the object id as sha1, so sha256 will not work. I did not expect any info to be shown...
The app is somehow prepared for changing storage, but it is considerable work still to support sha256.

@Chri-s Chri-s linked a pull request Apr 24, 2024 that will close this issue
@Chri-s
Copy link

Chri-s commented Apr 24, 2024

I made some changes in the draft PR #11707, basically changing the ObjectId to be able to hold a sha1 or sha256 hash and changing some regexes. I also added dots to the git log format so that RevisionReader can see where a hash ends.

With these changes, GE can parse and display the git log of a sha256 repository, displays the branches and the commit tabs such as Files or Diff also work.

Can you or someone else check whether this is a sensible approach for the project? Then I would try to continue in this way.
I can't promise to complete the changes without help because I don't have detailed knowledge of git internals.

@gerhardol
Copy link
Member

Can you read the configuration for a repo and get the length of the sha?
The parsing of sha is time critical when loading a repo, to search for the length of the sha for every sha is slowing down for all.

@pmiossec
Copy link
Member

Can you read the configuration for a repo and get the length of the sha?

Somewhat possible with git rev-parse --show-object-format:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: discussion type: git issue Issues that attributable to git
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants