1. 16 Apr, 2019 21 commits
  2. 08 Apr, 2019 3 commits
  3. 29 Mar, 2019 1 commit
    • Duy Nguyen's avatar
      doc: promote "git switch" · 5a921aa0
      Duy Nguyen authored
      The new command "git switch" is added to avoid the confusion of
      one-command-do-all "git checkout" for new users. They are also helpful
      to avoid ambiguation context.
      
      For these reasons, promote it everywhere possible. This includes
      documentation, suggestions/advice from other commands...
      
      The "Checking out files" progress line in unpack-trees.c is also updated
      to "Updating files" to be neutral to both git-checkout and git-switch.
      5a921aa0
  4. 24 Mar, 2019 1 commit
    • Duy Nguyen's avatar
      sha1_name.c: add an option to abort on ambiguous refs · c7060248
      Duy Nguyen authored
      There are cases when a warning on ambiguous ref may go unnoticed
      (e.g. git-log filling up the whole screen). There are also cases when
      people want to catch ambiguation early (e.g. it happens deep in some
      script). In either case, aborting the program would accomplish it.
      c7060248
  5. 14 Mar, 2019 1 commit
    • Johannes Schindelin's avatar
      get_oid(): when an object was not found, try harder · 6d67a993
      Johannes Schindelin authored
      It is quite possible that the loose object cache gets stale when new
      objects are written. In that case, get_oid() would potentially say that
      it cannot find a given object, even if it should find it.
      
      Let's blow away the loose object cache as well as the read packs and try
      again in that case.
      
      Note: this does *not* affect the code path that was introduced to help
      avoid looking for the same non-existing objects (which made some
      operations really expensive via NFS): that code path is handled by the
      `OBJECT_INFO_QUICK` flag (which does not even apply to `get_oid()`,
      which has no equivalent flag, at least at the time this patch was
      written).
      
      This incidentally fixes the problem identified earlier where an
      interactive rebase wanted to re-read (and validate) the todo list after
      an `exec` command modified it.
      Helped-by: 's avatarJeff King <peff@peff.net>
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      6d67a993
  6. 28 Feb, 2019 1 commit
  7. 12 Feb, 2019 1 commit
  8. 18 Jan, 2019 1 commit
  9. 14 Jan, 2019 2 commits
  10. 08 Jan, 2019 1 commit
  11. 13 Nov, 2018 4 commits
    • Jeff King's avatar
      object-store: provide helpers for loose_objects_cache · 3a2e0824
      Jeff King authored
      Our object_directory struct has a loose objects cache that all users of
      the struct can see. But the only one that knows how to load the cache is
      find_short_object_filename(). Let's extract that logic in to a reusable
      function.
      
      While we're at it, let's also reset the cache when we re-read the object
      directories. This shouldn't have an impact on performance, as re-reads
      are meant to be rare (and are already expensive, so we avoid them with
      things like OBJECT_INFO_QUICK).
      
      Since the cache is already meant to be an approximation, it's tempting
      to skip even this bit of safety. But it's necessary to allow more code
      to use it. For instance, fetch-pack explicitly re-reads the object
      directory after performing its fetch, and would be confused if we didn't
      clear the cache.
      Signed-off-by: 's avatarJeff King <peff@peff.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      3a2e0824
    • Jeff King's avatar
      sha1-file: use an object_directory for the main object dir · f0eaf638
      Jeff King authored
      Our handling of alternate object directories is needlessly different
      from the main object directory. As a result, many places in the code
      basically look like this:
      
        do_something(r->objects->objdir);
      
        for (odb = r->objects->alt_odb_list; odb; odb = odb->next)
              do_something(odb->path);
      
      That gets annoying when do_something() is non-trivial, and we've
      resorted to gross hacks like creating fake alternates (see
      find_short_object_filename()).
      
      Instead, let's give each raw_object_store a unified list of
      object_directory structs. The first will be the main store, and
      everything after is an alternate. Very few callers even care about the
      distinction, and can just loop over the whole list (and those who care
      can just treat the first element differently).
      
      A few observations:
      
        - we don't need r->objects->objectdir anymore, and can just
          mechanically convert that to r->objects->odb->path
      
        - object_directory's path field needs to become a real pointer rather
          than a FLEX_ARRAY, in order to fill it with expand_base_dir()
      
        - we'll call prepare_alt_odb() earlier in many functions (i.e.,
          outside of the loop). This may result in us calling it even when our
          function would be satisfied looking only at the main odb.
      
          But this doesn't matter in practice. It's not a very expensive
          operation in the first place, and in the majority of cases it will
          be a noop. We call it already (and cache its results) in
          prepare_packed_git(), and we'll generally check packs before loose
          objects. So essentially every program is going to call it
          immediately once per program.
      
          Arguably we should just prepare_alt_odb() immediately upon setting
          up the repository's object directory, which would save us sprinkling
          calls throughout the code base (and forgetting to do so has been a
          source of subtle bugs in the past). But I've stopped short of that
          here, since there are already a lot of other moving parts in this
          patch.
      
        - Most call sites just get shorter. The check_and_freshen() functions
          are an exception, because they have entry points to handle local and
          nonlocal directories separately.
      Signed-off-by: 's avatarJeff King <peff@peff.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      f0eaf638
    • Jeff King's avatar
      handle alternates paths the same as the main object dir · f3f043a1
      Jeff King authored
      When we generate loose file paths for the main object directory, the
      caller provides a buffer to loose_object_path (formerly sha1_file_name).
      The callers generally keep their own static buffer to avoid excessive
      reallocations.
      
      But for alternate directories, each struct carries its own scratch
      buffer. This is needlessly different; let's unify them.
      
      We could go either direction here, but this patch moves the alternates
      struct over to the main directory style (rather than vice-versa).
      Technically the alternates style is more efficient, as it avoids
      rewriting the object directory name on each call. But this is unlikely
      to matter in practice, as we avoid reallocations either way (and nobody
      has ever noticed or complained that the main object directory is copying
      a few extra bytes before making a much more expensive system call).
      
      And this has the advantage that the reusable buffers are tied to
      particular calls, which makes the invalidation rules simpler (for
      example, the return value from stat_sha1_file() used to be invalidated
      by basically any other object call, but now it is affected only by other
      calls to stat_sha1_file()).
      
      We do steal the trick from alt_sha1_path() of returning a pointer to the
      filled buffer, which makes a few conversions more convenient.
      Signed-off-by: 's avatarJeff King <peff@peff.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      f3f043a1
    • Jeff King's avatar
      rename "alternate_object_database" to "object_directory" · 263db403
      Jeff King authored
      In preparation for unifying the handling of alt odb's and the normal
      repo object directory, let's use a more neutral name. This patch is
      purely mechanical, swapping the type name, and converting any variables
      named "alt" to "odb". There should be no functional change, but it will
      reduce the noise in subsequent diffs.
      Signed-off-by: 's avatarJeff King <peff@peff.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      263db403
  12. 29 Aug, 2018 1 commit
    • Jeff King's avatar
      convert "oidcmp() == 0" to oideq() · 4a7e27e9
      Jeff King authored
      Using the more restrictive oideq() should, in the long run,
      give the compiler more opportunities to optimize these
      callsites. For now, this conversion should be a complete
      noop with respect to the generated code.
      
      The result is also perhaps a little more readable, as it
      avoids the "zero is equal" idiom. Since it's so prevalent in
      C, I think seasoned programmers tend not to even notice it
      anymore, but it can sometimes make for awkward double
      negations (e.g., we can drop a few !!oidcmp() instances
      here).
      
      This patch was generated almost entirely by the included
      coccinelle patch. This mechanical conversion should be
      completely safe, because we check explicitly for cases where
      oidcmp() is compared to 0, which is what oideq() is doing
      under the hood. Note that we don't have to catch "!oidcmp()"
      separately; coccinelle's standard isomorphisms make sure the
      two are treated equivalently.
      
      I say "almost" because I did hand-edit the coccinelle output
      to fix up a few style violations (it mostly keeps the
      original formatting, but sometimes unwraps long lines).
      Signed-off-by: 's avatarJeff King <peff@peff.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      4a7e27e9
  13. 20 Jul, 2018 2 commits