For now this obsoletes the action triggered when pressing Enter.
REQ_(SHOW_VERSION, "Show version information"), \
REQ_(STOP_LOADING, "Stop all loading views"), \
REQ_(TOGGLE_LINENO, "Toggle line numbers"), \
REQ_(SHOW_VERSION, "Show version information"), \
REQ_(STOP_LOADING, "Stop all loading views"), \
REQ_(TOGGLE_LINENO, "Toggle line numbers"), \
- REQ_(TOGGLE_REV_GRAPH, "Toggle revision graph visualization")
+ REQ_(TOGGLE_REV_GRAPH, "Toggle revision graph visualization"), \
+ REQ_(STATUS_UPDATE, "Update file status") \
/* User action requests. */
/* User action requests. */
{ '.', REQ_TOGGLE_LINENO },
{ 'g', REQ_TOGGLE_REV_GRAPH },
{ ':', REQ_PROMPT },
{ '.', REQ_TOGGLE_LINENO },
{ 'g', REQ_TOGGLE_REV_GRAPH },
{ ':', REQ_PROMPT },
+ { 'u', REQ_STATUS_UPDATE },
/* Using the ncurses SIGWINCH handler. */
{ KEY_RESIZE, REQ_SCREEN_RESIZE },
/* Using the ncurses SIGWINCH handler. */
{ KEY_RESIZE, REQ_SCREEN_RESIZE },
* User request switch noodle
*/
* User request switch noodle
*/
+static void status_update(struct view *view);
+
static int
view_driver(struct view *view, enum request request)
{
static int
view_driver(struct view *view, enum request request)
{
+ case REQ_STATUS_UPDATE:
+ status_update(view);
+ break;
+
case REQ_NONE:
doupdate();
return TRUE;
case REQ_NONE:
doupdate();
return TRUE;
static bool
status_enter(struct view *view, struct line *line)
{
static bool
status_enter(struct view *view, struct line *line)
{
- struct status *status = line->data;
+ return TRUE;
+}
+
+static bool
+status_update_file(struct view *view, struct status *status, enum line_type type)
+{
char cmd[SIZEOF_STR];
char buf[SIZEOF_STR];
size_t cmdsize = 0;
char cmd[SIZEOF_STR];
char buf[SIZEOF_STR];
size_t cmdsize = 0;
size_t written = 0;
FILE *pipe;
size_t written = 0;
FILE *pipe;
- if (!status)
- return TRUE;
-
- line->type != LINE_STAT_UNTRACKED &&
+ type != LINE_STAT_UNTRACKED &&
!string_format_from(cmd, &cmdsize, "cd %s;", opt_cdup))
return FALSE;
!string_format_from(cmd, &cmdsize, "cd %s;", opt_cdup))
return FALSE;
case LINE_STAT_STAGED:
if (!string_format_from(buf, &bufsize, "%06o %s\t%s%c",
status->old.mode,
case LINE_STAT_STAGED:
if (!string_format_from(buf, &bufsize, "%06o %s\t%s%c",
status->old.mode,
+status_update(struct view *view)
+{
+ if (view == VIEW(REQ_VIEW_STATUS)) {
+ struct line *line = view->lines
+ ? &view->line[view->lineno] : NULL;
+
+ if (!line || !line->data) {
+ report("No file chosen for update");
+ return;
+ }
+
+ if (!status_update_file(view, line->data, line->type))
+ report("Failed to update file status");
+ } else {
+ report("This action is only valid for the status view");
+ }
+}
+
+static void
status_select(struct view *view, struct line *line)
{
char *text;
status_select(struct view *view, struct line *line)
{
char *text;
stop-loading Stop all loading views
toggle-lineno Toggle line numbers
toggle-rev-graph Toggle revision graph visualization
stop-loading Stop all loading views
toggle-lineno Toggle line numbers
toggle-rev-graph Toggle revision graph visualization
+status-update Update file status
------------------------------------------------------------------------------
------------------------------------------------------------------------------