From 656883f1f076a33de4a643e4621953d8a589d59b Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Thu, 19 Feb 2009 02:21:39 +0100 Subject: [PATCH] Update the current branch information when reloading all references Fixes problem of improper highlighting of current branch after switching branch and reloading. --- tig.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tig.c b/tig.c index 5acb398..85fe981 100644 --- a/tig.c +++ b/tig.c @@ -6658,6 +6658,9 @@ read_ref(char *id, size_t idlen, char *name, size_t namelen) static int load_refs(void) { + const char *head_argv[] = { + "git", "symbolic-ref", "HEAD", NULL + }; static const char *ls_remote_argv[SIZEOF_ARG] = { "git", "ls-remote", opt_git_dir, NULL }; @@ -6671,6 +6674,15 @@ load_refs(void) if (!*opt_git_dir) return OK; + if (run_io_buf(head_argv, opt_head, sizeof(opt_head))) { + chomp_string(opt_head); + if (!prefixcmp(opt_head, "refs/heads/")) { + char *offset = opt_head + STRING_SIZE("refs/heads/"); + + memmove(opt_head, offset, strlen(offset) + 1); + } + } + while (refs_size > 0) free(refs[--refs_size].name); while (id_refs_size > 0) @@ -6813,23 +6825,11 @@ read_repo_info(char *name, size_t namelen, char *value, size_t valuelen) static int load_repo_info(void) { - const char *head_argv[] = { - "git", "symbolic-ref", "HEAD", NULL - }; const char *rev_parse_argv[] = { "git", "rev-parse", "--git-dir", "--is-inside-work-tree", "--show-cdup", "--show-prefix", NULL }; - if (run_io_buf(head_argv, opt_head, sizeof(opt_head))) { - chomp_string(opt_head); - if (!prefixcmp(opt_head, "refs/heads/")) { - char *offset = opt_head + STRING_SIZE("refs/heads/"); - - memmove(opt_head, offset, strlen(offset) + 1); - } - } - return run_io_load(rev_parse_argv, "=", read_repo_info); } -- 2.32.0.93.g670b81a890