From: jipey Date: Mon, 29 Mar 2010 02:49:08 +0000 (-0400) Subject: Branch view: add %(branch) variable tracking currently selected branch X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7332344186ab02b45babce8299162b1b56ad7cc0;p=tig.git Branch view: add %(branch) variable tracking currently selected branch This makes it possible to easily change branches from the branch view. [ jf: updated docs, added NEWS entry, added checkout run request ] Signed-off-by: Jonas Fonseca --- diff --git a/NEWS b/NEWS index 07198d3..bce72eb 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ Improvements: - Status view: update the file variable when a line is selected so %(file) works as expected. + - Branch view: add %(branch) symbol providing access to the selected + branch. - Branch view: add entry to browse all branches (uses git-log's --all flag). - Abbreviation of author names can now be configured and toggled. diff --git a/manual.txt b/manual.txt index 5fd9c51..cfc26c6 100644 --- a/manual.txt +++ b/manual.txt @@ -153,6 +153,7 @@ following variables. |%(head) |The currently viewed 'head' ID. Defaults to HEAD |%(commit) |The currently selected commit ID. |%(blob) |The currently selected blob ID. +|%(branch) |The currently selected branch name. |%(directory) |The current directory path in the tree view; empty for the root directory. |%(file) |The currently selected file. diff --git a/tig.c b/tig.c index 826c3f9..c8ab944 100644 --- a/tig.c +++ b/tig.c @@ -1730,6 +1730,7 @@ static void add_builtin_run_requests(void) { const char *cherry_pick[] = { "git", "cherry-pick", "%(commit)", NULL }; + const char *checkout[] = { "git", "checkout", "%(branch)", NULL }; const char *commit[] = { "git", "commit", NULL }; const char *gc[] = { "git", "gc", NULL }; struct { @@ -1740,6 +1741,7 @@ add_builtin_run_requests(void) } reqs[] = { { KEYMAP_MAIN, 'C', ARRAY_SIZE(cherry_pick) - 1, cherry_pick }, { KEYMAP_STATUS, 'C', ARRAY_SIZE(commit) - 1, commit }, + { KEYMAP_BRANCH, 'C', ARRAY_SIZE(checkout) - 1, checkout }, { KEYMAP_GENERIC, 'G', ARRAY_SIZE(gc) - 1, gc }, }; int i; @@ -2157,6 +2159,7 @@ static unsigned int current_view; static char ref_blob[SIZEOF_REF] = ""; static char ref_commit[SIZEOF_REF] = "HEAD"; static char ref_head[SIZEOF_REF] = "HEAD"; +static char ref_branch[SIZEOF_REF] = ""; struct view { const char *name; /* View name */ @@ -3112,6 +3115,7 @@ format_arg(const char *name) FORMAT_VAR("%(head)", ref_head, ""), FORMAT_VAR("%(commit)", ref_commit, ""), FORMAT_VAR("%(blob)", ref_blob, ""), + FORMAT_VAR("%(branch)", ref_branch, ""), }; int i; @@ -5440,6 +5444,7 @@ branch_select(struct view *view, struct line *line) string_copy_rev(view->ref, branch->ref->id); string_copy_rev(ref_commit, branch->ref->id); string_copy_rev(ref_head, branch->ref->id); + string_copy_rev(ref_branch, branch->ref->name); } static struct view_ops branch_ops = { diff --git a/tigrc.5.txt b/tigrc.5.txt index d33056a..575164e 100644 --- a/tigrc.5.txt +++ b/tigrc.5.txt @@ -222,6 +222,7 @@ are: |%(head) |The currently viewed 'head' ID. Defaults to HEAD |%(commit) |The currently selected commit ID. |%(blob) |The currently selected blob ID. +|%(branch) |The currently selected branch name. |%(directory) |The current directory path in the tree view; empty for the root directory. |%(file) |The currently selected file.