Code

Make open_blob_editor use its own argv show and take blob ID as an argument
authorJonas Fonseca <fonseca@diku.dk>
Mon, 10 May 2010 02:24:44 +0000 (22:24 -0400)
committerJonas Fonseca <fonseca@diku.dk>
Sun, 30 May 2010 04:40:53 +0000 (00:40 -0400)
tig.c

diff --git a/tig.c b/tig.c
index a31d18eb23bd1213610bc94fe78f09e2836bff8d..32f4b648493b2bbfb4aacf16de78ff0240f22e08 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -4662,14 +4662,15 @@ tree_draw(struct view *view, struct line *line, unsigned int lineno)
 }
 
 static void
-open_blob_editor()
+open_blob_editor(const char *id)
 {
+       const char *blob_argv[] = { "git", "cat-file", "blob", id, NULL };
        char file[SIZEOF_STR] = "/tmp/tigblob.XXXXXX";
        int fd = mkstemp(file);
 
        if (fd == -1)
                report("Failed to create temporary file");
-       else if (!io_run_append(blob_ops.argv, FORMAT_ALL, fd))
+       else if (!io_run_append(blob_argv, FORMAT_NONE, fd))
                report("Failed to save blob data to file");
        else
                open_editor(file);
@@ -4681,6 +4682,7 @@ static enum request
 tree_request(struct view *view, enum request request, struct line *line)
 {
        enum open_flags flags;
+       struct tree_entry *entry = line->data;
 
        switch (request) {
        case REQ_VIEW_BLAME:
@@ -4696,7 +4698,7 @@ tree_request(struct view *view, enum request request, struct line *line)
                if (line->type != LINE_TREE_FILE) {
                        report("Edit only supported for files");
                } else if (!is_head_commit(view->vid)) {
-                       open_blob_editor();
+                       open_blob_editor(entry->id);
                } else {
                        open_editor(opt_file);
                }
@@ -4847,7 +4849,7 @@ blob_request(struct view *view, enum request request, struct line *line)
 {
        switch (request) {
        case REQ_EDIT:
-               open_blob_editor();
+               open_blob_editor(view->vid);
                return REQ_NONE;
        default:
                return pager_request(view, request, line);