]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'bc/object-id'
authorJunio C Hamano <gitster@pobox.com>
Wed, 30 May 2018 05:04:10 +0000 (14:04 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 May 2018 05:04:10 +0000 (14:04 +0900)
Conversion from uchar[20] to struct object_id continues.

* bc/object-id: (42 commits)
  merge-one-file: compute empty blob object ID
  add--interactive: compute the empty tree value
  Update shell scripts to compute empty tree object ID
  sha1_file: only expose empty object constants through git_hash_algo
  dir: use the_hash_algo for empty blob object ID
  sequencer: use the_hash_algo for empty tree object ID
  cache-tree: use is_empty_tree_oid
  sha1_file: convert cached object code to struct object_id
  builtin/reset: convert use of EMPTY_TREE_SHA1_BIN
  builtin/receive-pack: convert one use of EMPTY_TREE_SHA1_HEX
  wt-status: convert two uses of EMPTY_TREE_SHA1_HEX
  submodule: convert several uses of EMPTY_TREE_SHA1_HEX
  sequencer: convert one use of EMPTY_TREE_SHA1_HEX
  merge: convert empty tree constant to the_hash_algo
  builtin/merge: switch tree functions to use object_id
  builtin/am: convert uses of EMPTY_TREE_SHA1_BIN to the_hash_algo
  sha1-file: add functions for hex empty tree and blob OIDs
  builtin/receive-pack: avoid hard-coded constants for push certs
  diff: specify abbreviation size in terms of the_hash_algo
  upload-pack: replace use of several hard-coded constants
  ...

27 files changed:
1  2 
builtin/am.c
builtin/fsck.c
builtin/index-pack.c
builtin/merge.c
builtin/pack-objects.c
builtin/receive-pack.c
cache.h
commit.c
diff.c
dir.c
dir.h
fsck.c
git-rebase--interactive.sh
http.c
packfile.c
packfile.h
read-cache.c
revision.c
sequencer.c
sha1-file.c
sha1-name.c
submodule-config.c
submodule-config.h
submodule.c
unpack-trees.c
upload-pack.c
wt-status.c

diff --cc builtin/am.c
Simple merge
diff --cc builtin/fsck.c
Simple merge
Simple merge
diff --cc builtin/merge.c
Simple merge
index 53a0fb6ef2a8eec242359463cb5182973837c36f,f0145236135e9857eb2015de8764cb88781a5fd9..e78f3f52203f369d63c6af6eefb7e21f48c83318
@@@ -279,10 -264,11 +279,11 @@@ static unsigned long write_no_reuse_obj
        enum object_type type;
        void *buf;
        struct git_istream *st = NULL;
+       const unsigned hashsz = the_hash_algo->rawsz;
  
        if (!usable_delta) {
 -              if (entry->type == OBJ_BLOB &&
 -                  entry->size > big_file_threshold &&
 +              if (oe_type(entry) == OBJ_BLOB &&
 +                  oe_size_greater_than(&to_pack, entry, big_file_threshold) &&
                    (st = open_istream(&entry->idx.oid, &type, &size, NULL)) != NULL)
                        buf = NULL;
                else {
                        return 0;
                }
                hashwrite(f, header, hdrlen);
-               hashwrite(f, DELTA(entry)->idx.oid.hash, 20);
-               hdrlen += 20;
 -              hashwrite(f, entry->delta->idx.oid.hash, hashsz);
++              hashwrite(f, DELTA(entry)->idx.oid.hash, hashsz);
+               hdrlen += hashsz;
        } else {
-               if (limit && hdrlen + datalen + 20 >= limit) {
+               if (limit && hdrlen + datalen + hashsz >= limit) {
                        if (st)
                                close_istream(st);
                        free(buf);
@@@ -391,13 -377,13 +392,14 @@@ static off_t write_reuse_object(struct 
        unsigned char header[MAX_PACK_OBJECT_HEADER],
                      dheader[MAX_PACK_OBJECT_HEADER];
        unsigned hdrlen;
+       const unsigned hashsz = the_hash_algo->rawsz;
 +      unsigned long entry_size = SIZE(entry);
  
 -      if (entry->delta)
 -              type = (allow_ofs_delta && entry->delta->idx.offset) ?
 +      if (DELTA(entry))
 +              type = (allow_ofs_delta && DELTA(entry)->idx.offset) ?
                        OBJ_OFS_DELTA : OBJ_REF_DELTA;
        hdrlen = encode_in_pack_object_header(header, sizeof(header),
 -                                            type, entry->size);
 +                                            type, entry_size);
  
        offset = entry->in_pack_offset;
        revidx = find_pack_revindex(p, offset);
                        return 0;
                }
                hashwrite(f, header, hdrlen);
-               hashwrite(f, DELTA(entry)->idx.oid.hash, 20);
-               hdrlen += 20;
 -              hashwrite(f, entry->delta->idx.oid.hash, hashsz);
++              hashwrite(f, DELTA(entry)->idx.oid.hash, hashsz);
+               hdrlen += hashsz;
                reused_delta++;
        } else {
-               if (limit && hdrlen + datalen + 20 >= limit) {
+               if (limit && hdrlen + datalen + hashsz >= limit) {
                        unuse_pack(&w_curs);
                        return 0;
                }
@@@ -1947,12 -1850,12 +1949,12 @@@ static int try_delta(struct unpacked *t
                return 0;
  
        /* Now some size filtering heuristics. */
 -      trg_size = trg_entry->size;
 -      if (!trg_entry->delta) {
 +      trg_size = SIZE(trg_entry);
 +      if (!DELTA(trg_entry)) {
-               max_size = trg_size/2 - 20;
+               max_size = trg_size/2 - the_hash_algo->rawsz;
                ref_depth = 1;
        } else {
 -              max_size = trg_entry->delta_size;
 +              max_size = DELTA_SIZE(trg_entry);
                ref_depth = trg->depth;
        }
        max_size = (uint64_t)max_size * (max_depth - src->depth) /
Simple merge
diff --cc cache.h
Simple merge
diff --cc commit.c
index f9714ed74ccdccba4d9b5f00bc8ac31cb022dd02,9617f85caaca8ab2a332fee4ed29c1f373c6cabe..b0e57cc4400964ad7dca8d37c5d4c10bf3979b51
+++ b/commit.c
@@@ -358,10 -331,10 +358,10 @@@ int parse_commit_buffer(struct commit *
        if (tail <= bufptr + tree_entry_len + 1 || memcmp(bufptr, "tree ", 5) ||
                        bufptr[tree_entry_len] != '\n')
                return error("bogus commit object %s", oid_to_hex(&item->object.oid));
-       if (get_sha1_hex(bufptr + 5, parent.hash) < 0)
+       if (get_oid_hex(bufptr + 5, &parent) < 0)
                return error("bad tree pointer in commit %s",
                             oid_to_hex(&item->object.oid));
 -      item->tree = lookup_tree(&parent);
 +      item->maybe_tree = lookup_tree(&parent);
        bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
        pptr = &item->parents;
  
diff --cc diff.c
Simple merge
diff --cc dir.c
Simple merge
diff --cc dir.h
Simple merge
diff --cc fsck.c
index 4db2277ab8606fe08143cdba12b32bde959b2732,768011f812e11bcc3c69bc92e46560417b4d5de0..bcae2c30e6531f6a71f518877a71d9a5a9b232ae
--- 1/fsck.c
--- 2/fsck.c
+++ b/fsck.c
@@@ -795,8 -773,8 +796,8 @@@ static int fsck_commit_buffer(struct co
        err = fsck_ident(&buffer, &commit->object, options);
        if (err)
                return err;
 -      if (!commit->tree) {
 +      if (!get_commit_tree(commit)) {
-               err = report(options, &commit->object, FSCK_MSG_BAD_TREE, "could not load commit's tree %s", sha1_to_hex(tree_sha1));
+               err = report(options, &commit->object, FSCK_MSG_BAD_TREE, "could not load commit's tree %s", oid_to_hex(&tree_oid));
                if (err)
                        return err;
        }
Simple merge
diff --cc http.c
Simple merge
diff --cc packfile.c
Simple merge
diff --cc packfile.h
Simple merge
diff --cc read-cache.c
index cebd24849d56da4f4e9f9162328359662a464c19,9dbaeeec43836ffd7acd56903393062f454627bf..372588260ea00f48ea4d031095901a575ac0e620
@@@ -2584,8 -2559,8 +2584,8 @@@ int write_locked_index(struct index_sta
                goto out;
        }
  
 -      if (getenv("GIT_TEST_SPLIT_INDEX")) {
 +      if (git_env_bool("GIT_TEST_SPLIT_INDEX", 0)) {
-               int v = si->base_sha1[0];
+               int v = si->base_oid.hash[0];
                if ((v & 15) < 6)
                        istate->cache_changed |= SPLIT_INDEX_ORDERED;
        }
diff --cc revision.c
Simple merge
diff --cc sequencer.c
index abb6c5dc26c04e21607615326c4d101cd85d5c00,94b6513402476fdcf518adeb50f4c3bf4b509913..72b4d8ecae3b07e2259cf05c4a8f4acdb46eae0a
@@@ -1246,8 -1118,8 +1246,8 @@@ static int try_to_commit(struct strbuf 
        }
  
        if (!(flags & ALLOW_EMPTY) && !oidcmp(current_head ?
 -                                            &current_head->tree->object.oid :
 +                                            get_commit_tree_oid(current_head) :
-                                             &empty_tree_oid, &tree)) {
+                                             the_hash_algo->empty_tree, &tree)) {
                res = 1; /* run 'git commit' to display error message */
                goto out;
        }
@@@ -1630,16 -1478,9 +1630,16 @@@ static int do_pick_commit(enum todo_com
                        return error(_("your index file is unmerged."));
        } else {
                unborn = get_oid("HEAD", &head);
 -              if (unborn)
 +              /* Do we want to generate a root commit? */
 +              if (is_pick_or_similar(command) && opts->have_squash_onto &&
 +                  !oidcmp(&head, &opts->squash_onto)) {
 +                      if (is_fixup(command))
 +                              return error(_("cannot fixup root commit"));
 +                      flags |= CREATE_ROOT_COMMIT;
 +                      unborn = 1;
 +              } else if (unborn)
                        oidcpy(&head, the_hash_algo->empty_tree);
-               if (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : "HEAD",
+               if (index_differs_from(unborn ? empty_tree_oid_hex() : "HEAD",
                                       NULL, 0))
                        return error_dirty_index(opts);
        }
diff --cc sha1-file.c
index e47098eff2828c573a4a2eb3cce3dc7a5520b3e5,bf6c8da3ffb2867ea4a326ad08b49008943c0a9a..555e780f4b61b8b96b12549de341cb2d827e039e
@@@ -1270,7 -1289,7 +1291,7 @@@ int oid_object_info_extended(struct rep
        }
  
        while (1) {
-               if (find_pack_entry(r, real->hash, &e))
 -              if (find_pack_entry(the_repository, real, &e))
++              if (find_pack_entry(r, real, &e))
                        break;
  
                if (flags & OBJECT_INFO_IGNORE_LOOSE)
  
                /* Not a loose object; someone else may have just packed it. */
                if (!(flags & OBJECT_INFO_QUICK)) {
 -                      reprepare_packed_git(the_repository);
 -                      if (find_pack_entry(the_repository, real, &e))
 +                      reprepare_packed_git(r);
-                       if (find_pack_entry(r, real->hash, &e))
++                      if (find_pack_entry(r, real, &e))
                                break;
                }
  
diff --cc sha1-name.c
Simple merge
Simple merge
Simple merge
diff --cc submodule.c
Simple merge
diff --cc unpack-trees.c
index 7051fcf7d841c9526f4e0e83dd32d6922835e181,038ef7b92683257f3a47806d91a0dd560549d363..d17f726e7572985c8c2fa5289bafe7c1b78eaa00
@@@ -1284,21 -1284,10 +1284,21 @@@ int unpack_trees(unsigned len, struct t
        o->result.timestamp.sec = o->src_index->timestamp.sec;
        o->result.timestamp.nsec = o->src_index->timestamp.nsec;
        o->result.version = o->src_index->version;
 -      o->result.split_index = o->src_index->split_index;
 -      if (o->result.split_index)
 +      if (!o->src_index->split_index) {
 +              o->result.split_index = NULL;
 +      } else if (o->src_index == o->dst_index) {
 +              /*
 +               * o->dst_index (and thus o->src_index) will be discarded
 +               * and overwritten with o->result at the end of this function,
 +               * so just use src_index's split_index to avoid having to
 +               * create a new one.
 +               */
 +              o->result.split_index = o->src_index->split_index;
                o->result.split_index->refcount++;
-       hashcpy(o->result.sha1, o->src_index->sha1);
 +      } else {
 +              o->result.split_index = init_split_index(&o->result);
 +      }
+       oidcpy(&o->result.oid, &o->src_index->oid);
        o->merge_size = len;
        mark_all_ce_unused(o->src_index);
  
diff --cc upload-pack.c
index 87b4d32a6e23aed2416a9bb752dfa56b916b141c,1fb4942235ee07e65c388989d0cfa38ba68b9777..bacc92bbb6b58180aa65b2edf1cd9b5358c3e1cd
@@@ -893,13 -821,10 +895,11 @@@ static void receive_needs(void
                        parse_list_objects_filter(&filter_options, arg);
                        continue;
                }
 +
                if (!skip_prefix(line, "want ", &arg) ||
-                   get_oid_hex(arg, &oid_buf))
+                   parse_oid_hex(arg, &oid_buf, &features))
                        die("git upload-pack: protocol error, "
-                           "expected to get sha, not '%s'", line);
-               features = arg + 40;
+                           "expected to get object ID, not '%s'", line);
  
                if (parse_feature_request(features, "deepen-relative"))
                        deepen_relative = 1;
diff --cc wt-status.c
Simple merge