Use 'unsigned short' for mode, like diff_filespec does

struct diff_filespec defines mode to be an 'unsigned short'. Several other places in the API which we'd like to interact with using a diff_filespec used a plain unsigned (or unsigned int). This caused problems when taking addresses, so switch to unsigned short. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Apr 5, 2019 at 08:00 UTC 5ec1e72823735b5682389589b6bee774ae70fa49
15 files changed +24 -24
archive.c
+1 -1
@@ -415,7 +415,7 @@ static void parse_treeish_arg(const char **argv,
415
416 if (prefix) {
417 struct object_id tree_oid;
418 - unsigned int mode;
418 + unsigned short mode;
419 int err;
420
421 err = get_tree_entry(&tree->object.oid, prefix, &tree_oid,
blame.c
+1 -1
@@ -99,7 +99,7 @@ static void verify_working_tree_path(struct repository *r,
99 for (parents = work_tree->parents; parents; parents = parents->next) {
100 const struct object_id *commit_oid = &parents->item->object.oid;
101 struct object_id blob_oid;
102 - unsigned mode;
102 + unsigned short mode;
103
104 if (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&
105 oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)
blame.h
+1 -1
@@ -52,7 +52,7 @@ struct blame_origin {
52 struct blame_entry *suspects;
53 mmfile_t file;
54 struct object_id blob_oid;
55 - unsigned mode;
55 + unsigned short mode;
56 /* guilty gets set when shipping any suspects to the final
57 * blame list instead of other commits
58 */
builtin/rm.c
+1 -1
@@ -110,7 +110,7 @@ static int check_local_mod(struct object_id *head, int index_only)
110 const struct cache_entry *ce;
111 const char *name = list.entry[i].name;
112 struct object_id oid;
113 - unsigned mode;
113 + unsigned short mode;
114 int local_changes = 0;
115 int staged_changes = 0;
116
builtin/update-index.c
+1 -1
@@ -597,7 +597,7 @@ static struct cache_entry *read_one_ent(const char *which,
597 struct object_id *ent, const char *path,
598 int namelen, int stage)
599 {
600 - unsigned mode;
600 + unsigned short mode;
601 struct object_id oid;
602 struct cache_entry *ce;
603
cache.h
+1 -1
@@ -1331,7 +1331,7 @@ static inline int hex2chr(const char *s)
1331 #define FALLBACK_DEFAULT_ABBREV 7
1332
1333 struct object_context {
1334 - unsigned mode;
1334 + unsigned short mode;
1335 /*
1336 * symlink_path is only used by get_tree_entry_follow_symlinks,
1337 * and only for symlinks that point outside the repository.
fsck.c
+1 -1
@@ -604,7 +604,7 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
604 o_name = NULL;
605
606 while (desc.size) {
607 - unsigned mode;
607 + unsigned short mode;
608 const char *name;
609 const struct object_id *oid;
610
line-log.c
+1 -1
@@ -498,7 +498,7 @@ static struct commit *check_single_commit(struct rev_info *revs)
498
499 static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec)
500 {
501 - unsigned mode;
501 + unsigned short mode;
502 struct object_id oid;
503
504 if (get_tree_entry(&commit->object.oid, spec->path, &oid, &mode))
match-trees.c
+4 -4
@@ -140,7 +140,7 @@ static void match_trees(const struct object_id *hash1,
140 while (one.size) {
141 const char *path;
142 const struct object_id *elem;
143 - unsigned mode;
143 + unsigned short mode;
144 int score;
145
146 elem = tree_entry_extract(&one, &path, &mode);
@@ -196,7 +196,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
196 rewrite_here = NULL;
197 while (desc.size) {
198 const char *name;
199 - unsigned mode;
199 + unsigned short mode;
200
201 tree_entry_extract(&desc, &name, &mode);
202 if (strlen(name) == toplen &&
@@ -285,7 +285,7 @@ void shift_tree(const struct object_id *hash1,
285
286 if (add_score < del_score) {
287 /* We need to pick a subtree of two */
288 - unsigned mode;
288 + unsigned short mode;
289
290 if (!*del_prefix)
291 return;
@@ -313,7 +313,7 @@ void shift_tree_by(const struct object_id *hash1,
313 const char *shift_prefix)
314 {
315 struct object_id sub1, sub2;
316 - unsigned mode1, mode2;
316 + unsigned short mode1, mode2;
317 unsigned candidate = 0;
318
319 /* Can hash2 be a tree at shift_prefix in tree hash1? */
merge-recursive.c
+3 -3
@@ -214,7 +214,7 @@ struct rename_conflict_info {
214 */
215 struct stage_data {
216 struct {
217 - unsigned mode;
217 + unsigned short mode;
218 struct object_id oid;
219 } stages[4];
220 struct rename_conflict_info *rename_conflict_info;
@@ -482,7 +482,7 @@ static void get_files_dirs(struct merge_options *o, struct tree *tree)
482 static int get_tree_entry_if_blob(const struct object_id *tree,
483 const char *path,
484 struct object_id *hashy,
485 - unsigned int *mode_o)
485 + unsigned short *mode_o)
486 {
487 int ret;
488
@@ -1935,7 +1935,7 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *o,
1935 static int tree_has_path(struct tree *tree, const char *path)
1936 {
1937 struct object_id hashy;
1938 - unsigned int mode_o;
1938 + unsigned short mode_o;
1939
1940 return !get_tree_entry(&tree->object.oid, path,
1941 &hashy, &mode_o);
notes.c
+1 -1
@@ -986,7 +986,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
986 combine_notes_fn combine_notes, int flags)
987 {
988 struct object_id oid, object_oid;
989 - unsigned mode;
989 + unsigned short mode;
990 struct leaf_node root_tree;
991
992 if (!t)
sha1-name.c
+1 -1
@@ -1577,7 +1577,7 @@ static void diagnose_invalid_oid_path(const char *prefix,
1577 int object_name_len)
1578 {
1579 struct object_id oid;
1580 - unsigned mode;
1580 + unsigned short mode;
1581
1582 if (!prefix)
1583 prefix = "";
tree-diff.c
+1 -1
@@ -181,7 +181,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
181 struct tree_desc *t, struct tree_desc *tp,
182 int imin)
183 {
184 - unsigned mode;
184 + unsigned short mode;
185 const char *path;
186 const struct object_id *oid;
187 int pathlen;
tree-walk.c
+3 -3
@@ -500,7 +500,7 @@ struct dir_state {
500 struct object_id oid;
501 };
502
503 -static int find_tree_entry(struct tree_desc *t, const char *name, struct object_id *result, unsigned *mode)
503 +static int find_tree_entry(struct tree_desc *t, const char *name, struct object_id *result, unsigned short *mode)
504 {
505 int namelen = strlen(name);
506 while (t->size) {
@@ -535,7 +535,7 @@ static int find_tree_entry(struct tree_desc *t, const char *name, struct object_
535 return -1;
536 }
537
538 -int get_tree_entry(const struct object_id *tree_oid, const char *name, struct object_id *oid, unsigned *mode)
538 +int get_tree_entry(const struct object_id *tree_oid, const char *name, struct object_id *oid, unsigned short *mode)
539 {
540 int retval;
541 void *tree;
@@ -585,7 +585,7 @@ int get_tree_entry(const struct object_id *tree_oid, const char *name, struct ob
585 * See the code for enum get_oid_result for a description of
586 * the return values.
587 */
588 -enum get_oid_result get_tree_entry_follow_symlinks(struct object_id *tree_oid, const char *name, struct object_id *result, struct strbuf *result_path, unsigned *mode)
588 +enum get_oid_result get_tree_entry_follow_symlinks(struct object_id *tree_oid, const char *name, struct object_id *result, struct strbuf *result_path, unsigned short *mode)
589 {
590 int retval = MISSING_OBJECT;
591 struct dir_state *parents = NULL;
tree-walk.h
+3 -3
@@ -16,7 +16,7 @@ struct tree_desc {
16 unsigned int size;
17 };
18
19 -static inline const struct object_id *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
19 +static inline const struct object_id *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned short *modep)
20 {
21 *pathp = desc->entry.path;
22 *modep = desc->entry.mode;
@@ -51,7 +51,7 @@ struct traverse_info;
51 typedef int (*traverse_callback_t)(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *);
52 int traverse_trees(struct index_state *istate, int n, struct tree_desc *t, struct traverse_info *info);
53
54 -enum get_oid_result get_tree_entry_follow_symlinks(struct object_id *tree_oid, const char *name, struct object_id *result, struct strbuf *result_path, unsigned *mode);
54 +enum get_oid_result get_tree_entry_follow_symlinks(struct object_id *tree_oid, const char *name, struct object_id *result, struct strbuf *result_path, unsigned short *mode);
55
56 struct traverse_info {
57 const char *traverse_path;
@@ -66,7 +66,7 @@ struct traverse_info {
66 int show_all_errors;
67 };
68
69 -int get_tree_entry(const struct object_id *, const char *, struct object_id *, unsigned *);
69 +int get_tree_entry(const struct object_id *, const char *, struct object_id *, unsigned short *);
70 extern char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n);
71 extern void setup_traverse_info(struct traverse_info *info, const char *base);
72