summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 58fc3b1)
raw | patch | inline | side by side (parent: 58fc3b1)
author | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 7 Oct 2008 23:00:12 +0000 (01:00 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 8 Oct 2008 07:06:33 +0000 (09:06 +0200) |
NEWS | patch | blob | history | |
tig.c | patch | blob | history |
index dd1cc170d6739a20f980ebdb29078d27b770316c..d7633b37aaa39e46bbd3c115ae459cf567794d76 100644 (file)
--- a/NEWS
+++ b/NEWS
Improvements:
- - Checkout files with unstaged changes. Bound to '!' by default.
- - Main view: use --topo-order also when rev-list arguments are given on the
- command line.
+ - Status view: revert unstaged files with changes and diff chunks.
+ Bound to '!' by default.
+ - Main view: use --topo-order also when rev-list arguments are given on
+ the command line.
- Log view: support for refreshing.
Bug fixes:
index e64d72aefeb00afb1118b30a748396a02243e127..5c456e723bf1fea3b55382d3e5fd1b10431159a7 100644 (file)
--- a/tig.c
+++ b/tig.c
\
REQ_GROUP("View specific requests") \
REQ_(STATUS_UPDATE, "Update file status"), \
- REQ_(STATUS_CHECKOUT, "Checkout file"), \
+ REQ_(STATUS_REVERT, "Revert file changes"), \
REQ_(STATUS_MERGE, "Merge file using external tool"), \
REQ_(STAGE_NEXT, "Find next chunk to stage"), \
REQ_(TREE_PARENT, "Switch to parent directory in tree view"), \
{ 'F', REQ_TOGGLE_REFS },
{ ':', REQ_PROMPT },
{ 'u', REQ_STATUS_UPDATE },
- { '!', REQ_STATUS_CHECKOUT },
+ { '!', REQ_STATUS_REVERT },
{ 'M', REQ_STATUS_MERGE },
{ '@', REQ_STAGE_NEXT },
{ ',', REQ_TREE_PARENT },
}
static bool
-status_checkout(struct status *status, enum line_type type, bool has_none)
+status_revert(struct status *status, enum line_type type, bool has_none)
{
if (!status || type != LINE_STAT_UNSTAGED) {
if (type == LINE_STAT_STAGED) {
- report("Cannot checkout staged files");
+ report("Cannot revert changes to staged files");
} else if (type == LINE_STAT_UNTRACKED) {
- report("Cannot checkout untracked files");
+ report("Cannot revert changes to untracked files");
} else if (has_none) {
- report("Nothing to checkout");
+ report("Nothing to revert");
} else {
- report("Cannot checkout multiple files");
+ report("Cannot revert changes to multiple files");
}
return FALSE;
return REQ_NONE;
break;
- case REQ_STATUS_CHECKOUT:
- if (!status_checkout(status, line->type, status_has_none(view, line)))
+ case REQ_STATUS_REVERT:
+ if (!status_revert(status, line->type, status_has_none(view, line)))
return REQ_NONE;
break;
}
static bool
-stage_update_chunk(struct view *view, struct line *chunk)
+stage_apply_chunk(struct view *view, struct line *chunk, bool revert)
{
char cmd[SIZEOF_STR];
size_t cmdsize = 0;
return FALSE;
if (!string_format_from(cmd, &cmdsize,
- "git apply --whitespace=nowarn --cached %s - && "
+ "git apply --whitespace=nowarn %s %s - && "
"git update-index -q --unmerged --refresh 2>/dev/null",
- stage_line_type == LINE_STAT_STAGED ? "-R" : ""))
+ revert ? "" : "--cached",
+ revert || stage_line_type == LINE_STAT_STAGED ? "-R" : ""))
return FALSE;
pipe = popen(cmd, "w");
chunk = stage_diff_find(view, line, LINE_DIFF_CHUNK);
if (chunk) {
- if (!stage_update_chunk(view, chunk)) {
+ if (!stage_apply_chunk(view, chunk, FALSE)) {
report("Failed to apply chunk");
return FALSE;
}
return TRUE;
}
+static bool
+stage_revert(struct view *view, struct line *line)
+{
+ struct line *chunk = NULL;
+
+ if (!opt_no_head && stage_line_type == LINE_STAT_UNSTAGED)
+ chunk = stage_diff_find(view, line, LINE_DIFF_CHUNK);
+
+ if (chunk) {
+ if (!prompt_yesno("Are you sure you want to revert changes?"))
+ return FALSE;
+
+ if (!stage_apply_chunk(view, chunk, TRUE)) {
+ report("Failed to revert chunk");
+ return FALSE;
+ }
+ return TRUE;
+
+ } else {
+ return status_revert(stage_status.status ? &stage_status : NULL,
+ stage_line_type, FALSE);
+ }
+}
+
+
static void
stage_next(struct view *view, struct line *line)
{
return REQ_NONE;
break;
- case REQ_STATUS_CHECKOUT:
- if (!status_checkout(stage_status.status ? &stage_status : NULL,
- stage_line_type, FALSE))
+ case REQ_STATUS_REVERT:
+ if (!stage_revert(view, line))
return REQ_NONE;
break;