rasen58
rasen58

Reputation: 5091

Format git diff with newline spacing

Is it possible to add newlines or somehow format the output of git diff when called from the terminal?

Here is an excerpt from one of my git diff's, where after the previous file diff (ending at the last +), the next file diff starts.

+    def loader_collatefn(self, batch_list):
+        return data.dataloader.default_collate(batch_list)
+
+    def __getitem__(self, idx):
+        pass
+
+    def __len__(self):
+        pass
+
diff --git a/dataload/mrds_dataset.py b/dataload/mrds_dataset.py
index 9a5d60a..b751bc7 100644
--- a/dataload/mrds_dataset.py
+++ b/dataload/mrds_dataset.py
@@ -9,6 +9,7 @@ 
 from PIL import Image

 from . import DataPhase
+from . import BaseDataset

But, I think it would be more readable if there were a few newlines between each individual file's diff so that I can more easily see when the next file starts if I'm scrolling through the diff quickly.
Is there a git config option for this?

Upvotes: 2

Views: 791

Answers (1)

eftshift0
eftshift0

Reputation: 30307

Try piping diff output into this:

git diff blah blah blah | sed 's/^diff/\n\n\ndiff/'

That will create the separation

Upvotes: 2

Related Questions