File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,17 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
8080 } ;
8181
8282 let original_target_ref = if let Some ( base) = push_options. get ( "base" ) {
83- transaction. refname ( base)
83+ // Allow user to use just the branchname as the base:
84+ let full_path_base_refname = transaction. refname ( & format ! ( "refs/heads/{}" , base) ) ;
85+ if transaction
86+ . repo ( )
87+ . refname_to_id ( & full_path_base_refname)
88+ . is_ok ( )
89+ {
90+ full_path_base_refname
91+ } else {
92+ transaction. refname ( base)
93+ }
8494 } else {
8595 transaction. refname ( & baseref)
8696 } ;
@@ -97,7 +107,7 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
97107 return Err ( josh:: josh_error ( & unindent:: unindent ( & format ! (
98108 r###"
99109 Reference {:?} does not exist on remote.
100- If you want to create it, pass "-o base=refs/heads/<branchname> "
110+ If you want to create it, pass "-o base=<basebranch>" or "-o base=path/to/ref "
101111 to specify a base branch/reference.
102112 "### ,
103113 baseref
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ Check the branch pushed
6363 * [new branch] new-branch -> origin/ new-branch
6464 $ [ " ${ SHA1} " = " $(git log --max-count=1 --format='% H ' origin/new-branch)" ] || echo " SHA1 differs after push!"
6565
66- Add one more commit in the workspace
66+ Add one more commit in the workspace and push using implicit prefix in base
6767
6868 $ cd $ {TESTTMP}/ sub
6969 $ echo test > test. txt
@@ -72,7 +72,7 @@ Add one more commit in the workspace
7272 [new-branch 751 ef45] test commit
7373 1 file changed, 1 insertion(+)
7474 create mode 100644 test. txt
75- $ git push origin new-branch -o base = refs / heads / master
75+ $ git push origin new-branch -o base = master
7676 remote: josh-proxy
7777 remote: response from upstream:
7878 remote: To http: // localhost: 8001 / real_repo. git
Original file line number Diff line number Diff line change 2525 remote: josh-proxy
2626 remote: response from upstream:
2727 remote: Reference " refs/heads/new_branch" does not exist on remote.
28- remote: If you want to create it, pass " -o base=refs/heads/<branchname> "
28+ remote: If you want to create it, pass " -o base=<basebranch> " or " -o base=path/to/ref "
2929 remote: to specify a base branch/ reference.
3030 remote:
3131 remote:
You can’t perform that action at this time.
0 commit comments