[dpdk-dev] improve git diff

Message ID 1478706261-31261-1-git-send-email-thomas.monjalon@6wind.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
checkpatch/checkpatch success coding style OK

Commit Message

Thomas Monjalon Nov. 9, 2016, 3:44 p.m. UTC
  Sometimes git does not print the name of the function being changed
after @@. It happens especially after a goto label which is not indented.
Giving a hint about the languages of files .c, .h and .py
will improve hunk headers of "git diff" rendering.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 .gitattributes | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 .gitattributes
  

Comments

Ferruh Yigit Nov. 11, 2016, 11:22 a.m. UTC | #1
On 11/9/2016 3:44 PM, Thomas Monjalon wrote:
> Sometimes git does not print the name of the function being changed
> after @@. It happens especially after a goto label which is not indented.
> Giving a hint about the languages of files .c, .h and .py
> will improve hunk headers of "git diff" rendering.
> 
> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> ---
>  .gitattributes | 3 +++
>  1 file changed, 3 insertions(+)
>  create mode 100644 .gitattributes
> 
> diff --git a/.gitattributes b/.gitattributes
> new file mode 100644
> index 0000000..fe555f8
> --- /dev/null
> +++ b/.gitattributes
> @@ -0,0 +1,3 @@
> +*.c   diff=cpp
> +*.h   diff=cpp

Can't git auto detect to use C/C++ language diff use for .c/.h files?

Do you have a sample that generates bad hunk header, just to test?

> +*.py  diff=python
>
  
Thomas Monjalon Nov. 11, 2016, 4:21 p.m. UTC | #2
2016-11-11 11:22, Ferruh Yigit:
> On 11/9/2016 3:44 PM, Thomas Monjalon wrote:
> > Sometimes git does not print the name of the function being changed
> > after @@. It happens especially after a goto label which is not indented.
> > Giving a hint about the languages of files .c, .h and .py
> > will improve hunk headers of "git diff" rendering.
> > 
> > Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
[...]
> > --- /dev/null
> > +++ b/.gitattributes
> > @@ -0,0 +1,3 @@
> > +*.c   diff=cpp
> > +*.h   diff=cpp
> 
> Can't git auto detect to use C/C++ language diff use for .c/.h files?

No

> Do you have a sample that generates bad hunk header, just to test?

Yes, you'll find a lot of them with "git log -p | grep '@@.*:'"
Example:
	git show bb6722f | grep '@@.*:'
Without the patch, it is a goto label in the hunk header.
  
Ferruh Yigit Nov. 11, 2016, 5:28 p.m. UTC | #3
On 11/11/2016 4:21 PM, Thomas Monjalon wrote:
> 2016-11-11 11:22, Ferruh Yigit:
>> On 11/9/2016 3:44 PM, Thomas Monjalon wrote:
>>> Sometimes git does not print the name of the function being changed
>>> after @@. It happens especially after a goto label which is not indented.
>>> Giving a hint about the languages of files .c, .h and .py
>>> will improve hunk headers of "git diff" rendering.
>>>
>>> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> [...]
>>> --- /dev/null
>>> +++ b/.gitattributes
>>> @@ -0,0 +1,3 @@
>>> +*.c   diff=cpp
>>> +*.h   diff=cpp
>>
>> Can't git auto detect to use C/C++ language diff use for .c/.h files?
> 
> No
> 
>> Do you have a sample that generates bad hunk header, just to test?
> 
> Yes, you'll find a lot of them with "git log -p | grep '@@.*:'"
> Example:
> 	git show bb6722f | grep '@@.*:'
> Without the patch, it is a goto label in the hunk header.
> 

You are right, I was expecting better from git J
  
Thomas Monjalon Nov. 12, 2016, 8:51 p.m. UTC | #4
2016-11-11 17:28, Ferruh Yigit:
> On 11/11/2016 4:21 PM, Thomas Monjalon wrote:
> > 2016-11-11 11:22, Ferruh Yigit:
> >> On 11/9/2016 3:44 PM, Thomas Monjalon wrote:
> >>> Sometimes git does not print the name of the function being changed
> >>> after @@. It happens especially after a goto label which is not indented.
> >>> Giving a hint about the languages of files .c, .h and .py
> >>> will improve hunk headers of "git diff" rendering.
> >>>
> >>> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> > [...]
> >>> --- /dev/null
> >>> +++ b/.gitattributes
> >>> @@ -0,0 +1,3 @@
> >>> +*.c   diff=cpp
> >>> +*.h   diff=cpp
> >>
> >> Can't git auto detect to use C/C++ language diff use for .c/.h files?
> > 
> > No
> > 
> >> Do you have a sample that generates bad hunk header, just to test?
> > 
> > Yes, you'll find a lot of them with "git log -p | grep '@@.*:'"
> > Example:
> > 	git show bb6722f | grep '@@.*:'
> > Without the patch, it is a goto label in the hunk header.
> > 
> 
> You are right, I was expecting better from git J

Sometimes, less is more :)
  
Thomas Monjalon Nov. 13, 2016, 2:21 p.m. UTC | #5
2016-11-09 16:44, Thomas Monjalon:
> Sometimes git does not print the name of the function being changed
> after @@. It happens especially after a goto label which is not indented.
> Giving a hint about the languages of files .c, .h and .py
> will improve hunk headers of "git diff" rendering.
> 
> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>

Applied
  

Patch

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..fe555f8
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,3 @@ 
+*.c   diff=cpp
+*.h   diff=cpp
+*.py  diff=python