1. 09 Dec, 2018 1 commit
    • Duy Nguyen's avatar
      Indent code with TABs · ec36c42a
      Duy Nguyen authored
      We indent with TABs and sometimes for fine alignment, TABs followed by
      spaces, but never all spaces (unless the indentation is less than 8
      columns). Indenting with spaces slips through in some places. Fix
      them.
      
      Imported code and compat/ are left alone on purpose. The former should
      remain as close as upstream as possible. The latter pretty much has
      separate maintainers, it's up to them to decide.
      Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      ec36c42a
  2. 19 Nov, 2018 1 commit
  3. 12 Nov, 2018 1 commit
  4. 26 Oct, 2018 1 commit
    • Josh Steadmon's avatar
      archive: initialize archivers earlier · 00436bf1
      Josh Steadmon authored
      Initialize archivers as soon as possible when running git-archive.
      Various non-obvious behavior depends on having the archivers
      initialized, such as determining the desired archival format from the
      provided filename.
      
      Since 08716b3c ("archive: refactor file extension format-guessing",
      2011-06-21), archive_format_from_filename() has used the registered
      archivers to match filenames (provided via --output) to archival
      formats. However, when git-archive is executed with --remote, format
      detection happens before the archivers have been registered. This causes
      archives from remotes to always be generated as TAR files, regardless of
      the actual filename (unless an explicit --format is provided).
      
      This patch fixes that behavior; archival format is determined properly
      from the output filename, even when --remote is used.
      Helped-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJosh Steadmon <steadmon@google.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      00436bf1
  5. 17 Sep, 2018 1 commit
  6. 12 Sep, 2018 1 commit
  7. 13 Aug, 2018 5 commits
    • Duy Nguyen's avatar
      b612ee20
    • Duy Nguyen's avatar
      attr: remove index from git_attr_set_direction() · c4500e25
      Duy Nguyen authored
      Since attr checking API now take the index, there's no need to set an
      index in advance with this call. Most call sites are straightforward
      because they either pass the_index or NULL (which defaults back to
      the_index previously). There's only one suspicious call site in
      unpack-trees.c where it sets a different index.
      
      This code in unpack-trees is about to check out entries from the
      new/temporary index after merging is done in it. The attributes will
      be used by entry.c code to do crlf conversion if needed. entry.c now
      respects struct checkout's istate field, and this field is correctly
      set in unpack-trees.c, there should be no regression from this change.
      Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      c4500e25
    • Duy Nguyen's avatar
      dir.c: remove an implicit dependency on the_index in pathspec code · 6d2df284
      Duy Nguyen authored
      Make the match_patchspec API and friends take an index_state instead
      of assuming the_index in dir.c. All external call sites are converted
      blindly to keep the patch simple and retain current behavior.
      Individual call sites may receive further updates to use the right
      index instead of the_index.
      Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      6d2df284
    • Duy Nguyen's avatar
      convert.c: remove an implicit dependency on the_index · 7f944e26
      Duy Nguyen authored
      Make the convert API take an index_state instead of assuming the_index
      in convert.c. All external call sites are converted blindly to keep
      the patch simple and retain current behavior. Individual call sites
      may receive further updates to use the right index instead of
      the_index.
      Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      7f944e26
    • Duy Nguyen's avatar
      attr: remove an implicit dependency on the_index · 7a400a2c
      Duy Nguyen authored
      Make the attr API take an index_state instead of assuming the_index in
      attr code. All call sites are converted blindly to keep the patch
      simple and retain current behavior. Individual call sites may receive
      further updates to use the right index instead of the_index.
      
      There is one ugly temporary workaround added in attr.c that needs some
      more explanation.
      
      Commit c24f3aba (apply: file commited with CRLF should roundtrip
      diff and apply - 2017-08-19) forces one convert_to_git() call to NOT
      read the index at all. But what do you know, we read it anyway by
      falling back to the_index. When "istate" from convert_to_git is now
      propagated down to read_attr_from_array() we will hit segfault
      somewhere inside read_blob_data_from_index.
      
      The right way of dealing with this is to kill "use_index" variable and
      only follow "istate" but at this stage we are not ready for that:
      while most git_attr_set_direction() calls just passes the_index to be
      assigned to use_index, unpack-trees passes a different one which is
      used by entry.c code, which has no way to know what index to use if we
      delete use_index. So this has to be done later.
      Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      7a400a2c
  8. 29 Jun, 2018 1 commit
  9. 24 May, 2018 1 commit
  10. 16 May, 2018 1 commit
    • Stefan Beller's avatar
      object-store: move object access functions to object-store.h · cbd53a21
      Stefan Beller authored
      This should make these functions easier to find and cache.h less
      overwhelming to read.
      
      In particular, this moves:
      - read_object_file
      - oid_object_info
      - write_object_file
      
      As a result, most of the codebase needs to #include object-store.h.
      In this patch the #include is only added to files that would fail to
      compile otherwise.  It would be better to #include wherever
      identifiers from the header are used.  That can happen later
      when we have better tooling for it.
      Signed-off-by: Stefan Beller's avatarStefan Beller <sbeller@google.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      cbd53a21
  11. 14 Mar, 2018 5 commits
  12. 16 Oct, 2017 1 commit
  13. 14 Sep, 2017 1 commit
    • René Scharfe's avatar
      archive: don't add empty directories to archives · 43180940
      René Scharfe authored
      While git doesn't track empty directories, git archive can be tricked
      into putting some into archives.  One way is to construct an empty tree
      object, as t5004 does.  While that is supported by the object database,
      it can't be represented in the index and thus it's unlikely to occur in
      the wild.
      
      Another way is using the literal name of a directory in an exclude
      pathspec -- its contents are are excluded, but the directory stub is
      included.  That's inconsistent: exclude pathspecs containing wildcards
      don't leave empty directories in the archive.
      
      Yet another way is have a few levels of nested subdirectories (e.g.
      d1/d2/d3/file1) and ignoring the entries at the leaves (e.g. file1).
      The directories with the ignored content are ignored as well (e.g. d3),
      but their empty parents are included (e.g. d2).
      
      As empty directories are not supported by git, they should also not be
      written into archives.  If an empty directory is really needed then it
      can be tracked and archived by placing an empty .gitignore file in it.
      
      There already is a mechanism in place for suppressing empty directories.
      When read_tree_recursive() encounters a directory excluded by a pathspec
      then it enters it anyway because it might contain included entries.  It
      calls the callback function before it is able to decide if the directory
      is actually needed.  For that reason git archive adds directories to a
      queue and writes entries for them only when it encounters the first
      child item -- but currently only if pathspecs with wildcards are used.
      
      Queue *all* directories, no matter if there even are pathspecs present.
      This prevents git archive from writing entries for empty directories in
      all cases.
      Suggested-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarRene Scharfe <l.s.r@web.de>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      43180940
  14. 19 Aug, 2017 2 commits
  15. 17 Jul, 2017 1 commit
    • brian m. carlson's avatar
      sha1_name: convert get_sha1* to get_oid* · e82caf38
      brian m. carlson authored
      Now that all the callers of get_sha1 directly or indirectly use struct
      object_id, rename the functions starting with get_sha1 to start with
      get_oid.  Convert the internals in sha1_name.c to use struct object_id
      as well, and eliminate explicit length checks where possible.  Convert a
      use of 40 in get_oid_basic to GIT_SHA1_HEXSZ.
      
      Outside of sha1_name.c and cache.h, this transition was made with the
      following semantic patch:
      
      @@
      expression E1, E2;
      @@
      - get_sha1(E1, E2.hash)
      + get_oid(E1, &E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1(E1, E2->hash)
      + get_oid(E1, E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1_committish(E1, E2.hash)
      + get_oid_committish(E1, &E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1_committish(E1, E2->hash)
      + get_oid_committish(E1, E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1_treeish(E1, E2.hash)
      + get_oid_treeish(E1, &E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1_treeish(E1, E2->hash)
      + get_oid_treeish(E1, E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1_commit(E1, E2.hash)
      + get_oid_commit(E1, &E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1_commit(E1, E2->hash)
      + get_oid_commit(E1, E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1_tree(E1, E2.hash)
      + get_oid_tree(E1, &E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1_tree(E1, E2->hash)
      + get_oid_tree(E1, E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1_blob(E1, E2.hash)
      + get_oid_blob(E1, &E2)
      
      @@
      expression E1, E2;
      @@
      - get_sha1_blob(E1, E2->hash)
      + get_oid_blob(E1, E2)
      
      @@
      expression E1, E2, E3, E4;
      @@
      - get_sha1_with_context(E1, E2, E3.hash, E4)
      + get_oid_with_context(E1, E2, &E3, E4)
      
      @@
      expression E1, E2, E3, E4;
      @@
      - get_sha1_with_context(E1, E2, E3->hash, E4)
      + get_oid_with_context(E1, E2, E3, E4)
      Signed-off-by: brian m. carlson's avatarbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      e82caf38
  16. 15 Jun, 2017 1 commit
  17. 08 May, 2017 2 commits
    • brian m. carlson's avatar
      tree: convert parse_tree_indirect to struct object_id · a9dbc179
      brian m. carlson authored
      Convert parse_tree_indirect to take a pointer to struct object_id.
      Update all the callers.  This transformation was achieved using the
      following semantic patch and manual updates to the declaration and
      definition.  Update builtin/checkout.c manually as well, since it uses a
      ternary expression not handled by the semantic patch.
      
      @@
      expression E1;
      @@
      - parse_tree_indirect(E1.hash)
      + parse_tree_indirect(&E1)
      
      @@
      expression E1;
      @@
      - parse_tree_indirect(E1->hash)
      + parse_tree_indirect(E1)
      Signed-off-by: brian m. carlson's avatarbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      a9dbc179
    • brian m. carlson's avatar
      Convert lookup_commit* to struct object_id · bc83266a
      brian m. carlson authored
      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: brian m. carlson's avatarbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      bc83266a
  18. 01 Feb, 2017 2 commits
  19. 22 Nov, 2016 1 commit
    • Junio C Hamano's avatar
      archive: read local configuration · eb0224c6
      Junio C Hamano authored
      Since b9605bc4 ("config: only read .git/config from configured
      repos", 2016-09-12), we do not read from ".git/config" unless we
      know we are in a repository.  "git archive" however didn't do the
      repository discovery and instead relied on the old behaviour.
      
      Teach the command to run a "gentle" version of repository discovery
      so that local configuration variables are honoured.
      
      [jc: stole tests from peff]
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      eb0224c6
  20. 09 Aug, 2016 1 commit
  21. 02 Jun, 2016 1 commit
  22. 22 Feb, 2016 1 commit
  23. 20 Nov, 2015 2 commits
  24. 05 Oct, 2015 1 commit
    • Jeff King's avatar
      avoid sprintf and strcpy with flex arrays · c7ab0ba3
      Jeff King authored
      When we are allocating a struct with a FLEX_ARRAY member, we
      generally compute the size of the array and then sprintf or
      strcpy into it. Normally we could improve a dynamic allocation
      like this by using xstrfmt, but it doesn't work here; we
      have to account for the size of the rest of the struct.
      
      But we can improve things a bit by storing the length that
      we use for the allocation, and then feeding it to xsnprintf
      or memcpy, which makes it more obvious that we are not
      writing more than the allocated number of bytes.
      
      It would be nice if we had some kind of helper for
      allocating generic flex arrays, but it doesn't work that
      well:
      
       - the call signature is a little bit unwieldy:
      
            d = flex_struct(sizeof(*d), offsetof(d, path), fmt, ...);
      
         You need offsetof here instead of just writing to the
         end of the base size, because we don't know how the
         struct is packed (partially this is because FLEX_ARRAY
         might not be zero, though we can account for that; but
         the size of the struct may actually be rounded up for
         alignment, and we can't know that).
      
       - some sites do clever things, like over-allocating because
         they know they will write larger things into the buffer
         later (e.g., struct packed_git here).
      
      So we're better off to just write out each allocation (or
      add type-specific helpers, though many of these are one-off
      allocations anyway).
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      c7ab0ba3
  25. 29 Jun, 2015 1 commit
    • Jeff King's avatar
      convert "enum date_mode" into a struct · a5481a6c
      Jeff King authored
      In preparation for adding date modes that may carry extra
      information beyond the mode itself, this patch converts the
      date_mode enum into a struct.
      
      Most of the conversion is fairly straightforward; we pass
      the struct as a pointer and dereference the type field where
      necessary. Locations that declare a date_mode can use a "{}"
      constructor.  However, the tricky case is where we use the
      enum labels as constants, like:
      
        show_date(t, tz, DATE_NORMAL);
      
      Ideally we could say:
      
        show_date(t, tz, &{ DATE_NORMAL });
      
      but of course C does not allow that. Likewise, we cannot
      cast the constant to a struct, because we need to pass an
      actual address. Our options are basically:
      
        1. Manually add a "struct date_mode d = { DATE_NORMAL }"
           definition to each caller, and pass "&d". This makes
           the callers uglier, because they sometimes do not even
           have their own scope (e.g., they are inside a switch
           statement).
      
        2. Provide a pre-made global "date_normal" struct that can
           be passed by address. We'd also need "date_rfc2822",
           "date_iso8601", and so forth. But at least the ugliness
           is defined in one place.
      
        3. Provide a wrapper that generates the correct struct on
           the fly. The big downside is that we end up pointing to
           a single global, which makes our wrapper non-reentrant.
           But show_date is already not reentrant, so it does not
           matter.
      
      This patch implements 3, along with a minor macro to keep
      the size of the callers sane.
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      a5481a6c
  26. 22 Jun, 2015 1 commit
  27. 14 Mar, 2015 1 commit
  28. 14 Jan, 2015 1 commit