Skip to content

Commit

Permalink
Update tracking branch when refreshing status view
Browse files Browse the repository at this point in the history
Fixes #1015
  • Loading branch information
koutcher committed Oct 13, 2020
1 parent e0fc1f4 commit b7951d1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Bug fixes:

- Fix wrapping of lines with multibyte characters. (#988)
- Improve highlighting of search with $ regex. (#1000)
- Update tracking branch when refreshing status view. (#1015)

tig-2.5.1
---------
Expand Down
10 changes: 10 additions & 0 deletions src/repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define REPO_INFO_SHOW_PREFIX "--show-prefix"
#define REPO_INFO_SYMBOLIC_HEAD "--symbolic-full-name"
#define REPO_INFO_RESOLVED_HEAD "HEAD"
#define REPO_INFO_REMOTE "--abbrev-ref"

struct repo_info_state {
const char **argv;
Expand Down Expand Up @@ -72,6 +73,10 @@ read_repo_info(char *name, size_t namelen, char *value, size_t valuelen, void *d
add_ref(repo.head_id, name, repo.remote, repo.head);
}
state->argv++;

} else if (!strcmp(arg, REPO_INFO_REMOTE)) {
string_ncopy(repo.remote, name, namelen);
state->argv++;
}

return SUCCESS;
Expand Down Expand Up @@ -103,11 +108,16 @@ load_repo_info(void)
enum status_code
load_repo_head(void)
{
const char *rev_parse_remote_argv[] = {
"git", "rev-parse", REPO_INFO_REMOTE, "@{upstream}", NULL
};
const char *rev_parse_argv[] = {
"git", "rev-parse", REPO_INFO_RESOLVED_HEAD,
REPO_INFO_SYMBOLIC_HEAD, "HEAD", NULL
};

memset(repo.remote, 0, sizeof(repo.remote));
reload_repo_info(rev_parse_remote_argv);
memset(repo.head, 0, sizeof(repo.head));
memset(repo.head_id, 0, sizeof(repo.head_id));
return reload_repo_info(rev_parse_argv);
Expand Down
2 changes: 1 addition & 1 deletion test/main/all-arg-test
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ EOF

assert_equals 'detached.screen' <<EOF
2009-02-13 23:31 +0000 Max Power * {max-power/mp/feature} WIP: featu
2010-04-07 05:37 +0000 Max Power * [master] {origin/master} {max-pow
2010-04-07 05:37 +0000 Max Power * [master] {max-power/master} {orig
2010-03-29 17:15 +0000 Jørgen Thygesen Brahe * Commit 10 D
2010-03-21 04:53 +0000 作者 * [HEAD] Commit 10 C
2010-03-12 16:31 +0000 René Lévesque * <v2.0.1> Commit 10 B
Expand Down
4 changes: 2 additions & 2 deletions test/reflog/default-test
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ test_tig reflog
assert_equals 'reflog-default.screen' <<EOF
HEAD@{0} [r1.1.2] [r1.1.x] <v1.1> checkout: moving from r1.0 to r1.1.2
HEAD@{1} [r1.0] <v1.0> checkout: moving from master to r1.0
HEAD@{2} [master] {origin/master} {max-power/master} {origin/HEAD} reset: moving
HEAD@{3} [master] {origin/master} {max-power/master} {origin/HEAD} clone: from /
HEAD@{2} [master] {max-power/master} {origin/HEAD} {origin/master} reset: moving
HEAD@{3} [master] {max-power/master} {origin/HEAD} {origin/master} clone: from /
Expand Down
4 changes: 2 additions & 2 deletions test/refs/branch-checkout-test
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ assert_equals 'refs-checked-out-branch.screen' <<EOF
All references
2010-03-04 04:09 +0000 A. U. Thor this_is_really_a_long_long_long_long_long_long_long_branch Comm
2010-04-07 05:37 +0000 Max Power master Comm
2010-04-07 05:37 +0000 Max Power origin/master Comm
2010-04-07 05:37 +0000 Max Power origin/HEAD Comm
2010-04-07 05:37 +0000 Max Power origin/master Comm
2010-01-20 14:18 +0000 A. U. Thor this_is_really_a_long_long_long_long_long_long_long_tag Comm
2009-12-17 12:49 +0000 René Lévesque v1.0 Comm
[refs] 19455fa3642af6a6a7d527dd043caf5a70eaad2d - reference 1 of 6 100%
Expand All @@ -88,8 +88,8 @@ assert_equals 'refs-checked-out-tag.screen' <<EOF
2010-01-20 14:18 +0000 A. U. Thor HEAD Comm
2010-04-07 05:37 +0000 Max Power master Comm
2010-03-04 04:09 +0000 A. U. Thor this_is_really_a_long_long_long_long_long_long_long_branch Comm
2010-04-07 05:37 +0000 Max Power origin/master Comm
2010-04-07 05:37 +0000 Max Power origin/HEAD Comm
2010-04-07 05:37 +0000 Max Power origin/master Comm
2010-01-20 14:18 +0000 A. U. Thor this_is_really_a_long_long_long_long_long_long_long_tag Comm
[refs] 5cb3412a5e06e506840495b91acc885037a48b72 - reference 5 of 7 87%
EOF

0 comments on commit b7951d1

Please sign in to comment.