Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/tig/argv.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ typedef unsigned long argv_number;
struct argv_env {
ARGV_ENV_INFO(ARGV_ENV_FIELDS)
unsigned long goto_lineno;
unsigned long blame_lineno;
char goto_id[SIZEOF_REV];
char search[SIZEOF_STR];
char none[1];
Expand Down
2 changes: 0 additions & 2 deletions include/tig/blame.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#include "tig/view.h"

extern struct view blame_view;
extern char *filename_from_blame;
extern unsigned long lineno_from_blame;

static inline void
open_blame_view(struct view *prev, enum open_flags flags)
Expand Down
1 change: 0 additions & 1 deletion include/tig/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ enum open_flags {
OPEN_PREPARED = 32, /* Open already prepared command. */
OPEN_EXTRA = 64, /* Open extra data from command. */
OPEN_WITH_STDERR = 128, /* Redirect stderr to stdin. */
OPEN_BLAMED_LINE = 256, /* Open the file and line stored by blame view */

OPEN_PAGER_MODE = OPEN_STDIN | OPEN_FORWARD_STDIN,
OPEN_ALWAYS_LOAD = OPEN_RELOAD | OPEN_REFRESH | OPEN_PREPARED | OPEN_EXTRA | OPEN_PAGER_MODE,
Expand Down
13 changes: 3 additions & 10 deletions src/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* GNU General Public License for more details.
*/

#include "tig/blame.h"
#include "tig/io.h"
#include "tig/refdb.h"
#include "tig/repo.h"
Expand All @@ -24,9 +23,6 @@
#include "tig/diff.h"
#include "tig/main.h"

char *filename_from_blame = NULL;
unsigned long lineno_from_blame;

/*
* Blame backend
*/
Expand Down Expand Up @@ -455,12 +451,9 @@ blame_request(struct view *view, enum request request, struct line *line)
if (diff->pipe)
string_copy_rev(diff->ref, NULL_ID);
} else {
if (filename_from_blame) {
free(filename_from_blame);
}
filename_from_blame = strdup(blame->commit->filename);
lineno_from_blame = blame -> lineno;
open_diff_view(view, flags | OPEN_RELOAD | OPEN_BLAMED_LINE);
string_ncopy(view->env->file, blame->commit->filename, strlen(blame->commit->filename));
view->env->blame_lineno = blame->lineno;
open_diff_view(view, flags | OPEN_RELOAD);
}
break;

Expand Down
18 changes: 9 additions & 9 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/

#include "tig/argv.h"
#include "tig/blame.h"
#include "tig/refdb.h"
#include "tig/repo.h"
#include "tig/options.h"
Expand Down Expand Up @@ -453,14 +452,6 @@ diff_save_line(struct view *view, struct diff_state *state, enum open_flags flag
state->pos = view->pos;
}
}
if (flags & OPEN_BLAMED_LINE) {
const char *file = filename_from_blame;
if (file) {
state->file = get_path(file);
state->lineno = lineno_from_blame;
state->pos.offset = 5; // TODO: Should be half screen
}
}
}

void
Expand Down Expand Up @@ -552,6 +543,15 @@ diff_read(struct view *view, struct buffer *buf, bool force_stop)
}
}

if (view->env->blame_lineno) {
state->file = get_path(view->env->file);
state->lineno = view->env->blame_lineno;
state->pos.offset = 0;
state->pos.lineno = view->lines - 1;

view->env->blame_lineno = 0;
}

diff_restore_line(view, state);

if (!state->adding_describe_ref && !ref_list_contains_tag(view->vid)) {
Expand Down
20 changes: 10 additions & 10 deletions test/blame/default-test
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,24 @@ assert_equals 'blame-with-diff.screen' <<EOF
4779f9b Jonas Fonseca 2013-11-26 20:13 -0500 8| object ScalaJSBenchmarks
90286e0 Jonas Fonseca 2013-10-14 13:15 -0400 9|
[blame] 74537d9b257954056d3caa19eb3837500aded883 changed project/Build.scala 14%

diff --git a/project/Build.scala b/project/Build.scala
index 560bca1..1713681 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -1,7 +1,7 @@
import sbt._
import Keys._

-import ch.epfl.lamp.sbtscalajs._
+import scala.scalajs.sbtplugin._
import ScalaJSPlugin._
import ScalaJSKeys._





[diff] Changes to 'project/Build.scala' - line 20 of 24 100%
EOF

Expand All @@ -103,20 +103,20 @@ assert_equals 'blame-with-diff-no-file-filter.screen' <<EOF
4779f9b Jonas Fonseca 2013-11-26 20:13 -0500 8| object ScalaJSBenchmarks
90286e0 Jonas Fonseca 2013-10-14 13:15 -0400 9|
[blame] 74537d9b257954056d3caa19eb3837500aded883 changed project/Build.scala 14%

diff --git a/project/Build.scala b/project/Build.scala
index 560bca1..1713681 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -1,7 +1,7 @@
import sbt._
import Keys._

-import ch.epfl.lamp.sbtscalajs._
+import scala.scalajs.sbtplugin._
import ScalaJSPlugin._
import ScalaJSKeys._

diff --git a/project/build.sbt b/project/build.sbt
index 63f84d4..f5971c3 100644
--- a/project/build.sbt
Expand Down
129 changes: 0 additions & 129 deletions test/blame/open-diff-test

This file was deleted.

Loading