summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 33623c0)
raw | patch | inline | side by side (parent: 33623c0)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 1 Oct 2008 15:30:37 +0000 (17:30 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 1 Oct 2008 15:30:37 +0000 (17:30 +0200) |
tig.c | patch | blob | history |
index 15a42a436bf83e71cc6c0d4e41897fb7e24a05a5..0360e173457a455d4d266b46ee338ac19e4fefba 100644 (file)
--- a/tig.c
+++ b/tig.c
static size_t stage_chunks;
static int *stage_chunk;
+/* This should work even for the "On branch" line. */
+static inline bool
+status_has_none(struct view *view, struct line *line)
+{
+ return line < view->line + view->lines && !line[1].data;
+}
+
/* Get fields from the diff line:
* :100644 100644 06a5d6ae9eca55be2e0e585a152e6b1336f2b20e 0000000000000000000000000000000000000000 M
*/
}
static bool
-status_checkout(struct view *view)
+status_checkout(struct status *status, enum line_type type, bool has_next)
{
- struct line *line = &view->line[view->lineno];
-
- assert(view->lines);
-
- if (!line->data || line->type != LINE_STAT_UNSTAGED) {
- /* This should work even for the "On branch" line. */
- if (line < view->line + view->lines && !line[1].data) {
+ if (!status || type != LINE_STAT_UNSTAGED) {
+ if (has_next) {
report("Nothing to checkout");
- } else if (line->type == LINE_STAT_UNTRACKED) {
+ } else if (type == LINE_STAT_UNTRACKED) {
report("Cannot checkout untracked files");
- } else if (line->type == LINE_STAT_STAGED) {
+ } else if (type == LINE_STAT_STAGED) {
report("Cannot checkout staged files");
} else {
report("Cannot checkout multiple files");
return FALSE;
} else {
- struct status *status = line->data;
char cmd[SIZEOF_STR];
char file_sq[SIZEOF_STR];
break;
case REQ_STATUS_CHECKOUT:
- if (!status_checkout(view))
+ if (!status_checkout(status, line->type, status_has_none(view, line)))
return REQ_NONE;
break;
return REQ_NONE;
break;
+ case REQ_STATUS_CHECKOUT:
+ if (!status_checkout(&stage_status, stage_line_type, FALSE))
+ return REQ_NONE;
+ break;
+
case REQ_STAGE_NEXT:
if (stage_line_type == LINE_STAT_UNTRACKED) {
report("File is untracked; press %s to add",