Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage tfs/NameOfMyBranch in fetch -i command #171

Closed
pmiossec opened this issue Apr 6, 2012 · 5 comments
Closed

Manage tfs/NameOfMyBranch in fetch -i command #171

pmiossec opened this issue Apr 6, 2012 · 5 comments

Comments

@pmiossec
Copy link
Member

pmiossec commented Apr 6, 2012

Hi,

Does it make sens (and is it possible) to manage tfs/NameOfMyBranch in fetch -i (and ct -i) command?

Actually, if you want to manage many tfs branches, you have to use the command :
git tfs fetch -i NameOfMyBranch

Is it possible to add the possibility to use the command with the branch name "tfs/NameOfMyBranch" :
git tfs fetch -i tfs/NameOfMyBranch

When you use this command, you have the message :
Unable to locate git-tfs remote with id = tfs/gf_1-0-x
You may be able to resolve this problem.

  • Try using git tfs bootstrap to auto-init TFS remotes.

Actually, I try to use git-tfs with gitExtension and to add scripts (in gitExtension) to make the use easier and try to convince my team to use git.
But the only information given to me by gitExtension (with the variable {sRemoteBranch}) to add working scripts is "tfs/NameOfMyBranch" instead of "NameOfMyBranch" expected by git-tfs.

The problem should be the same with the commant "ct -i".

Thanks in advance for your answer.

Philippe

@dennismi dennismi mentioned this issue Apr 16, 2012
@pmiossec
Copy link
Member Author

Hi,

In fact a guy in the git-extension forum gave me a workaround ( https://github.com/spdr870/gitextensions/issues/869 ) to do what I wanted to do but I fall on a bug of git-tfs. And I don't know why it don't work.

Because gitExtension give me the name 'tfs/default' for a branch and git-tfs need just 'default' as parameter, he told me to use the unix command 'sed' to help me. Like that :
git tfs fetch -i tfs/default | sed 's/tfs///'

But git-tfs failed unexpectely with a strange message :
Unable to locate git-tfs remote with id = default
You may be able to resolve this problem.
Try using git tfs bootstrap to auto-init TFS remotes.

But 'default' is the name of my branch!!!!!!

Any idea?

@spraints
Copy link
Member

As with many refs in git, the tfs remote id goes by several different names. Depending on the context, it goes by 'refs/remotes/tfs/default', 'tfs/default', or just 'default'. (git-tfs is fairly simplistic about how it handles the id in different contexts, so there may be room for improvement.) Here's how it works now.

'default' is the actual id of the remote. If you do git config -l, you'll see several config keys that start with 'tfs-remote.default'. When you do -i other in git-tfs commands, you're telling it to look up configs with 'tfs-remote.other'. So if you do '-i tfs/default', it looks for configs called 'tfs-remote.tfs/default'. So, for identifying the tfs remote with -i, use 'default'.

The id of the remote is used in the name of the remote tracking branch. The full name of the branch is 'refs/remotes/tfs/default'. Git lets you call it 'tfs/default'. (I don't think you can call it 'default' when talking about the branch. You can ask git by doing git rev-parse default, and see if you get the same thing as git rev-parse tfs/default or git rev-parse refs/remotes/tfs/default.) Ideally, git-tfs is the only thing that updates the tfs/default branch, but you can of course read from it or branch from it. So, when you're using git's commands to diff, merge, pull, rebase, etc., use 'tfs/default'.

hth

@pmiossec
Copy link
Member Author

Ok, I understand better why it's not a good idea. I was wandering but was quite not shure about that!
Thanks.
And your right, git rev-parse default is not allowed!

But do you have an idea for my second message? The command 'sed' do it's job so git-tfs should receive the good values but make an error :(

@spraints
Copy link
Member

git tfs fetch -i tfs/default | sed 's/tfs\///'

This command passes the output of git-tfs through sed, which isn't what you need. You need something more like this:

git tfs fetch -i $(echo tfs/default | sed 's/tfs\///')
# or, if your shell doesn't support that, maybe this will work:
git tfs fetch -i `echo tfs/default | sed 's/tfs\///'`
# Note ` vs '

@pmiossec
Copy link
Member Author

After quite some tries (and lost of failed --due to cmd.exe--) trying your commands, I figured out what was the problem... I put it here if it could help someone!

Like I explain here ( https://github.com/spdr870/gitextensions/issues/869 ), this command was to use with GitExtension (and not with the command line).
In the command line, it worked well but not when I put it in the GitExtension GUI.
The workaround was to use bash.exe to pass it the command line (and not cmd.exe /C which fail miserabily!).
Finally, I use the command line :
bash -c "git tfs fetch -i $(echo {sRemoteBranch} | sed 's/tfs\///')"

and it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants