Skip to content

Commit

Permalink
Add "Untracked only" status view
Browse files Browse the repository at this point in the history
  • Loading branch information
koutcher committed Apr 6, 2019
1 parent 228c400 commit b07d66f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
6 changes: 1 addition & 5 deletions include/tig/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ bool status_stage_info_(char *buf, size_t bufsize,
status_stage_info_(buf, sizeof(buf), type, status)
extern struct view status_view;

static inline void
open_status_view(struct view *prev, enum open_flags flags)
{
open_view(prev, &status_view, flags);
}
void open_status_view(struct view *prev, bool untracked_only, enum open_flags flags);

#endif
/* vim: set ts=8 sw=8 noexpandtab: */
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ main_request(struct view *view, enum request request, struct line *line)
|| line->type == LINE_STAT_STAGED)
open_stage_view(view, NULL, line->type, flags);
else if (line->type == LINE_STAT_UNTRACKED)
open_status_view(view, flags);
open_status_view(view, true, flags);
else
open_diff_view(view, flags);
break;
Expand Down
14 changes: 12 additions & 2 deletions src/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
*/

static char status_onbranch[SIZEOF_STR];
static bool show_untracked_only=false;

void
open_status_view(struct view *prev, bool untracked_only, enum open_flags flags)
{
show_untracked_only=untracked_only;
open_view(prev, &status_view, flags | OPEN_REFRESH);
}

/* This should work even for the "On branch" line. */
static inline bool
Expand Down Expand Up @@ -370,8 +378,8 @@ status_open(struct view *view, enum open_flags flags)

update_index();

if (!status_run(view, staged_argv, staged_status, LINE_STAT_STAGED) ||
!status_run(view, status_diff_files_argv, 0, LINE_STAT_UNSTAGED) ||
if ((!show_untracked_only && !status_run(view, staged_argv, staged_status, LINE_STAT_STAGED)) ||
(!show_untracked_only && !status_run(view, status_diff_files_argv, 0, LINE_STAT_UNSTAGED)) ||
!status_read_untracked(view))
return error("Failed to load status data");

Expand Down Expand Up @@ -738,6 +746,8 @@ status_request(struct view *view, enum request request, struct line *line)
return request;
}

if (view->parent)
refresh_view(view->parent);
refresh_view(view);

return REQ_NONE;
Expand Down
2 changes: 1 addition & 1 deletion src/tig.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ view_driver(struct view *view, enum request request)
open_blob_view(view, OPEN_DEFAULT);
break;
case REQ_VIEW_STATUS:
open_status_view(view, OPEN_DEFAULT);
open_status_view(view, false, OPEN_DEFAULT);
break;
case REQ_VIEW_STAGE:
open_stage_view(view, NULL, 0, OPEN_DEFAULT);
Expand Down
14 changes: 7 additions & 7 deletions test/main/untracked-test
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ $YYY_MM_DD_HH_MM +0000 Unknown o Staged changes
[main] Untracked changes 100%
On branch master
Changes to be committed:
M .j
Changes not staged for commit:
M a
M b.c
M e/f
M g h
Untracked files:
? z
[status] Nothing to update 100%
EOF

0 comments on commit b07d66f

Please sign in to comment.