Use 'unsigned short' for mode, like diff_filespec does
authorElijah Newren <newren@gmail.com>
Fri, 5 Apr 2019 15:00:12 +0000 (08:00 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Apr 2019 07:02:07 +0000 (16:02 +0900)
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>
15 files changed:
archive.c
blame.c
blame.h
builtin/rm.c
builtin/update-index.c
cache.h
fsck.c
line-log.c
match-trees.c
merge-recursive.c
notes.c
sha1-name.c
tree-diff.c
tree-walk.c
tree-walk.h
index 1f98324a930e39aa1a7c41e78b4fcd6450899c66..92bc001545756472069cfd9ec8430ba81822743c 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -415,7 +415,7 @@ static void parse_treeish_arg(const char **argv,
 
        if (prefix) {
                struct object_id tree_oid;
-               unsigned int mode;
+               unsigned short mode;
                int err;
 
                err = get_tree_entry(&tree->object.oid, prefix, &tree_oid,
diff --git a/blame.c b/blame.c
index 5c07dec1903545738642c17e94cc1fa060ba15d3..326231476e2dc66d67e63c769b565ff8e0cc34d5 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -99,7 +99,7 @@ static void verify_working_tree_path(struct repository *r,
        for (parents = work_tree->parents; parents; parents = parents->next) {
                const struct object_id *commit_oid = &parents->item->object.oid;
                struct object_id blob_oid;
-               unsigned mode;
+               unsigned short mode;
 
                if (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&
                    oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)
diff --git a/blame.h b/blame.h
index be3a895043e07a2508d407ac35e74d634acd7886..2a285eb027bf1a82b3b1b53f2bc04caebef86924 100644 (file)
--- a/blame.h
+++ b/blame.h
@@ -52,7 +52,7 @@ struct blame_origin {
        struct blame_entry *suspects;
        mmfile_t file;
        struct object_id blob_oid;
-       unsigned mode;
+       unsigned short mode;
        /* guilty gets set when shipping any suspects to the final
         * blame list instead of other commits
         */
index db85b339823cc0aa5ab5d03220335d4e4240d656..90cbe896c99188130a36a18aa18a57cd080be591 100644 (file)
@@ -110,7 +110,7 @@ static int check_local_mod(struct object_id *head, int index_only)
                const struct cache_entry *ce;
                const char *name = list.entry[i].name;
                struct object_id oid;
-               unsigned mode;
+               unsigned short mode;
                int local_changes = 0;
                int staged_changes = 0;
 
index 1b6c42f748fd52ece4cf5f109f92a50bc2a87be3..0baf51c3169ab2237217b7a4d65de1f9f1cd6b8b 100644 (file)
@@ -597,7 +597,7 @@ static struct cache_entry *read_one_ent(const char *which,
                                        struct object_id *ent, const char *path,
                                        int namelen, int stage)
 {
-       unsigned mode;
+       unsigned short mode;
        struct object_id oid;
        struct cache_entry *ce;
 
diff --git a/cache.h b/cache.h
index ac92421f3a8bc814da3f01731f2d8d8a52dc8364..851c3e694505791c5c971cb4220dbe7002e5f903 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1331,7 +1331,7 @@ static inline int hex2chr(const char *s)
 #define FALLBACK_DEFAULT_ABBREV 7
 
 struct object_context {
-       unsigned mode;
+       unsigned short mode;
        /*
         * symlink_path is only used by get_tree_entry_follow_symlinks,
         * and only for symlinks that point outside the repository.
diff --git a/fsck.c b/fsck.c
index 2260adb71e7a9f1091d14bb635a4f082592b9512..4703f55561452c3fca5401aba3fcec7b170f1c6a 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -604,7 +604,7 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
        o_name = NULL;
 
        while (desc.size) {
-               unsigned mode;
+               unsigned short mode;
                const char *name;
                const struct object_id *oid;
 
index 24e21731c4315f414578b33178a7b784176bb24d..f743592bc0b6aeb2404e1f25d132dc128814bb31 100644 (file)
@@ -498,7 +498,7 @@ static struct commit *check_single_commit(struct rev_info *revs)
 
 static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec)
 {
-       unsigned mode;
+       unsigned short mode;
        struct object_id oid;
 
        if (get_tree_entry(&commit->object.oid, spec->path, &oid, &mode))
index ddc4d398456363cede9f3f5d4fa602efb402b5bd..9d1ec8d6b01e13b20b34c836130cd9557fdd1d80 100644 (file)
@@ -140,7 +140,7 @@ static void match_trees(const struct object_id *hash1,
        while (one.size) {
                const char *path;
                const struct object_id *elem;
-               unsigned mode;
+               unsigned short mode;
                int score;
 
                elem = tree_entry_extract(&one, &path, &mode);
@@ -196,7 +196,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
        rewrite_here = NULL;
        while (desc.size) {
                const char *name;
-               unsigned mode;
+               unsigned short mode;
 
                tree_entry_extract(&desc, &name, &mode);
                if (strlen(name) == toplen &&
@@ -285,7 +285,7 @@ void shift_tree(const struct object_id *hash1,
 
        if (add_score < del_score) {
                /* We need to pick a subtree of two */
-               unsigned mode;
+               unsigned short mode;
 
                if (!*del_prefix)
                        return;
@@ -313,7 +313,7 @@ void shift_tree_by(const struct object_id *hash1,
                   const char *shift_prefix)
 {
        struct object_id sub1, sub2;
-       unsigned mode1, mode2;
+       unsigned short mode1, mode2;
        unsigned candidate = 0;
 
        /* Can hash2 be a tree at shift_prefix in tree hash1? */
index 6c40c61c4728d9224006768599d7bf2ded744bb1..fcf37be2a78a1e1b7c3a749f194158b2d0ff9029 100644 (file)
@@ -214,7 +214,7 @@ struct rename_conflict_info {
  */
 struct stage_data {
        struct {
-               unsigned mode;
+               unsigned short mode;
                struct object_id oid;
        } stages[4];
        struct rename_conflict_info *rename_conflict_info;
@@ -482,7 +482,7 @@ static void get_files_dirs(struct merge_options *o, struct tree *tree)
 static int get_tree_entry_if_blob(const struct object_id *tree,
                                  const char *path,
                                  struct object_id *hashy,
-                                 unsigned int *mode_o)
+                                 unsigned short *mode_o)
 {
        int ret;
 
@@ -1935,7 +1935,7 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *o,
 static int tree_has_path(struct tree *tree, const char *path)
 {
        struct object_id hashy;
-       unsigned int mode_o;
+       unsigned short mode_o;
 
        return !get_tree_entry(&tree->object.oid, path,
                               &hashy, &mode_o);
diff --git a/notes.c b/notes.c
index 7f7cc4d5112cd8f5098477d03034e8c8886dcb84..ba4cae785138eec5c31e9579ef61f21045070c56 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -986,7 +986,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
                combine_notes_fn combine_notes, int flags)
 {
        struct object_id oid, object_oid;
-       unsigned mode;
+       unsigned short mode;
        struct leaf_node root_tree;
 
        if (!t)
index 6dda2c16df1026e50b7d9be255b6bbfc4e92725c..d4b3d01f3c057ff9cfa404eba8653bdb4a7f5475 100644 (file)
@@ -1577,7 +1577,7 @@ static void diagnose_invalid_oid_path(const char *prefix,
                                      int object_name_len)
 {
        struct object_id oid;
-       unsigned mode;
+       unsigned short mode;
 
        if (!prefix)
                prefix = "";
index e6d306f69f940edd9613de0b38ffe2d9993f91ab..f1f641eb6a64abc2dbb6f0ef70f7375101874812 100644 (file)
@@ -181,7 +181,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
        struct tree_desc *t, struct tree_desc *tp,
        int imin)
 {
-       unsigned mode;
+       unsigned short mode;
        const char *path;
        const struct object_id *oid;
        int pathlen;
index 1e4bbc8a0e48c6afe61dc8aab76488356d7e1cbc..ec32a47b2e7664365f771f3955747794001d3f28 100644 (file)
@@ -500,7 +500,7 @@ struct dir_state {
        struct object_id oid;
 };
 
-static int find_tree_entry(struct tree_desc *t, const char *name, struct object_id *result, unsigned *mode)
+static int find_tree_entry(struct tree_desc *t, const char *name, struct object_id *result, unsigned short *mode)
 {
        int namelen = strlen(name);
        while (t->size) {
@@ -535,7 +535,7 @@ static int find_tree_entry(struct tree_desc *t, const char *name, struct object_
        return -1;
 }
 
-int get_tree_entry(const struct object_id *tree_oid, const char *name, struct object_id *oid, unsigned *mode)
+int get_tree_entry(const struct object_id *tree_oid, const char *name, struct object_id *oid, unsigned short *mode)
 {
        int retval;
        void *tree;
@@ -585,7 +585,7 @@ int get_tree_entry(const struct object_id *tree_oid, const char *name, struct ob
  * See the code for enum get_oid_result for a description of
  * the return values.
  */
-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)
+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)
 {
        int retval = MISSING_OBJECT;
        struct dir_state *parents = NULL;
index 82251718666eb5dceb33d6140e86de5a627baab1..3aa381b6a3dd20e4d98f781dde6bcf27bc8b055b 100644 (file)
@@ -16,7 +16,7 @@ struct tree_desc {
        unsigned int size;
 };
 
-static inline const struct object_id *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
+static inline const struct object_id *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned short *modep)
 {
        *pathp = desc->entry.path;
        *modep = desc->entry.mode;
@@ -51,7 +51,7 @@ struct traverse_info;
 typedef int (*traverse_callback_t)(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *);
 int traverse_trees(struct index_state *istate, int n, struct tree_desc *t, struct traverse_info *info);
 
-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);
+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);
 
 struct traverse_info {
        const char *traverse_path;
@@ -66,7 +66,7 @@ struct traverse_info {
        int show_all_errors;
 };
 
-int get_tree_entry(const struct object_id *, const char *, struct object_id *, unsigned *);
+int get_tree_entry(const struct object_id *, const char *, struct object_id *, unsigned short *);
 extern char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n);
 extern void setup_traverse_info(struct traverse_info *info, const char *base);