Is there a way in git log
to give it as input a line number of a file, and it return the function or class name.
Asked
Active
Viewed 55 times
0

Biffen
- 6,249
- 6
- 28
- 36

Amine Barrak
- 139
- 9
1 Answers
1
In latest version (I'm not sure which version onward) of git
, the option -L
introduced. from this you can print the line changes. it will display the complete content of those lines. you can play with this option to print only range of revisions which explained here
-L <start>,<end>:<file> -L :<funcname>:<file>
Usage: (I don't have any php project, so tested with c Project)
tshetty@ubuntu:~/work/linux$ git log -L 44,44:arch/arm/common/scoop.c
commit 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2
Author: Linus Torvalds <torvalds@ppc970.osdl.org>
Date: Sat Apr 16 15:20:36 2005 -0700
...........................
.................
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c
--- /dev/null
+++ b/arch/arm/common/scoop.c
@@ -0,0 +26,1 @@
+void reset_scoop(struct device *dev)

ntshetty
- 1,293
- 9
- 20
-
actually I mean you give it a line inside a function. And as a result it gives you the name of the function ? – Amine Barrak Mar 29 '18 at 05:57
-
@AmineBarrak as per my git knowledge `git log` doesn't provide such feature directly yet. But you can search for range like `git log -L 0,100:/path/to/file` – ntshetty Mar 29 '18 at 06:46