Skip to content
Versora

Manual

Inspection

Line origin

4 min read

On this page

Blame tells you which commit last touched a line. Often that's not enough: the last commit only reindented the code, renamed the file or brought the line from another file. Line origin picks up where blame stops. It goes back through the history, commit by commit, and shows the line's full path:

  • where it was changed;
  • which file it came from, when it was moved or copied;
  • the file's renames;
  • which merges brought it into the branch;
  • where it was born.

Where to find it

  • Blame: right-click a block › Investigate the origin of line N…. The line is the one under the mouse pointer.
  • Revision tree: right-click a line in a file's content › Investigate the origin of line N….

Step by step

  1. Open the file's blame.
  2. Right-click the line you're interested in and choose Investigate the origin of line N….
  3. The Line origin window opens and starts following the line ("Following the line through the history…"). The top shows the file and the starting version, or "in the working directory".
  4. If you want another line from the same block, change it in the Line picker. The investigation starts over.
  5. Read the steps, from the most recent to the oldest. Each step has:
    • the type of change (table below);
    • the file and the line at that point ("<path>, line N");
    • "came from <path>" when the line was brought from another file;
    • "the file was called <path> before this commit" on a rename;
    • "Arrived through a merge:" or "Arrived through N merges:", with clickable merges, when the commit isn't on the main line of the version being investigated;
    • the commit, with author, date and summary.
  6. Use each step's buttons:
    • Show commit: closes the window and selects the commit in the graph.
    • Blame this version: opens the file's blame in that commit.
    • Blame before this commit: opens the blame of the previous version.
  7. Close with the X or Esc. Closing cancels an investigation in progress.

Step types

TypeWhat it means
ChangedThe commit changed the line. The investigation continues in its previous version.
Written hereThe commit only added lines at that point: the line was born there.
Born with the fileThe line has existed since the commit that created the file.
Brought from another fileThe line was moved or copied from another file in this commit.
RewrittenThe line was replaced by a very different one. The match is uncertain.
OptionWhat it doesDefault
Follow copies and moves between files"Finds out when the line came from another file (git blame -C -C); slower"Checked
Ignore whitespace-only changes"An indentation-only change doesn't count as authorship (git blame -w)"Unchecked

Changing an option restarts the investigation.

How Versora follows the line

Each step is a git blame of a single line, in the version at that point:

bash
git blame --porcelain -M12 [-w] -L <line>,<line> <commit> -- <file>
# with "Follow copies", a second blame finds out whether the line came from another file:
git blame --porcelain -M12 -C12 -C12 [-w] -L <line>,<line> <commit> -- <file>

The 12 is the minimum number of characters for git to recognize a moved or copied line. Git's default (20 for -M, 40 for -C) was designed for blocks, and with it almost no single line would be recognized as coming from somewhere else. The difference between the two blames is precisely the commit that brought the line into the current file.

Blame tells you which commit wrote the line, but not what the line was before it. To take the next step, Versora reads that commit's diff:

  • if the hunk only added lines, the line was born there and the investigation ends;
  • if it replaced lines, the one most similar to the current line is the previous version, and the investigation continues with it, in the parent commit;
  • if none is similar enough (less than 35% similarity), the step is marked Rewritten and the investigation stops.

Between one step and the next, if the commit isn't in the first-parent chain of the version being investigated, Versora computes which merges brought it in.

Everything is read only: nothing changes in the repository.

How to undo

There's nothing to undo.

Caveats and messages

  • "Origin found in N steps.": the investigation reached the line's birth.
  • "Stopped after N steps; you can continue from there.": each round goes up to 30 steps. Click Continue to go on from where it stopped. The new steps are added to the end of the list.
  • "Uncertain match: the line seems to have been rewritten in this commit.": with the note "The replaced lines don't look like this one (N% similar): most likely it was written here.". If you still want to follow the most similar line, use Continue anyway.
  • "The line hasn't been committed yet: there's no history to follow.": the line only exists on disk.
  • "Couldn't follow the line beyond this point.": the history doesn't allow taking the next step.
  • "The path through merges wasn't computed in time (very large history).": computing a step's merges has a 20-second deadline. The rest of the step is still valid.
  • "the file was renamed later": appears when the file name in the next step is different.
  • "Couldn't find who wrote line N of <path>.": git couldn't annotate that line.
  • "Choose a line (starting at 1).": the line you entered isn't valid.
  • "Analysis canceled.": you closed the window or changed the line midway.

Line origin has no preference of its own and no company policy key.

See also