git-tfs icon indicating copy to clipboard operation
git-tfs copied to clipboard

git-tfs lets you break itself by renaming its "default" remote-tracking branch

Open gab opened this issue 11 years ago • 4 comments

The following command works and leaves git-tfs unable to do anything, including fixing the problem by doing the opposite rename:

git tfs branch --move default Master/AW1.0

Any subsequent command fails with the message:Unable to locate git-tfs remote with id = default You may be able to resolve this problem. - Try usinggit tfs bootstrap to auto-init TFS remotes.

git tfs bootstrap fails with the same message, incidentally.

Honestly its reliance on a remote branch being named default instead of whatever name it had in TFS is annoying. But the main point here is that it's super-easy to bork everything.

gab avatar Jan 19 '15 19:01 gab

Looks like git tfs branch --move default newdefault leaves the section header tfs-remote "default"] intact, e.g. relevant parts of the .git/config

[tfs-remote "default"]
[tfs-remote "newdefault"]
        url = https://server.com/tfs/tpc
        repository = $/repo/Main

siprbaum avatar Nov 19 '20 17:11 siprbaum

A subsequent fetch nevertheless works here. Closing the issue, as it is no longer reproducable

siprbaum avatar Nov 19 '20 17:11 siprbaum

I encountered this problem today. I can't exactly say this is not reproducible.

git-tfs version 0.32.0.0 (TFS client library 16.0.0.0 (MS)) (64-bit)
C:\{dir}>git tfs branch --move default {newname}
Cleaning before processing rename...
Cleaning up workspaces for TFS remote default
Cleaning up workspaces for TFS remote {otherBranch1}
Cleaning up workspaces for TFS remote {otherBranch2}
Cleaning up workspaces directory for TFS remote default
Cleaning up workspaces directory for TFS remote {otherBranch1}
Cleaning up workspaces directory for TFS remote {otherBranch2}
warning: no local branch found to rename

After that, git tfs branch -r is broken.

C:\{dir}>git tfs branch -r
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.
All the logs could be found in the log file: C:\Users\{user}\AppData\Local\git-tfs\git-tfs_log.txt

The suggested solution git tfs bootstrap is unable to fix the problem. Also, deleting stale entries of [tfs-remote *] in .git/config does not solve the issue. I noticed that .git/info/refs still contains the entry for default, but not for {newname}. Maybe this is part of the problem?

Error log:

2021-10-18 10:40:12.9246 [Debug] git command: Starting process: git rev-parse --show-prefix
2021-10-18 10:40:13.0336 [Debug] git command time: [00:00:00.1159639] rev-parse --show-prefix
2021-10-18 10:40:13.0687 [Debug] Command run:git tfs branch -r
2021-10-18 10:40:13.1267 [Debug] No authors file used.
2021-10-18 10:40:13.1267 [Debug] git-tfs version 0.32.0.0 (TFS client library 16.0.0.0 (MS)) (64-bit)
2021-10-18 10:40:13.1267 [Debug] git command: Starting process: git --version
2021-10-18 10:40:13.2017 [Debug] git command time: [00:00:00.0660075] --version
2021-10-18 10:40:13.9516 [Debug] GitTfs.Core.GitTfsException: Unable to locate git-tfs remote with id = default
   bei GitTfs.Util.GitTfsCommandRunner.Run(GitTfsCommand command, IList`1 args) in C:\gittfs\src\GitTfs\Util\GitTfsCommandRunner.cs:Zeile 36.
   bei GitTfs.GitTfs.Main(GitTfsCommand command, IList`1 unparsedArgs) in C:\gittfs\src\GitTfs\GitTfs.cs:Zeile 83.
   bei GitTfs.GitTfs.Run(IList`1 args) in C:\gittfs\src\GitTfs\GitTfs.cs:Zeile 48.
   bei GitTfs.Program.Main(String[] args) in C:\gittfs\src\GitTfs\Program.cs:Zeile 28.
2021-10-18 10:40:13.9666 [Error] Unable to locate git-tfs remote with id = default
2021-10-18 10:40:13.9766 [Error] You may be able to resolve this problem.
2021-10-18 10:40:13.9766 [Error] - Try using `git tfs bootstrap` to auto-init TFS remotes.
2021-10-18 10:40:13.9766 [Warn] All the logs could be found in the log file: C:\Users\{user}\AppData\Local\git-tfs\git-tfs_log.txt

d5UtQvp8QQU9 avatar Oct 18 '21 08:10 d5UtQvp8QQU9

Edited to fix formating

@d5UtQvp8QQU9 What I did:

Rename the tfs remote (output omitted):

/c/src/git-tfs/src/GitTfs/bin/Debug/net472/git-tfs.exe branch --move default foo

Reproduce your problem with git tfs branch -r:

$ /c/src/git-tfs/src/GitTfs/bin/Debug/net472/git-tfs.exe branch -r
Found matching Visual Studio version at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
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.
All the logs could be found in the log file: C:\Users\z002bd7y\AppData\Local\git-tfs\git-tfs_log.txt

Check for the existence of the default branch

$ git branch -a
  remotes/tfs/foo

So this is where I can't reproduce your described behaviour, as I don't have any default branch anymore.

Checking that git tfs fetch still works:

$ /c/src/git-tfs/src/GitTfs/bin/Debug/net472/git-tfs.exe fetch -i foo
Found matching Visual Studio version at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
Fetching from TFS remote 'foo'...
C23390 = 649da5f64086f1081cc036358dd857c54ecdf6d9
C25118 = ab12aed3c4bf244804e92b558544226567fafbda
...
CTRL+C

So fething is working, even with the renamed remote.

Check git-tfs.exe branch --all (editied for anonymization):

$ /c/src/git-tfs/src/GitTfs/bin/Debug/net472/git-tfs.exe branch --all
Found matching Visual Studio version at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise

Git-tfs remote details:

 foo -> https://server.com/tfs/tpc $/some/path/Main
        refs/remotes/tfs/foo - ab12aed3c4bf244804e92b558544226567fafbda @ 25118

Check git-tfs.exe branch -r --all:

$ /c/src/git-tfs/src/GitTfs/bin/Debug/net472/git-tfs.exe branch -r --all
Found matching Visual Studio version at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
Sequence contains no matching element
All the logs could be found in the log file: C:\Users\z002bd7y\AppData\Local\git-tfs\git-tfs_log.txt

Anyway, it looks like there is a problem with git tfs branch -r after the name. Therefore, reopen the issue.

siprbaum avatar Oct 18 '21 10:10 siprbaum