ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: use reverse-alphabet hex for branch name in jj git push --change

This commit is contained in:
Martin von Zweigbergk 2023-02-12 11:49:05 -08:00 committed by Martin von Zweigbergk
parent 9887d2c3d6
commit 331ebf4cef
3 changed files with 15 additions and 13 deletions

View file

@ -50,12 +50,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* The builtin `jj update` and `jj up` aliases for `jj checkout` have been
deleted.
* Change IDs are now in rendered using letters from the end of the alphabet
(backwards from 'z' through 'k') instead of the usual hex digits ('0' through
'9' and 'a' through 'f'). This is to clarify the distinction between change
IDs and commit IDs, and to allow more efficient lookup of unique prefixes.
This change doesn't affect the storage format; existing repositories will
remain usable.
* Change IDs are now rendered using letters from the end of the alphabet (from
'z' through 'k') instead of the usual hex digits ('0' through '9' and 'a'
through 'f'). This is to clarify the distinction between change IDs and commit
IDs, and to allow more efficient lookup of unique prefixes. This change
doesn't affect the storage format; existing repositories will remain usable.
### New features

View file

@ -32,6 +32,7 @@ use jujutsu_lib::backend::{BackendError, ChangeId, CommitId, ObjectId, TreeId};
use jujutsu_lib::commit::Commit;
use jujutsu_lib::git::{GitExportError, GitImportError};
use jujutsu_lib::gitignore::GitIgnoreFile;
use jujutsu_lib::hex_util::to_reverse_hex;
use jujutsu_lib::matchers::{EverythingMatcher, Matcher, PrefixMatcher, Visit};
use jujutsu_lib::op_heads_store::{self, OpHeadResolutionError, OpHeadsStore};
use jujutsu_lib::op_store::{OpStore, OpStoreError, OperationId, RefTarget, WorkspaceId};
@ -1619,7 +1620,9 @@ pub fn short_commit_hash(commit_id: &CommitId) -> String {
}
pub fn short_change_hash(change_id: &ChangeId) -> String {
change_id.hex()[0..12].to_string()
// TODO: We could avoid the unwrap() and make this more efficient by converting
// straight from binary.
to_reverse_hex(&change_id.hex()[0..12]).unwrap()
}
pub fn short_operation_hash(operation_id: &OperationId) -> String {

View file

@ -221,9 +221,9 @@ fn test_git_push_changes() {
let stdout = test_env.jj_cmd_success(&workspace_root, &["git", "push", "--change", "@"]);
insta::assert_snapshot!(stdout, @r###"
Creating branch push-1b76972398e6 for revision @
Creating branch push-yostqsxwqrlt for revision @
Branch changes to push to origin:
Add branch push-1b76972398e6 to 28d7620ea63a
Add branch push-yostqsxwqrlt to 28d7620ea63a
"###);
// test pushing two changes at once
std::fs::write(workspace_root.join("file"), "modified2").unwrap();
@ -232,10 +232,10 @@ fn test_git_push_changes() {
&["git", "push", "--change", "@", "--change", "@-"],
);
insta::assert_snapshot!(stdout, @r###"
Creating branch push-19b790168e73 for revision @-
Creating branch push-yqosqzytrlsw for revision @-
Branch changes to push to origin:
Force branch push-1b76972398e6 from 28d7620ea63a to 48d8c7948133
Add branch push-19b790168e73 to fa16a14170fb
Force branch push-yostqsxwqrlt from 28d7620ea63a to 48d8c7948133
Add branch push-yqosqzytrlsw to fa16a14170fb
"###);
// specifying the same change twice doesn't break things
std::fs::write(workspace_root.join("file"), "modified3").unwrap();
@ -245,7 +245,7 @@ fn test_git_push_changes() {
);
insta::assert_snapshot!(stdout, @r###"
Branch changes to push to origin:
Force branch push-1b76972398e6 from 48d8c7948133 to b5f030322b1d
Force branch push-yostqsxwqrlt from 48d8c7948133 to b5f030322b1d
"###);
}