{"thread":{"id":"57209","subject":"[PATCH] git-gui: reload tracking branches after adding remote","startedAt":"2022-01-07T12:58:04Z","lastAt":"2022-01-07T12:58:04Z","messageCount":1,"participants":["Tom Levy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"445714","messageId":"20220107123939.1955-1-tomlevy93@gmail.com","threadId":"57209","inReplyTo":null,"subject":"[PATCH] git-gui: reload tracking branches after adding remote","fromName":"Tom Levy","fromEmail":"tomlevy93@gmail.com","sentAt":"2022-01-07T12:39:39Z","receivedAt":"2022-01-07T12:58:04Z","isPatch":true,"sender":{"key":"tomlevy93@gmail.com","avatar":null},"body":"Hi,\n\ngit-gui does not display new tracking branches after adding a remote.\n\nSteps to reproduce issue:\n\n$ git init test_repo\n$ cd test_repo\n$ git commit --allow-empty -m \"Initial commit\"\n$ git gui\nRemote > Add... > Name: \"test_remote\", Location: \".\". Add.\n(Fetch output: [new branch] master -> test_remote/master. Close.)\nBranch > Create... . Select \"Tracking Branch\".\n\nExpected result: test_remote/master should be displayed.\nActual result: No tracking branches displayed.\n\nA workaround is to close and re-open git-gui.\n\nThe patch below fixes the issue by reloading the tracking branches\nafter adding a remote (see the commit message for more details).\n\nIt may be a good idea to also reload the tracking branches when\nremoving a remote (something this patch doesn't do). It's not strictly\nnecessary with the way the code is currently written (see the commit\nmessage).\n\nRegards,\nTom Levy\n\n-- >8 --\n\nSubject: [PATCH] git-gui: reload tracking branches after adding remote\n\nOtherwise newly-fetched tracking branches are not displayed in the\nrevision chooser's Tracking Branch tab ($tracking_branches is not\nupdated, so 'all_tracking_branches' does not return the new branches).\n\nThe reload is done using 'load_all_remotes', which also reloads\n$all_remotes and $repo_config, so they don't need to be manually\nupdated any more.\n\nWhen removing remotes, it's not necessary to reload the tracking\nbranches. This is because 'all_tracking_branches' is only called from\nchoose_rev.tcl, which filters out non-existent refs.\n\nSigned-off-by: Tom Levy <tomlevy93@gmail.com>\n---\n lib/remote.tcl | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\ndiff --git a/lib/remote.tcl b/lib/remote.tcl\nindex ef77ed7..ed26170 100644\n--- a/lib/remote.tcl\n+++ b/lib/remote.tcl\n@@ -285,15 +285,9 @@ proc populate_remotes_menu {} {\n }\n \n proc add_single_remote {name location} {\n-\tglobal all_remotes repo_config\n-\tlappend all_remotes $name\n-\n \tgit remote add $name $location\n \n-\t# XXX: Better re-read the config so that we will never get out\n-\t# of sync with git remote implementation?\n-\tset repo_config(remote.$name.url) $location\n-\tset repo_config(remote.$name.fetch) \"+refs/heads/*:refs/remotes/$name/*\"\n+\tload_all_remotes\n \n \tadd_fetch_entry $name\n \tadd_push_entry $name\n-- \n2.30.2\n\n"}]}