mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-04 10:51:37 +00:00
git: simply use rand::random() to generate ref preventing gc
We don't care the ref content as long as it is unique, so using threaded RNG should be fine. This change means refs/jj/keep will now contain refs of the following forms: - new create_no_gc_ref(): 0f8d6cd9721823906cfb55dac99d7bf5 - old create_no_gc_ref(): 0f6d93fe-0507-4db8-ad0a-6317f02e27b9 - prevent_gc(commit_id): 0f9c15100b6f1373f38186357e274a829fb6c4e2
This commit is contained in:
parent
31ad0cd2ed
commit
ca2e9fe6d1
1 changed files with 2 additions and 8 deletions
|
@ -21,7 +21,6 @@ use std::sync::{Arc, Mutex};
|
|||
use git2::Oid;
|
||||
use itertools::Itertools;
|
||||
use prost::Message;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::backend::{
|
||||
make_root_commit, Backend, BackendError, BackendResult, ChangeId, Commit, CommitId, Conflict,
|
||||
|
@ -138,13 +137,8 @@ fn deserialize_extras(commit: &mut Commit, bytes: &[u8]) {
|
|||
/// Creates a random ref in refs/jj/. Used for preventing GC of commits we
|
||||
/// create.
|
||||
fn create_no_gc_ref() -> String {
|
||||
let mut no_gc_ref = NO_GC_REF_NAMESPACE.to_owned();
|
||||
let mut uuid_buffer = Uuid::encode_buffer();
|
||||
let uuid_str = Uuid::new_v4()
|
||||
.as_hyphenated()
|
||||
.encode_lower(&mut uuid_buffer);
|
||||
no_gc_ref.push_str(uuid_str);
|
||||
no_gc_ref
|
||||
let random_bytes: [u8; 16] = rand::random();
|
||||
format!("{NO_GC_REF_NAMESPACE}{}", hex::encode(random_bytes))
|
||||
}
|
||||
|
||||
fn validate_git_object_id(id: &impl ObjectId) -> Result<git2::Oid, BackendError> {
|
||||
|
|
Loading…
Reference in a new issue