{"id":17442596,"url":"https://github.com/jez/diff-locs","last_synced_at":"2025-04-13T08:21:00.105Z","repository":{"id":73797775,"uuid":"161969044","full_name":"jez/diff-locs","owner":"jez","description":"List the file locations involved in a diff","archived":false,"fork":false,"pushed_at":"2019-06-10T17:16:04.000Z","size":25,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T00:11:06.507Z","etag":null,"topics":["cli"],"latest_commit_sha":null,"homepage":"https://blog.jez.io/surgery-on-code/","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-16T04:55:32.000Z","updated_at":"2024-01-09T08:36:20.000Z","dependencies_parsed_at":"2023-03-25T11:18:45.410Z","dependency_job_id":null,"html_url":"https://github.com/jez/diff-locs","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fdiff-locs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fdiff-locs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fdiff-locs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fdiff-locs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jez","download_url":"https://codeload.github.com/jez/diff-locs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681598,"owners_count":21144715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli"],"created_at":"2024-10-17T16:18:30.898Z","updated_at":"2025-04-13T08:21:00.081Z","avatar_url":"https://github.com/jez.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# diff-locs\n\n[![Build diff-locs Status](https://travis-ci.org/jez/diff-locs.svg?branch=master)](https://travis-ci.org/jez/diff-locs)\n\n\u003e List the filename:line pairs involved in a diff\n\n`diff-locs` takes a text diff (like, the output of `git diff`) and lists the\nfilename + line number pairs involved. This is useful in conjunction with other\ntools that operate on such pairs:\n\n- [`multi-grep`] is a tool that searches for a pattern in a specific set of\n  lines\n- [`multi-sub`] is a tool that substitutes within a specific set of lines\n- In Vim, pressing `gf` or `gF` will open the file under the cursor at the\n  specific line\n\n[`multi-grep`]: https://github.com/jez/multi-grep\n[`multi-sub`]: https://github.com/jez/multi-sub\n\nFor example, given this `git show` diff output:\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to expand diff output\u003c/summary\u003e\n\n```diff\n❯ git show 3f1b8e9 -- app/Main.hs\ncommit 3f1b8e9705e414a80203bf642fd708fd77f28dfc\nAuthor: Jake Zimmerman \u003czimmerman.jake@gmail.com\u003e\nDate:   15 minutes ago\n\n    Show warning message if stdin is a tty\n\ndiff --git a/app/Main.hs b/app/Main.hs\nindex 16d01e4..b0ecbd9 100644\n--- a/app/Main.hs\n+++ b/app/Main.hs\n@@ -1,12 +1,16 @@\n+{-# LANGUAGE LambdaCase     #-}\n {-# LANGUAGE NamedFieldPuns #-}\n module Main where\n\n-import qualified System.IO          as IO\n+import           Control.Monad         (when)\n+import qualified System.IO             as IO\n+import           System.Posix.IO       (stdInput)\n+import           System.Posix.Terminal (queryTerminal)\n\n import           DiffLocs.InputLoop\n import           DiffLocs.Options\n import           DiffLocs.Types\n-import           Paths_diff_locs    (version)\n+import           Paths_diff_locs       (version)\n\n main :: IO ()\n main = do\n@@ -15,6 +19,10 @@ main = do\n   fileIn \u003c- case optionsInput of\n     -- Leak the file handle because we're short lived anyways\n     InputFromFile filename -\u003e IO.openFile filename IO.ReadMode\n-    InputFromStdin         -\u003e return IO.stdin\n+    InputFromStdin         -\u003e do\n+      isTTY \u003c- queryTerminal stdInput\n+      when isTTY $ do\n+        IO.hPutStrLn IO.stderr \"Warning: reading from stdin, which is a tty.\"\n+      return IO.stdin\n\n   run $ Config {configFileIn = fileIn, configWhichLines = optionsWhichLines}\n```\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n... you can run `diff-locs` to show the added / modified lines:\n\n```\n❯ git show 3f1b8e9 -- app/Main.hs | diff-locs\napp/Main.hs:1\napp/Main.hs:5\napp/Main.hs:6\napp/Main.hs:7\napp/Main.hs:8\napp/Main.hs:13\napp/Main.hs:22\napp/Main.hs:23\napp/Main.hs:24\napp/Main.hs:25\napp/Main.hs:26\n```\n\nor pass a flag and see all lines affected (both added and removed):\n\n```\n❯ git show 3f1b8e9 -- app/Main.hs | diff-locs --all\n+app/Main.hs:1\n-app/Main.hs:4\n+app/Main.hs:5\n+app/Main.hs:6\n+app/Main.hs:7\n+app/Main.hs:8\n-app/Main.hs:9\n+app/Main.hs:13\n-app/Main.hs:18\n+app/Main.hs:22\n+app/Main.hs:23\n+app/Main.hs:24\n+app/Main.hs:25\n+app/Main.hs:26\n```\n\n\n## Install\n\n### macOS\n\n```\nbrew install jez/formulae/diff-locs\n```\n\n### Linux\n\nCheck the [Releases] page for pre-built 64-bit binaries for Linux.\n\n[Releases]: https://github.com/jez/diff-locs/releases\n\n### From source\n\nTo build this project from source, use Haskell's [Stack].\n\n[Stack]: https://docs.haskellstack.org/en/stable/\n\n```\ngit clone https://github.com/jez/diff-locs.git\n\nstack build \u0026\u0026 stack install\n```\n\nIf you've packaged this software for your operating system, let me know and I\ncan link to it from these instructions.\n\n\n## License\n\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://jez.io/MIT-LICENSE.txt)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjez%2Fdiff-locs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjez%2Fdiff-locs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjez%2Fdiff-locs/lists"}