tibirna / qgit

Official git repository for QGit.
Other
174 stars 68 forks source link

Limit git hash length to 8 characters #101

Closed nishanthkarthik closed 3 years ago

nishanthkarthik commented 4 years ago

Is there a way I can configure qgit to show only the first n characters of commit hash? My use case is I use qgit as a git browser and I do all my git things on the terminal. Limiting the commit hash length makes it easier to copy.

If this is not implemented, I can make a PR with a configurable commit hash length

tibirna commented 4 years ago

Showing a smaller number of characters from the full 40 char length SHA is convenient, but choosing 8 as a constant limit is dangerous (can lead to collisions). If, on the other hand, you want to implement an algorithm similar to that used by git log --format=short, then please do. Such an algorithm should automatically choose the number of chars in the shorthand SHA so that collisions are not possible in the current repo.

Please keep in mind that such a calculation remains valid for the current state of any git repo. Reuse of the shorthand SHA and any later point could still produce collisions, depending on how the repo evolved.

Thanks for your offer of help!

mvf commented 4 years ago

Limiting the commit hash length makes it easier to copy.

Double-clicking a short hash takes the same time as double-clicking a long one. If the goal is easier hash copying, it might be better to add an option to emulate gitk, where selecting a commit automatically puts the SHA in the primary selection.

nishanthkarthik commented 4 years ago

I sometimes type the hash manually. A shorter hash is easier to copy visually. For example, I can remember b182aa better than b182aa184308..

I also have a tiling terminal, copying short length hash prevents my git commands from rolling over to a new line

tibirna commented 3 years ago

Merged. Thanks!