From: René Scharfe <hidden> Date: 2021-08-28 21:30:57
Call fspathcmp() instead of open-coding it. This shortens the code and
makes it less repetitive.
Signed-off-by: René Scharfe <redacted>
---
merge-recursive.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
From: Taylor Blau <hidden> Date: 2021-08-29 20:21:25
Hi René,
On Sat, Aug 28, 2021 at 11:30:49PM +0200, René Scharfe wrote:
quoted hunk
Call fspathcmp() instead of open-coding it. This shortens the code and
makes it less repetitive.
Signed-off-by: René Scharfe <redacted>
---
merge-recursive.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
@@ -55,10 +55,7 @@ static int path_hashmap_cmp(const void *cmp_data,a=container_of(eptr,conststructpath_hashmap_entry,e);b=container_of(entry_or_key,conststructpath_hashmap_entry,e);-if(ignore_case)-returnstrcasecmp(a->path,key?key:b->path);-else-returnstrcmp(a->path,key?key:b->path);+returnfspathcmp(a->path,key?key:b->path);}
Looks obviously right to me. I found another spot in
t/helper/test-hashmap.c:test_entry_cmp() that could be cleaned up in the
same way. But this looks fine with or without the following diff:
From: Jeff King <hidden> Date: 2021-08-29 21:00:21
On Sun, Aug 29, 2021 at 04:21:21PM -0400, Taylor Blau wrote:
quoted hunk
quoted
+++ b/merge-recursive.c
@@ -55,10 +55,7 @@ static int path_hashmap_cmp(const void *cmp_data,
[...]
Looks obviously right to me. I found another spot in
t/helper/test-hashmap.c:test_entry_cmp() that could be cleaned up in the
same way. But this looks fine with or without the following diff:
From: René Scharfe <hidden> Date: 2021-08-30 15:09:44
Am 29.08.21 um 22:21 schrieb Taylor Blau:
quoted hunk
Hi René,
On Sat, Aug 28, 2021 at 11:30:49PM +0200, René Scharfe wrote:
quoted
Call fspathcmp() instead of open-coding it. This shortens the code and
makes it less repetitive.
Signed-off-by: René Scharfe <redacted>
---
merge-recursive.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
@@ -55,10 +55,7 @@ static int path_hashmap_cmp(const void *cmp_data,a=container_of(eptr,conststructpath_hashmap_entry,e);b=container_of(entry_or_key,conststructpath_hashmap_entry,e);-if(ignore_case)-returnstrcasecmp(a->path,key?key:b->path);-else-returnstrcmp(a->path,key?key:b->path);+returnfspathcmp(a->path,key?key:b->path);}
Looks obviously right to me. I found another spot in
t/helper/test-hashmap.c:test_entry_cmp() that could be cleaned up in the
same way. But this looks fine with or without the following diff:
@@ -28,10 +28,7 @@ static int test_entry_cmp(const void *cmp_data,e1=container_of(eptr,conststructtest_entry,ent);e2=container_of(entry_or_key,conststructtest_entry,ent);-if(ignore_case)-returnstrcasecmp(e1->key,key?key:e2->key);-else-returnstrcmp(e1->key,key?key:e2->key);+returnfspathcmp(e1->key,key?key:e2->key);}staticstructtest_entry*alloc_test_entry(unsignedinthash,
That's a local variable named "ignore_case", not the one declared in
environment.c that fspathcmp() uses, so this would change the behavior.
The helper code does not include cache.h, so this is not even a case of
variable shadowing, just two different variables for similar purposes
in different places having the same name.
René
@@ -28,10 +28,7 @@ static int test_entry_cmp(const void *cmp_data,e1=container_of(eptr,conststructtest_entry,ent);e2=container_of(entry_or_key,conststructtest_entry,ent);-if(ignore_case)-returnstrcasecmp(e1->key,key?key:e2->key);-else-returnstrcmp(e1->key,key?key:e2->key);+returnfspathcmp(e1->key,key?key:e2->key);}staticstructtest_entry*alloc_test_entry(unsignedinthash,
That's a local variable named "ignore_case", not the one declared in
environment.c that fspathcmp() uses, so this would change the behavior.
The helper code does not include cache.h, so this is not even a case of
variable shadowing, just two different variables for similar purposes
in different places having the same name.
Yikes, good catch. Perhaps it's overkill, but I wonder if a comment
like:
/*
* Do not use fspathcmp() here; our behavior depends on the local
* ignore_case variable, not the usual Git-wide global.
*/
would help.
I double-checked the spot I suggested. I think it is actually using the
global (though I got it right through sheer luck).
-Peff