1. 09 5月, 2018 7 次提交
  2. 26 4月, 2018 1 次提交
  3. 12 4月, 2018 2 次提交
  4. 27 3月, 2018 2 次提交
  5. 24 3月, 2018 2 次提交
  6. 15 3月, 2018 4 次提交
    • B
      Convert lookup_replace_object to struct object_id · b383a13c
      brian m. carlson 提交于
      Convert both the argument and the return value to be pointers to struct
      object_id.  Update the callers and their internals to deal with the new
      type.  Remove several temporaries which are no longer needed.
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b383a13c
    • B
      sha1_file: convert read_sha1_file to struct object_id · b4f5aca4
      brian m. carlson 提交于
      Convert read_sha1_file to take a pointer to struct object_id and rename
      it read_object_file.  Do the same for read_sha1_file_extended.
      
      Convert one use in grep.c to use the new function without any other code
      change, since the pointer being passed is a void pointer that is already
      initialized with a pointer to struct object_id.  Update the declaration
      and definitions of the modified functions, and apply the following
      semantic patch to convert the remaining callers:
      
      @@
      expression E1, E2, E3;
      @@
      - read_sha1_file(E1.hash, E2, E3)
      + read_object_file(&E1, E2, E3)
      
      @@
      expression E1, E2, E3;
      @@
      - read_sha1_file(E1->hash, E2, E3)
      + read_object_file(E1, E2, E3)
      
      @@
      expression E1, E2, E3, E4;
      @@
      - read_sha1_file_extended(E1.hash, E2, E3, E4)
      + read_object_file_extended(&E1, E2, E3, E4)
      
      @@
      expression E1, E2, E3, E4;
      @@
      - read_sha1_file_extended(E1->hash, E2, E3, E4)
      + read_object_file_extended(E1, E2, E3, E4)
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b4f5aca4
    • B
      sha1_file: convert sha1_object_info* to object_id · abef9020
      brian m. carlson 提交于
      Convert sha1_object_info and sha1_object_info_extended to take pointers
      to struct object_id and rename them to use "oid" instead of "sha1" in
      their names.  Update the declaration and definition and apply the
      following semantic patch, plus the standard object_id transforms:
      
      @@
      expression E1, E2;
      @@
      - sha1_object_info(E1.hash, E2)
      + oid_object_info(&E1, E2)
      
      @@
      expression E1, E2;
      @@
      - sha1_object_info(E1->hash, E2)
      + oid_object_info(E1, E2)
      
      @@
      expression E1, E2, E3;
      @@
      - sha1_object_info_extended(E1.hash, E2, E3)
      + oid_object_info_extended(&E1, E2, E3)
      
      @@
      expression E1, E2, E3;
      @@
      - sha1_object_info_extended(E1->hash, E2, E3)
      + oid_object_info_extended(E1, E2, E3)
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      abef9020
    • B
      sha1_file: convert check_sha1_signature to struct object_id · 17e65451
      brian m. carlson 提交于
      Convert this function to take a pointer to struct object_id and rename
      it check_object_signature.  Introduce temporaries to convert the return
      values of lookup_replace_object and lookup_replace_object_extended into
      struct object_id.
      
      The temporaries are needed because in order to convert
      lookup_replace_object, open_istream needs to be converted, and
      open_istream needs check_sha1_signature to be converted, causing a loop
      of dependencies.  The temporaries will be removed in a future patch.
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      17e65451
  7. 15 2月, 2018 1 次提交
  8. 29 12月, 2017 1 次提交
  9. 09 12月, 2017 1 次提交
    • J
      rev-list: support termination at promisor objects · df11e196
      Jonathan Tan 提交于
      Teach rev-list to support termination of an object traversal at any
      object from a promisor remote (whether one that the local repo also has,
      or one that the local repo knows about because it has another promisor
      object that references it).
      
      This will be used subsequently in gc and in the connectivity check used
      by fetch.
      
      For efficiency, if an object is referenced by a promisor object, and is
      in the local repo only as a non-promisor object, object traversal will
      not stop there. This is to avoid building the list of promisor object
      references.
      
      (In list-objects.c, the case where obj is NULL in process_blob() and
      process_tree() do not need to be changed because those happen only when
      there is a conflict between the expected type and the existing object.
      If the object doesn't exist, an object will be synthesized, which is
      fine.)
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJeff Hostetler <jeffhost@microsoft.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      df11e196
  10. 24 9月, 2017 1 次提交
    • M
      object_array: add and use `object_array_pop()` · 71992039
      Martin Ågren 提交于
      In a couple of places, we pop objects off an object array `foo` by
      decreasing `foo.nr`. We access `foo.nr` in many places, but most if not
      all other times we do so read-only, e.g., as we iterate over the array.
      But when we change `foo.nr` behind the array's back, it feels a bit
      nasty and looks like it might leak memory.
      
      Leaks happen if the popped element has an allocated `name` or `path`.
      At the moment, that is not the case. Still, 1) the object array might
      gain more fields that want to be freed, 2) a code path where we pop
      might start using names or paths, 3) one of these code paths might be
      copied to somewhere where we do, and 4) using a dedicated function for
      popping is conceptually cleaner.
      
      Introduce and use `object_array_pop()` instead. Release memory in the
      new function. Document that popping an object leaves the associated
      elements in limbo.
      
      The converted places were identified by grepping for "\.nr\>" and
      looking for "--".
      
      Make the new function return NULL on an empty array. This is consistent
      with `pop_commit()` and allows the following:
      
      	while ((o = object_array_pop(&foo)) != NULL) {
      		// do something
      	}
      
      But as noted above, we don't need to go out of our way to avoid reading
      `foo.nr`. This is probably more readable:
      
      	while (foo.nr) {
      		... o = object_array_pop(&foo);
      		// do something
      	}
      
      The name of `object_array_pop()` does not quite align with
      `add_object_array()`. That is unfortunate. On the other hand, it matches
      `object_array_clear()`. Arguably it's `add_...` that is the odd one out,
      since it reads like it's used to "add" an "object array". For that
      reason, side with `object_array_clear()`.
      Signed-off-by: NMartin Ågren <martin.agren@gmail.com>
      Reviewed-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      71992039
  11. 21 7月, 2017 1 次提交
  12. 17 6月, 2017 1 次提交
  13. 08 5月, 2017 6 次提交
    • B
      object: convert parse_object* to take struct object_id · c251c83d
      brian m. carlson 提交于
      Make parse_object, parse_object_or_die, and parse_object_buffer take a
      pointer to struct object_id.  Remove the temporary variables inserted
      earlier, since they are no longer necessary.  Transform all of the
      callers using the following semantic patch:
      
      @@
      expression E1;
      @@
      - parse_object(E1.hash)
      + parse_object(&E1)
      
      @@
      expression E1;
      @@
      - parse_object(E1->hash)
      + parse_object(E1)
      
      @@
      expression E1, E2;
      @@
      - parse_object_or_die(E1.hash, E2)
      + parse_object_or_die(&E1, E2)
      
      @@
      expression E1, E2;
      @@
      - parse_object_or_die(E1->hash, E2)
      + parse_object_or_die(E1, E2)
      
      @@
      expression E1, E2, E3, E4, E5;
      @@
      - parse_object_buffer(E1.hash, E2, E3, E4, E5)
      + parse_object_buffer(&E1, E2, E3, E4, E5)
      
      @@
      expression E1, E2, E3, E4, E5;
      @@
      - parse_object_buffer(E1->hash, E2, E3, E4, E5)
      + parse_object_buffer(E1, E2, E3, E4, E5)
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c251c83d
    • B
      Convert lookup_tag to struct object_id · d3101b53
      brian m. carlson 提交于
      Convert lookup_tag to take a pointer to struct object_id.
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d3101b53
    • B
      Convert lookup_tree to struct object_id · 740ee055
      brian m. carlson 提交于
      Convert the lookup_tree function to take a pointer to struct object_id.
      
      The commit was created with manual changes to tree.c, tree.h, and
      object.c, plus the following semantic patch:
      
      @@
      @@
      - lookup_tree(EMPTY_TREE_SHA1_BIN)
      + lookup_tree(&empty_tree_oid)
      
      @@
      expression E1;
      @@
      - lookup_tree(E1.hash)
      + lookup_tree(&E1)
      
      @@
      expression E1;
      @@
      - lookup_tree(E1->hash)
      + lookup_tree(E1)
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      740ee055
    • B
      Convert lookup_blob to struct object_id · 3aca1fc6
      brian m. carlson 提交于
      Convert lookup_blob to take a pointer to struct object_id.
      
      The commit was created with manual changes to blob.c and blob.h, plus
      the following semantic patch:
      
      @@
      expression E1;
      @@
      - lookup_blob(E1.hash)
      + lookup_blob(&E1)
      
      @@
      expression E1;
      @@
      - lookup_blob(E1->hash)
      + lookup_blob(E1)
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3aca1fc6
    • B
      Convert remaining callers of lookup_blob to object_id · 3e930981
      brian m. carlson 提交于
      All but a few callers of lookup_blob have been converted to struct
      object_id.  Introduce a temporary, which will be removed later, into
      parse_object to ease the transition, and convert the remaining callers
      so that we can update lookup_blob to take struct object_id *.
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3e930981
    • B
      Convert lookup_commit* to struct object_id · bc83266a
      brian m. carlson 提交于
      Convert lookup_commit, lookup_commit_or_die,
      lookup_commit_reference, and lookup_commit_reference_gently to take
      struct object_id arguments.
      
      Introduce a temporary in parse_object buffer in order to convert this
      function.  This is required since in order to convert parse_object and
      parse_object_buffer, lookup_commit_reference_gently and
      lookup_commit_or_die would need to be converted.  Not introducing a
      temporary would therefore require that lookup_commit_or_die take a
      struct object_id *, but lookup_commit would take unsigned char *,
      leaving a confusing and hard-to-use interface.
      
      parse_object_buffer will lose this temporary in a later patch.
      
      This commit was created with manual changes to commit.c, commit.h, and
      object.c, plus the following semantic patch:
      
      @@
      expression E1, E2;
      @@
      - lookup_commit_reference_gently(E1.hash, E2)
      + lookup_commit_reference_gently(&E1, E2)
      
      @@
      expression E1, E2;
      @@
      - lookup_commit_reference_gently(E1->hash, E2)
      + lookup_commit_reference_gently(E1, E2)
      
      @@
      expression E1;
      @@
      - lookup_commit_reference(E1.hash)
      + lookup_commit_reference(&E1)
      
      @@
      expression E1;
      @@
      - lookup_commit_reference(E1->hash)
      + lookup_commit_reference(E1)
      
      @@
      expression E1;
      @@
      - lookup_commit(E1.hash)
      + lookup_commit(&E1)
      
      @@
      expression E1;
      @@
      - lookup_commit(E1->hash)
      + lookup_commit(E1)
      
      @@
      expression E1, E2;
      @@
      - lookup_commit_or_die(E1.hash, E2)
      + lookup_commit_or_die(&E1, E2)
      
      @@
      expression E1, E2;
      @@
      - lookup_commit_or_die(E1->hash, E2)
      + lookup_commit_or_die(E1, E2)
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bc83266a
  14. 31 1月, 2017 1 次提交
    • R
      use SWAP macro · 35d803bc
      René Scharfe 提交于
      Apply the semantic patch swap.cocci to convert hand-rolled swaps to use
      the macro SWAP.  The resulting code is shorter and easier to read, the
      object code is effectively unchanged.
      
      The patch for object.c had to be hand-edited in order to preserve the
      comment before the change; Coccinelle tried to eat it for some reason.
      Signed-off-by: NRene Scharfe <l.s.r@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      35d803bc
  15. 20 11月, 2015 3 次提交
  16. 18 4月, 2015 1 次提交
  17. 20 10月, 2014 1 次提交
  18. 17 10月, 2014 3 次提交
    • J
      make add_object_array_with_context interface more sane · 9e0c3c4f
      Jeff King 提交于
      When you resolve a sha1, you can optionally keep any context
      found during the resolution, including the path and mode of
      a tree entry (e.g., when looking up "HEAD:subdir/file.c").
      
      The add_object_array_with_context function lets you then
      attach that context to an entry in a list. Unfortunately,
      the interface for doing so is horrible. The object_context
      structure is large and most object_array users do not use
      it. Therefore we keep a pointer to the structure to avoid
      burdening other users too much. But that means when we do
      use it that we must allocate the struct ourselves. And the
      struct contains a fixed PATH_MAX-sized buffer, which makes
      this wholly unsuitable for any large arrays.
      
      We can observe that there is only a single user of the
      "with_context" variant: builtin/grep.c. And in that use
      case, the only element we care about is the path. We can
      therefore store only the path as a pointer (the context's
      mode field was redundant with the object_array_entry itself,
      and nobody actually cared about the surrounding tree). This
      still requires a strdup of the pathname, but at least we are
      only consuming the minimum amount of memory for each string.
      
      We can also handle the copying ourselves in
      add_object_array_*, and free it as appropriate in
      object_array_release_entry.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9e0c3c4f
    • J
      object_array: add a "clear" function · 46be8231
      Jeff King 提交于
      There's currently no easy way to free the memory associated
      with an object_array (and in most cases, we simply leak the
      memory in a rev_info's pending array). Let's provide a
      helper to make this easier to handle.
      
      We can make use of it in list-objects.c, which does the same
      thing by hand (but fails to free the "name" field of each
      entry, potentially leaking memory).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      46be8231
    • J
      object_array: factor out slopbuf-freeing logic · 68f49235
      Jeff King 提交于
      This is not a lot of code, but it's a logical construct that
      should not need to be repeated (and we are about to add a
      third repetition).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      68f49235
  19. 19 9月, 2014 1 次提交