I'm using git 2.14.1 on Linux/x86-64/Debian/Sid. I don't have any shell environment variable with GIT. I've read the git diff format page. Here is output of git config -l, for my current project (on github) bismon :
user.name=Basile Starynkevitch
[email protected]
push.default=simple
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
[email protected]:bstarynk/bismon.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
When I do a git diff on some C file like main_BM.c I'm getting an output like
diff --git a/main_BM.c b/main_BM.c
index 3639a52..9c43d9e 100644
--- a/main_BM.c
+++ b/main_BM.c
@@ -371,6 +371,7 @@ rungui_BM (void)
}
if (gui_command_log_file_BM)
{
+ /// the current time
{
time_t nowtim = time (NULL);
struct tm nowtm = { };
Notice the chunk header line @@ -371,6 +371,7 @@ rungui_BM (void); it shows a function name (e.g. rungui_BM), and I don't understand why and how (but I like that).
I have also several .bismon textual files (machine generated, but versioned under git, and could be considered as some simplistic domain specific language). For example my store2.bismon contains stuff like
!(_0277f6mOd9j_0tVZSXnTzUK |=basiclo_temporary_module|
!~ name (~ basiclo_temporary_module
~)
!@ 1504862208.05
!$_0LK4TzFd6u1_0JFUsrQ4odG |=class|
!: _01h86SAfOfg_1q2oMegGRwW |=comment|
"class of temporary modules containing only functions for closures"
!~ class (~ |supercl plain_temporary_module:| _1oEp0eAAyFN_4lsobepyr1T
~)
!)_0277f6mOd9j_0tVZSXnTzUK
(My store*.bismon have their own format -that I defined and could slightly change if convenient- and basically represents a dump of the persistent memory heap of some interpreter)
From the point of view of git diff, I would like that any line similar to
!(_0277f6mOd9j_0tVZSXnTzUK |=basiclo_temporary_module|
(that is any line starting with !(_ followed by 11 alphanumerical characters followed by _ followed by 11 alphanumerical characters) be considered by git diff as a function start and displayed by git diff in the @@ chunk header.
Currently git diff store2.bismon don't give nice chunk headers like I would want them:
diff --git a/store2.bismon b/store2.bismon
index edbb2f7..3847b6b 100644
--- a/store2.bismon
+++ b/store2.bismon
@@ -6,7 +6,13 @@
!(_0277f6mOd9j_0tVZSXnTzUK |=basiclo_temporary_module|
!~ name (~ basiclo_temporary_module
~)
-!@ 1504861742.79
+!@ 1504862208.05
+!$_0LK4TzFd6u1_0JFUsrQ4odG |=class|
+!: _01h86SAfOfg_1q2oMegGRwW |=comment|
+ "class of temporary modules containing only functions for closures"
+!~ class (~ |supercl plain_temporary_module:| _1oEp0eAAyFN_4lsobepyr1T
+~)
+
!)_0277f6mOd9j_0tVZSXnTzUK
I would like the chunk header line @@ -6,7 +6,13 @@ to be something like:
@@ -6,7 +6,13 @@ !(_0277f6mOd9j_0tVZSXnTzUK |=basiclo_temporary_module|
Maybe I need to have some GIT_EXTERNAL_DIFF set to some script. But how is that thing invoked and by what subpart of git?
If possible, I would like the colors used by git diff to stay the same.
The solution is to define a custom hunk-header:
echo '*.bismon diff=bismon' > .gitattributes
git config diff.bismon.xfuncname '^!\(_.*$'
You can adapt the regexp for more accuracy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With