Skip to content

Commit 5ec1e72

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 041f5ea commit 5ec1e72

File tree

15 files changed

+24
-24
lines changed

15 files changed

+24
-24
lines changed

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static void parse_treeish_arg(const char **argv,
415415

416416
if (prefix) {
417417
struct object_id tree_oid;
418-
unsigned int mode;
418+
unsigned short mode;
419419
int err;
420420

421421
err = get_tree_entry(&tree->object.oid, prefix, &tree_oid,

blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static void verify_working_tree_path(struct repository *r,
9999
for (parents = work_tree->parents; parents; parents = parents->next) {
100100
const struct object_id *commit_oid = &parents->item->object.oid;
101101
struct object_id blob_oid;
102-
unsigned mode;
102+
unsigned short mode;
103103

104104
if (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&
105105
oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)

blame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct blame_origin {
5252
struct blame_entry *suspects;
5353
mmfile_t file;
5454
struct object_id blob_oid;
55-
unsigned mode;
55+
unsigned short mode;
5656
/* guilty gets set when shipping any suspects to the final
5757
* blame list instead of other commits
5858
*/

builtin/rm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int check_local_mod(struct object_id *head, int index_only)
110110
const struct cache_entry *ce;
111111
const char *name = list.entry[i].name;
112112
struct object_id oid;
113-
unsigned mode;
113+
unsigned short mode;
114114
int local_changes = 0;
115115
int staged_changes = 0;
116116

builtin/update-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ static struct cache_entry *read_one_ent(const char *which,
597597
struct object_id *ent, const char *path,
598598
int namelen, int stage)
599599
{
600-
unsigned mode;
600+
unsigned short mode;
601601
struct object_id oid;
602602
struct cache_entry *ce;
603603

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ static inline int hex2chr(const char *s)
13311331
#define FALLBACK_DEFAULT_ABBREV 7
13321332

13331333
struct object_context {
1334-
unsigned mode;
1334+
unsigned short mode;
13351335
/*
13361336
* symlink_path is only used by get_tree_entry_follow_symlinks,
13371337
* and only for symlinks that point outside the repository.

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
604604
o_name = NULL;
605605

606606
while (desc.size) {
607-
unsigned mode;
607+
unsigned short mode;
608608
const char *name;
609609
const struct object_id *oid;
610610

line-log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static struct commit *check_single_commit(struct rev_info *revs)
498498

499499
static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec)
500500
{
501-
unsigned mode;
501+
unsigned short mode;
502502
struct object_id oid;
503503

504504
if (get_tree_entry(&commit->object.oid, spec->path, &oid, &mode))

match-trees.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void match_trees(const struct object_id *hash1,
140140
while (one.size) {
141141
const char *path;
142142
const struct object_id *elem;
143-
unsigned mode;
143+
unsigned short mode;
144144
int score;
145145

146146
elem = tree_entry_extract(&one, &path, &mode);
@@ -196,7 +196,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
196196
rewrite_here = NULL;
197197
while (desc.size) {
198198
const char *name;
199-
unsigned mode;
199+
unsigned short mode;
200200

201201
tree_entry_extract(&desc, &name, &mode);
202202
if (strlen(name) == toplen &&
@@ -285,7 +285,7 @@ void shift_tree(const struct object_id *hash1,
285285

286286
if (add_score < del_score) {
287287
/* We need to pick a subtree of two */
288-
unsigned mode;
288+
unsigned short mode;
289289

290290
if (!*del_prefix)
291291
return;
@@ -313,7 +313,7 @@ void shift_tree_by(const struct object_id *hash1,
313313
const char *shift_prefix)
314314
{
315315
struct object_id sub1, sub2;
316-
unsigned mode1, mode2;
316+
unsigned short mode1, mode2;
317317
unsigned candidate = 0;
318318

319319
/* Can hash2 be a tree at shift_prefix in tree hash1? */

merge-recursive.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ struct rename_conflict_info {
214214
*/
215215
struct stage_data {
216216
struct {
217-
unsigned mode;
217+
unsigned short mode;
218218
struct object_id oid;
219219
} stages[4];
220220
struct rename_conflict_info *rename_conflict_info;
@@ -482,7 +482,7 @@ static void get_files_dirs(struct merge_options *o, struct tree *tree)
482482
static int get_tree_entry_if_blob(const struct object_id *tree,
483483
const char *path,
484484
struct object_id *hashy,
485-
unsigned int *mode_o)
485+
unsigned short *mode_o)
486486
{
487487
int ret;
488488

@@ -1935,7 +1935,7 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *o,
19351935
static int tree_has_path(struct tree *tree, const char *path)
19361936
{
19371937
struct object_id hashy;
1938-
unsigned int mode_o;
1938+
unsigned short mode_o;
19391939

19401940
return !get_tree_entry(&tree->object.oid, path,
19411941
&hashy, &mode_o);

0 commit comments

Comments
 (0)