summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7440d5c)
raw | patch | inline | side by side (parent: 7440d5c)
author | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 3 Feb 2009 14:46:07 +0000 (15:46 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 3 Feb 2009 15:21:55 +0000 (16:21 +0100) |
... by using update-index --cacheinfo.
NEWS | patch | blob | history | |
tig.c | patch | blob | history |
index 59ad19e8035ae38f5ce3d44d455365e5599f54f8..7f8e98e406223a538ac5489708003b4efe90d312 100644 (file)
--- a/NEWS
+++ b/NEWS
Bug fixes:
- Tree view: fix memory corruption bug when updating.
+ - Status view: fix reverting of unmerged files.
- Fix regression for non-UTF-8 locales corrupting the view data.
- Fix regression parsing multiple spaces in ~/.tigrc.
index 8fd5288f4a654660693dc95b8b447c501d66e4d6..27563e19670e252a8bf90b85416a30d8a15cdb12 100644 (file)
--- a/tig.c
+++ b/tig.c
static bool
status_run(struct view *view, const char *argv[], char status, enum line_type type)
{
- struct status *file = NULL;
struct status *unmerged = NULL;
char *buf;
struct io io = {};
@@ -4631,6 +4630,8 @@ status_run(struct view *view, const char *argv[], char status, enum line_type ty
add_line_data(view, NULL, type);
while ((buf = io_get(&io, 0, TRUE))) {
+ struct status *file = unmerged;
+
if (!file) {
file = calloc(1, sizeof(*file));
if (!file || !add_line_data(view, file, type))
@@ -4643,7 +4644,7 @@ status_run(struct view *view, const char *argv[], char status, enum line_type ty
if (status == 'A')
string_copy(file->old.rev, NULL_ID);
- } else if (!file->status) {
+ } else if (!file->status || file == unmerged) {
if (!status_get_diff(file, buf, strlen(buf)))
goto error_out;
@@ -4653,19 +4654,11 @@ status_run(struct view *view, const char *argv[], char status, enum line_type ty
/* Collapse all 'M'odified entries that follow a
* associated 'U'nmerged entry. */
- if (file->status == 'U') {
- unmerged = file;
-
- } else if (unmerged) {
- int collapse = !strcmp(buf, unmerged->new.name);
-
+ if (unmerged == file) {
+ unmerged->status = 'U';
unmerged = NULL;
- if (collapse) {
- free(file);
- file = NULL;
- view->lines--;
- continue;
- }
+ } else if (file->status == 'U') {
+ unmerged = file;
}
}
return FALSE;
} else {
+ char mode[10] = "100644";
+ const char *reset_argv[] = {
+ "git", "update-index", "--cacheinfo", mode,
+ status->old.rev, status->old.name, NULL
+ };
const char *checkout_argv[] = {
"git", "checkout", "--", status->old.name, NULL
};
if (!prompt_yesno("Are you sure you want to overwrite any changes?"))
return FALSE;
- return run_io_fg(checkout_argv, opt_cdup);
+ string_format(mode, "%o", status->old.mode);
+ return (status->status != 'U' || run_io_fg(reset_argv, opt_cdup)) &&
+ run_io_fg(checkout_argv, opt_cdup);
}
}