19
19
#include "strbuf.h"
20
20
#include "write-or-die.h"
21
21
22
- static void hash_fd (int fd , const char * type , const char * path , unsigned flags ,
23
- int literally )
22
+ static void hash_fd (int fd , const char * type , const char * path , unsigned flags )
24
23
{
25
24
struct stat st ;
26
25
struct object_id oid ;
27
26
28
- if (literally )
29
- flags &= ~INDEX_FORMAT_CHECK ;
30
-
31
27
if (fstat (fd , & st ) < 0 ||
32
28
index_fd (the_repository -> index , & oid , fd , & st ,
33
29
type_from_string (type ), path , flags ))
@@ -39,15 +35,14 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
39
35
}
40
36
41
37
static void hash_object (const char * path , const char * type , const char * vpath ,
42
- unsigned flags , int literally )
38
+ unsigned flags )
43
39
{
44
40
int fd ;
45
41
fd = xopen (path , O_RDONLY );
46
- hash_fd (fd , type , vpath , flags , literally );
42
+ hash_fd (fd , type , vpath , flags );
47
43
}
48
44
49
- static void hash_stdin_paths (const char * type , int no_filters , unsigned flags ,
50
- int literally )
45
+ static void hash_stdin_paths (const char * type , int no_filters , unsigned flags )
51
46
{
52
47
struct strbuf buf = STRBUF_INIT ;
53
48
struct strbuf unquoted = STRBUF_INIT ;
@@ -59,8 +54,7 @@ static void hash_stdin_paths(const char *type, int no_filters, unsigned flags,
59
54
die ("line is badly quoted" );
60
55
strbuf_swap (& buf , & unquoted );
61
56
}
62
- hash_object (buf .buf , type , no_filters ? NULL : buf .buf , flags ,
63
- literally );
57
+ hash_object (buf .buf , type , no_filters ? NULL : buf .buf , flags );
64
58
}
65
59
strbuf_release (& buf );
66
60
strbuf_release (& unquoted );
@@ -81,7 +75,6 @@ int cmd_hash_object(int argc,
81
75
int hashstdin = 0 ;
82
76
int stdin_paths = 0 ;
83
77
int no_filters = 0 ;
84
- int literally = 0 ;
85
78
int nongit = 0 ;
86
79
unsigned flags = INDEX_FORMAT_CHECK ;
87
80
const char * vpath = NULL ;
@@ -93,7 +86,9 @@ int cmd_hash_object(int argc,
93
86
OPT_COUNTUP ( 0 , "stdin" , & hashstdin , N_ ("read the object from stdin" )),
94
87
OPT_BOOL ( 0 , "stdin-paths" , & stdin_paths , N_ ("read file names from stdin" )),
95
88
OPT_BOOL ( 0 , "no-filters" , & no_filters , N_ ("store file as is without filters" )),
96
- OPT_BOOL ( 0 , "literally" , & literally , N_ ("just hash any random garbage to create corrupt objects for debugging Git" )),
89
+ OPT_NEGBIT ( 0 , "literally" , & flags ,
90
+ N_ ("just hash any random garbage to create corrupt objects for debugging Git" ),
91
+ INDEX_FORMAT_CHECK ),
97
92
OPT_STRING ( 0 , "path" , & vpath , N_ ("file" ), N_ ("process file as it were from this path" )),
98
93
OPT_END ()
99
94
};
@@ -139,7 +134,7 @@ int cmd_hash_object(int argc,
139
134
}
140
135
141
136
if (hashstdin )
142
- hash_fd (0 , type , vpath , flags , literally );
137
+ hash_fd (0 , type , vpath , flags );
143
138
144
139
for (i = 0 ; i < argc ; i ++ ) {
145
140
const char * arg = argv [i ];
@@ -148,12 +143,12 @@ int cmd_hash_object(int argc,
148
143
if (prefix )
149
144
arg = to_free = prefix_filename (prefix , arg );
150
145
hash_object (arg , type , no_filters ? NULL : vpath ? vpath : arg ,
151
- flags , literally );
146
+ flags );
152
147
free (to_free );
153
148
}
154
149
155
150
if (stdin_paths )
156
- hash_stdin_paths (type , no_filters , flags , literally );
151
+ hash_stdin_paths (type , no_filters , flags );
157
152
158
153
free (vpath_free );
159
154
0 commit comments