git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: problem pushing repository

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jun 22, 2007, 22:47 UTC
Message-ID
<20070622224712.GI17393@spearce.org>
In-Reply-To
<1182519484.6207.38.camel@localhost>
Raimund Bauer <ray007@gmx.net> wrote:
Show 19 quoted lines
> On Fri, 2007-06-22 at 12:26 +0100, Johannes Schindelin wrote: 
> > On Fri, 22 Jun 2007, Raimund Bauer wrote:
> > 
> > > $ git push slcom test:test 
> > > error: dst refspec test does not match any existing ref on the remote
> > > and does not start with refs/.
> > 
> > It says that there is no branch named "test" on the remote side, and since 
> > you could also want to push a tag, you have to say
> > 
> > 	test:refs/heads/test
> > 
> > here. However, I do not understand why you bother to use the :dst syntax 
> > here, since your target name is _exactly_ the same as the source name. Why 
> > not just
> > 
> > 	git push slcom test
> 
> because I had gotten the command line from bash-completion

I just patched the bash completion package to offer `git push slcom test` as the completion, instead of `git push slcom test:test`. The patch was pretty trivial, and is now also in my fastimport.git tree on repo.or.cz.

-->8-- Avoid src:dst syntax as default bash completion for git push

Raimund Bauer just discovered that the default bash completion for a local branch name in a git-push line is not the best choice when the branch does not exist on the remote system.

In the past we have always completed the local name 'test' as "test:test", indicating that the destination name is the same as the local name. But this fails when "test" does not yet exist on the remote system, as there is no "test" branch for it to match the name against.

Fortunately git-push does the right thing when given just the local branch, as it assumes you want to use the same name in the destination repository. So we now offer "test" as the completion in a git-push line, and let git-push assume that is also the remote branch name.

We also still support the remote branch completion after the :, but only if the user manually adds the colon before trying to get a completion.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9e72f0f..c7c9963 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -683,7 +683,7 @@ _git_push ()
 			__gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
 			;;
 		*)
-			__gitcomp "$(__git_refs2)"
+			__gitcomp "$(__git_refs)"
 			;;
 		esac
 		;;
-- 
1.5.2.2.1050.g51a8b

-- 
Shawn.
Previous: Raimund BauerNext: Raimund Bauer
Message 7 of 15 in “problem pushing repository”
  1. Adam MercerJun 22, 2007
  2. Junio C HamanoJun 22, 2007
  3. Andrew RuderJun 22, 2007
  4. Raimund BauerJun 22, 2007
  5. Johannes SchindelinJun 22, 2007
  6. Raimund BauerJun 22, 2007
  7. Shawn O. PearceJun 22, 2007
  8. Raimund BauerJun 23, 2007
  9. Shawn O. PearceJun 24, 2007
  10. Jakub NarebskiJun 25, 2007
  11. Adam MercerJun 22, 2007
  12. Raimund BauerJun 22, 2007
  13. Adam MercerJun 22, 2007
  14. Adam MercerJun 22, 2007
  15. Johannes SixtJun 22, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.