View Issue Details

IDProjectCategoryView StatusLast Update
0000176fileGeneralpublic2020-08-09 16:57
Reportervinc17 Assigned Tochristos  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version5.38 
Fixed in Version5.40 
Summary0000176: Messages for Git objects have an incorrect id
DescriptionThe messages for Git objects have an incorrect id: only the first sequence of decimal digits is retrieved instead of the full sequence of hexadecimal digits. This is due to a bad regexp in "magic/Magdir/git".
Steps To Reproduce$ echo "commit d617e0c0ca8fac42361b00c8861eb2a59ab7a7d8" | file -
/dev/stdin: Git commit 617
Additional InformationThis issue is present in file 5.38 (current version in Debian/unstable), but according to https://github.com/file/file/blob/master/magic/Magdir/git it is still not fixed (thus present in file 5.39 too, I suppose). To fix it, replace each occurrence of "[0-9]+" by "[0-9a-f]+" (I've attached a patch). After this change,

$ echo "commit d617e0c0ca8fac42361b00c8861eb2a59ab7a7d8" | file -
/dev/stdin: Git commit d617e0c0ca8fac42361b00c8861eb2a59ab7a7d8
TagsNo tags attached.

Activities

vinc17

2020-08-05 12:24

reporter  

file-git-messages.patch (566 bytes)   
Description: Fix messages for Git objects.
Author: Vincent Lefevre <vincent@vinc17.net>
Last-Update: 2020-08-05

--- file-5.38-a/magic/Magdir/git	2019-10-04 18:46:29.000000000 +0000
+++ file-5.38-b/magic/Magdir/git	2020-08-05 11:56:09.704167516 +0000
@@ -4,10 +4,10 @@
 # git:  file(1) magic for Git objects
 
 0	string	blob\040
->5	regex	[0-9]+		Git blob %s
+>5	regex	[0-9a-f]+		Git blob %s
 
 0	string	tree\040
->5	regex	[0-9]+		Git tree %s
+>5	regex	[0-9a-f]+		Git tree %s
 
 0	string	commit\040
->7	regex	[0-9]+		Git commit %s
+>7	regex	[0-9a-f]+		Git commit %s
file-git-messages.patch (566 bytes)   

christos

2020-08-09 16:57

manager   ~0003444

Thanks!

Issue History

Date Modified Username Field Change
2020-08-05 12:24 vinc17 New Issue
2020-08-05 12:24 vinc17 File Added: file-git-messages.patch
2020-08-09 16:57 christos Assigned To => christos
2020-08-09 16:57 christos Status new => assigned
2020-08-09 16:57 christos Status assigned => resolved
2020-08-09 16:57 christos Resolution open => fixed
2020-08-09 16:57 christos Fixed in Version => 5.40
2020-08-09 16:57 christos Note Added: 0003444