1. 02 12月, 2014 4 次提交
    • N
      reflog: avoid constructing .lock path with git_path · 1fdc2abf
      Nguyễn Thái Ngọc Duy 提交于
      Among pathnames in $GIT_DIR, e.g. "index" or "packed-refs", we want to
      automatically and silently map some of them to the $GIT_DIR of the
      repository we are borrowing from via $GIT_COMMON_DIR mechanism.  When
      we formulate the pathname for its lockfile, we want it to be in the
      same location as its final destination.  "index" is not shared and
      needs to remain in the borrowing repository, while "packed-refs" is
      shared and needs to go to the borrowed repository.
      
      git_path() could be taught about the ".lock" suffix and map
      "index.lock" and "packed-refs.lock" the same way their basenames are
      mapped, but instead the caller can help by asking where the basename
      (e.g. "index") is mapped to git_path() and then appending ".lock"
      after the mapping is done.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1fdc2abf
    • N
      git_path(): be aware of file relocation in $GIT_DIR · 557bd833
      Nguyễn Thái Ngọc Duy 提交于
      We allow the user to relocate certain paths out of $GIT_DIR via
      environment variables, e.g. GIT_OBJECT_DIRECTORY, GIT_INDEX_FILE and
      GIT_GRAFT_FILE. Callers are not supposed to use git_path() or
      git_pathdup() to get those paths. Instead they must use
      get_object_directory(), get_index_file() and get_graft_file()
      respectively. This is inconvenient and could be missed in review (for
      example, there's git_path("objects/info/alternates") somewhere in
      sha1_file.c).
      
      This patch makes git_path() and git_pathdup() understand those
      environment variables. So if you set GIT_OBJECT_DIRECTORY to /foo/bar,
      git_path("objects/abc") should return /foo/bar/abc. The same is done
      for the two remaining env variables.
      
      "git rev-parse --git-path" is the wrapper for script use.
      
      This patch kinda reverts a0279e18 (setup_git_env: use git_pathdup
      instead of xmalloc + sprintf - 2014-06-19) because using git_pathdup
      here would result in infinite recursion:
      
        setup_git_env() -> git_pathdup("objects") -> .. -> adjust_git_path()
        -> get_object_directory() -> oops, git_object_directory is NOT set
        yet -> setup_git_env()
      
      I wanted to make git_pathdup_literal() that skips adjust_git_path().
      But that won't work because later on when $GIT_COMMON_DIR is
      introduced, git_pathdup_literal("objects") needs adjust_git_path() to
      replace $GIT_DIR with $GIT_COMMON_DIR.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      557bd833
    • N
      git_snpath(): retire and replace with strbuf_git_path() · 1a83c240
      Nguyễn Thái Ngọc Duy 提交于
      In the previous patch, git_snpath() is modified to allocate a new
      strbuf buffer because vsnpath() needs that. But that makes it
      awkward because git_snpath() receives a pre-allocated buffer from
      outside and has to copy data back. Rename it to strbuf_git_path()
      and make it receive strbuf directly.
      
      Using git_path() in update_refs_for_switch() which used to call
      git_snpath() is safe because that function and all of its callers do
      not keep any pointer to the round-robin buffer pool allocated by
      get_pathname().
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1a83c240
    • N
      path.c: make get_pathname() call sites return const char * · dcf69262
      Nguyễn Thái Ngọc Duy 提交于
      Before the previous commit, get_pathname returns an array of PATH_MAX
      length. Even if git_path() and similar functions does not use the
      whole array, git_path() caller can, in theory.
      
      After the commit, get_pathname() may return a buffer that has just
      enough room for the returned string and git_path() caller should never
      write beyond that.
      
      Make git_path(), mkpath() and git_path_submodule() return a const
      buffer to make sure callers do not write in it at all.
      
      This could have been part of the previous commit, but the "const"
      conversion is too much distraction from the core changes in path.c.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dcf69262
  2. 05 11月, 2014 1 次提交
    • J
      fetch: load all default config at startup · 72549dfd
      Jeff King 提交于
      When we start the git-fetch program, we call git_config to
      load all config, but our callback only processes the
      fetch.prune option; we do not chain to git_default_config at
      all.
      
      This means that we may not load some core configuration
      which will have an effect. For instance, we do not load
      core.logAllRefUpdates, which impacts whether or not we
      create reflogs in a bare repository.
      
      Note that I said "may" above. It gets even more exciting. If
      we have to transfer actual objects as part of the fetch,
      then we call fetch_pack as part of the same process. That
      function loads its own config, which does chain to
      git_default_config, impacting global variables which are
      used by the rest of fetch. But if the fetch is a pure ref
      update (e.g., a new ref which is a copy of an old one), we
      skip fetch_pack entirely. So we get inconsistent results
      depending on whether or not we have actual objects to
      transfer or not!
      
      Let's just load the core config at the start of fetch, so we
      know we have it (we may also load it again as part of
      fetch_pack, but that's OK; it's designed to be idempotent).
      
      Our tests check both cases (with and without a pack). We
      also check similar behavior for push for good measure, but
      it already works as expected.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      72549dfd
  3. 29 10月, 2014 1 次提交
  4. 25 10月, 2014 1 次提交
  5. 20 10月, 2014 6 次提交
    • E
      Handle atexit list internaly for unthreaded builds · 0f4b6db3
      Etienne Buira 提交于
      Wrap atexit()s calls on unthreaded builds to handle callback list
      internally.
      
      This is needed because on unthreaded builds, asyncs inherits parent's
      atexit() list, that gets run as soon as the async exit()s (and again at
      the end of async's parent process). That led to remove temporary files
      too early.
      
      Also remove a by-atexit-callback guard against this kind of issue in
      clone.c, as this patch makes it redundant.
      
      Fixes test 5537 (temporary shallow file vanished before unpack-objects
      could open it)
      
      BTW remove an unused variable in shallow.c.
      Helped-by: NDuy Nguyen <pclouds@gmail.com>
      Helped-by: NAndreas Schwab <schwab@linux-m68k.org>
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NEtienne Buira <etienne.buira@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0f4b6db3
    • R
      use env_array member of struct child_process · a9154590
      René Scharfe 提交于
      Convert users of struct child_process to using the managed env_array for
      specifying environment variables instead of supplying an array on the
      stack or bringing their own argv_array.  This shortens and simplifies
      the code and ensures automatically that the allocated memory is freed
      after use.
      Signed-off-by: NRene Scharfe <l.s.r@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a9154590
    • J
      pack-objects: turn off bitmaps when we split packs · 21134714
      Jeff King 提交于
      If a pack.packSizeLimit is set, we may split the pack data
      across multiple packfiles. This means we cannot generate
      .bitmap files, as they require that all of the reachable
      objects are in the same pack. We check that condition when
      we are generating the list of objects to pack (and disable
      bitmaps if we are not packing everything), but we forgot to
      update it when we notice that we needed to split (which
      doesn't happen until the actual write phase).
      
      The resulting bitmaps are quite bogus (they mention entries
      that do not exist in the pack!) and can cause a fetch or
      push to send insufficient objects.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      21134714
    • J
      pack-objects: double-check options before discarding objects · b1e757f3
      Jeff King 提交于
      When we are given an expiration time like
      --unpack-unreachable=2.weeks.ago, we avoid writing out old,
      unreachable loose objects entirely, under the assumption
      that running "prune" would simply delete them immediately
      anyway. However, this is only valid if we computed the same
      set of reachable objects as prune would.
      
      In practice, this is the case, because only git-repack uses
      the --unpack-unreachable option with an expiration, and it
      always feeds as many objects into the pack as possible. But
      we can double-check at runtime just to be sure.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b1e757f3
    • J
      repack: pack objects mentioned by the index · c90f9e13
      Jeff King 提交于
      When we pack all objects, we use only the objects reachable
      from references and reflogs. This misses any objects which
      are reachable from the index, but not yet referenced.
      
      By itself this isn't a big deal; the objects can remain
      loose until they are actually used in a commit. However, it
      does create a problem when we drop packed but unreachable
      objects. We try to optimize out the writing of objects that
      we will immediately prune, which means we must follow the
      same rules as prune in determining what is reachable. And
      prune uses the index for this purpose.
      
      This is rather uncommon in practice, as objects in the index
      would not usually have been packed in the first place. But
      it could happen in a sequence like:
      
        1. You make a commit on a branch that references blob X.
      
        2. You repack, moving X into the pack.
      
        3. You delete the branch (and its reflog), so that X is
           unreferenced.
      
        4. You "git add" blob X so that it is now referenced only
           by the index.
      
        5. You repack again with git-gc. The pack-objects we
           invoke will see that X is neither referenced nor
           recent and not bother loosening it.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c90f9e13
    • J
      pack-objects: use argv_array · edfbb2aa
      Jeff King 提交于
      This saves us from having to bump the rp_av count when we
      add new traversal options.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      edfbb2aa
  6. 17 10月, 2014 8 次提交
    • 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
      pack-objects: match prune logic for discarding objects · abcb8655
      Jeff King 提交于
      A recent commit taught git-prune to keep non-recent objects
      that are reachable from recent ones. However, pack-objects,
      when loosening unreachable objects, tries to optimize out
      the write in the case that the object will be immediately
      pruned. It now gets this wrong, since its rule does not
      reflect the new prune code (and this can be seen by running
      t6501 with a strategically placed repack).
      
      Let's teach pack-objects similar logic.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      abcb8655
    • J
      pack-objects: refactor unpack-unreachable expiration check · d0d46abc
      Jeff King 提交于
      When we are loosening unreachable packed objects, we do not
      bother to process objects that would simply be pruned
      immediately anyway. The "would be pruned" check is a simple
      comparison, but is about to get more complicated. Let's pull
      it out into a separate function.
      
      Note that this is slightly less efficient than the original,
      which avoided even opening old packs, since no object in
      them could pass the current check, which cares only about
      the pack mtime.  But the new rules will depend on the exact
      object, so we need to perform the check even for old packs.
      
      Note also that we fix a minor buglet when the pack mtime is
      exactly the same as the expiration time. The prune code
      considers that worth pruning, whereas our check here
      considered it worth keeping. This wasn't a big deal. Besides
      being unlikely to happen, the result was simply that the
      object was loosened and then pruned, missing the
      optimization. Still, we can easily fix it while we are here.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d0d46abc
    • J
      prune: keep objects reachable from recent objects · d3038d22
      Jeff King 提交于
      Our current strategy with prune is that an object falls into
      one of three categories:
      
        1. Reachable (from ref tips, reflogs, index, etc).
      
        2. Not reachable, but recent (based on the --expire time).
      
        3. Not reachable and not recent.
      
      We keep objects from (1) and (2), but prune objects in (3).
      The point of (2) is that these objects may be part of an
      in-progress operation that has not yet updated any refs.
      
      However, it is not always the case that objects for an
      in-progress operation will have a recent mtime. For example,
      the object database may have an old copy of a blob (from an
      abandoned operation, a branch that was deleted, etc). If we
      create a new tree that points to it, a simultaneous prune
      will leave our tree, but delete the blob. Referencing that
      tree with a commit will then work (we check that the tree is
      in the object database, but not that all of its referred
      objects are), as will mentioning the commit in a ref. But
      the resulting repo is corrupt; we are missing the blob
      reachable from a ref.
      
      One way to solve this is to be more thorough when
      referencing a sha1: make sure that not only do we have that
      sha1, but that we have objects it refers to, and so forth
      recursively. The problem is that this is very expensive.
      Creating a parent link would require traversing the entire
      object graph!
      
      Instead, this patch pushes the extra work onto prune, which
      runs less frequently (and has to look at the whole object
      graph anyway). It creates a new category of objects: objects
      which are not recent, but which are reachable from a recent
      object. We do not prune these objects, just like the
      reachable and recent ones.
      
      This lets us avoid the recursive check above, because if we
      have an object, even if it is unreachable, we should have
      its referent. We can make a simple inductive argument that
      with this patch, this property holds (that there are no
      objects with missing referents in the repository):
      
        0. When we have no objects, we have nothing to refer or be
           referred to, so the property holds.
      
        1. If we add objects to the repository, their direct
           referents must generally exist (e.g., if you create a
           tree, the blobs it references must exist; if you create
           a commit to point at the tree, the tree must exist).
           This is already the case before this patch. And it is
           not 100% foolproof (you can make bogus objects using
           `git hash-object`, for example), but it should be the
           case for normal usage.
      
           Therefore for any sequence of object additions, the
           property will continue to hold.
      
        2. If we remove objects from the repository, then we will
           not remove a child object (like a blob) if an object
           that refers to it is being kept. That is the part
           implemented by this patch.
      
           Note, however, that our reachability check and the
           actual pruning are not atomic. So it _is_ still
           possible to violate the property (e.g., an object
           becomes referenced just as we are deleting it). This
           patch is shooting for eliminating problems where the
           mtimes of dependent objects differ by hours or days,
           and one is dropped without the other. It does nothing
           to help with short races.
      
      Naively, the simplest way to implement this would be to add
      all recent objects as tips to the reachability traversal.
      However, this does not perform well. In a recently-packed
      repository, all reachable objects will also be recent, and
      therefore we have to look at each object twice. This patch
      instead performs the reachability traversal, then follows up
      with a second traversal for recent objects, skipping any
      that have already been marked.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d3038d22
    • J
      count-objects: use for_each_loose_file_in_objdir · 4a1e693a
      Jeff King 提交于
      This drops our line count considerably, and should make
      things more readable by keeping the counting logic separate
      from the traversal.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4a1e693a
    • J
      count-objects: do not use xsize_t when counting object size · cac05d4d
      Jeff King 提交于
      The point of xsize_t is to safely cast an off_t into a size_t
      (because we are about to mmap). But in count-objects, we are
      summing the sizes in an off_t. Using xsize_t means that
      count-objects could fail on a 32-bit system with a 4G
      object (not likely, as other parts of git would fail, but
      we should at least be correct here).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cac05d4d
    • J
      prune-packed: use for_each_loose_file_in_objdir · 0d3b7296
      Jeff King 提交于
      This saves us from manually traversing the directory
      structure ourselves.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0d3b7296
    • J
      prune: factor out loose-object directory traversal · 27e1e22d
      Jeff King 提交于
      Prune has to walk $GIT_DIR/objects/?? in order to find the
      set of loose objects to prune. Other parts of the code
      (e.g., count-objects) want to do the same. Let's factor it
      out into a reusable for_each-style function.
      
      Note that this is not quite a straight code movement. The
      original code had strange behavior when it found a file of
      the form "[0-9a-f]{2}/.{38}" that did _not_ contain all hex
      digits. It executed a "break" from the loop, meaning that we
      stopped pruning in that directory (but still pruned other
      directories!). This was probably a bug; we do not want to
      process the file as an object, but we should keep going
      otherwise (and that is how the new code handles it).
      
      We are also a little more careful with loose object
      directories which fail to open. The original code silently
      ignored any failures, but the new code will complain about
      any problems besides ENOENT.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      27e1e22d
  7. 16 10月, 2014 8 次提交
    • R
      remote rm/prune: print a message when writing packed-refs fails · 2ebb49ca
      Ronnie Sahlberg 提交于
      Until v2.1.0-rc0~22^2~11 (refs.c: add an err argument to
      repack_without_refs, 2014-06-20), repack_without_refs forgot to
      provide an error message when commit_packed_refs fails.  Even today,
      it only provides a message for callers that pass a non-NULL err
      parameter.  Internal callers in refs.c pass non-NULL err but
      "git remote" does not.
      
      That means that "git remote rm" and "git remote prune" can fail
      without printing a message about why.  Fix them by passing in a
      non-NULL err parameter and printing the returned message.
      
      This is the last caller to a ref handling function passing err ==
      NULL.  A later patch can drop support for err == NULL, avoiding such
      problems in the future.
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Reviewed-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2ebb49ca
    • R
      for-each-ref: skip and warn about broken ref names · 971c41c7
      Ronnie Sahlberg 提交于
      Print a warning message for any bad ref names we find in the repo and
      skip them so callers don't have to deal with parsing them.
      
      It might be useful in the future to have a flag where we would not
      skip these refs for those callers that want to and are prepared (for
      example by using a --format argument with %0 as a delimiter after the
      ref name).
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      971c41c7
    • R
      refs.c: allow listing and deleting badly named refs · d0f810f0
      Ronnie Sahlberg 提交于
      We currently do not handle badly named refs well:
      
        $ cp .git/refs/heads/master .git/refs/heads/master.....@\*@\\.
        $ git branch
          fatal: Reference has invalid format: 'refs/heads/master.....@*@\.'
        $ git branch -D master.....@\*@\\.
          error: branch 'master.....@*@\.' not found.
      
      Users cannot recover from a badly named ref without manually finding
      and deleting the loose ref file or appropriate line in packed-refs.
      Making that easier will make it easier to tweak the ref naming rules
      in the future, for example to forbid shell metacharacters like '`'
      and '"', without putting people in a state that is hard to get out of.
      
      So allow "branch --list" to show these refs and allow "branch -d/-D"
      and "update-ref -d" to delete them.  Other commands (for example to
      rename refs) will continue to not handle these refs but can be changed
      in later patches.
      
      Details:
      
      In resolving functions, refuse to resolve refs that don't pass the
      git-check-ref-format(1) check unless the new RESOLVE_REF_ALLOW_BAD_NAME
      flag is passed.  Even with RESOLVE_REF_ALLOW_BAD_NAME, refuse to
      resolve refs that escape the refs/ directory and do not match the
      pattern [A-Z_]* (think "HEAD" and "MERGE_HEAD").
      
      In locking functions, refuse to act on badly named refs unless they
      are being deleted and either are in the refs/ directory or match [A-Z_]*.
      
      Just like other invalid refs, flag resolved, badly named refs with the
      REF_ISBROKEN flag, treat them as resolving to null_sha1, and skip them
      in all iteration functions except for for_each_rawref.
      
      Flag badly named refs (but not symrefs pointing to badly named refs)
      with a REF_BAD_NAME flag to make it easier for future callers to
      notice and handle them specially.  For example, in a later patch
      for-each-ref will use this flag to detect refs whose names can confuse
      callers parsing for-each-ref output.
      
      In the transaction API, refuse to create or update badly named refs,
      but allow deleting them (unless they try to escape refs/ and don't match
      [A-Z_]*).
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d0f810f0
    • R
      branch -d: simplify by using RESOLVE_REF_READING · 18f29fc6
      Ronnie Sahlberg 提交于
      When "git branch -d" reads the branch it is about to delete, it used
      to avoid passing the RESOLVE_REF_READING ('treat missing ref as
      error') flag because a symref pointing to a nonexistent ref would show
      up as missing instead of as something that could be deleted.  To check
      if a ref is actually missing, we then check
      
       - is it a symref?
       - if not, did it resolve to null_sha1?
      
      Now we pass RESOLVE_REF_NO_RECURSE and the correct information is
      returned for a symref even when it points to a missing ref.  Simplify
      by relying on RESOLVE_REF_READING.
      
      No functional change intended.
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      18f29fc6
    • J
      branch -d: avoid repeated symref resolution · 62a2d525
      Jonathan Nieder 提交于
      If a repository gets in a broken state with too much symref nesting,
      it cannot be repaired with "git branch -d":
      
       $ git symbolic-ref refs/heads/nonsense refs/heads/nonsense
       $ git branch -d nonsense
       error: branch 'nonsense' not found.
      
      Worse, "git update-ref --no-deref -d" doesn't work for such repairs
      either:
      
       $ git update-ref -d refs/heads/nonsense
       error: unable to resolve reference refs/heads/nonsense: Too many levels of symbolic links
      
      Fix both by teaching resolve_ref_unsafe a new RESOLVE_REF_NO_RECURSE
      flag and passing it when appropriate.
      
      Callers can still read the value of a symref (for example to print a
      message about it) with that flag set --- resolve_ref_unsafe will
      resolve one level of symrefs and stop there.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Reviewed-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      62a2d525
    • R
      refs.c: change resolve_ref_unsafe reading argument to be a flags field · 7695d118
      Ronnie Sahlberg 提交于
      resolve_ref_unsafe takes a boolean argument for reading (a nonexistent ref
      resolves successfully for writing but not for reading).  Change this to be
      a flags field instead, and pass the new constant RESOLVE_REF_READING when
      we want this behaviour.
      
      While at it, swap two of the arguments in the function to put output
      arguments at the end.  As a nice side effect, this ensures that we can
      catch callers that were unaware of the new API so they can be audited.
      
      Give the wrapper functions resolve_refdup and read_ref_full the same
      treatment for consistency.
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7695d118
    • R
      fetch.c: change s_update_ref to use a ref transaction · cd94f765
      Ronnie Sahlberg 提交于
      Change s_update_ref to use a ref transaction for the ref update.
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cd94f765
    • R
      refs.c: pass the ref log message to _create/delete/update instead of _commit · db7516ab
      Ronnie Sahlberg 提交于
      Change the ref transaction API so that we pass the reflog message to the
      create/delete/update functions instead of to ref_transaction_commit.
      This allows different reflog messages for each ref update in a multi-ref
      transaction.
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      db7516ab
  8. 15 10月, 2014 2 次提交
    • J
      color_parse: do not mention variable name in error message · f6c5a296
      Jeff King 提交于
      Originally the color-parsing function was used only for
      config variables. It made sense to pass the variable name so
      that the die() message could be something like:
      
        $ git -c color.branch.plain=bogus branch
        fatal: bad color value 'bogus' for variable 'color.branch.plain'
      
      These days we call it in other contexts, and the resulting
      error messages are a little confusing:
      
        $ git log --pretty='%C(bogus)'
        fatal: bad color value 'bogus' for variable '--pretty format'
      
        $ git config --get-color foo.bar bogus
        fatal: bad color value 'bogus' for variable 'command line'
      
      This patch teaches color_parse to complain only about the
      value, and then return an error code. Config callers can
      then propagate that up to the config parser, which mentions
      the variable name. Other callers can provide a custom
      message. After this patch these three cases now look like:
      
        $ git -c color.branch.plain=bogus branch
        error: invalid color value: bogus
        fatal: unable to parse 'color.branch.plain' from command-line config
      
        $ git log --pretty='%C(bogus)'
        error: invalid color value: bogus
        fatal: unable to parse --pretty format
      
        $ git config --get-color foo.bar bogus
        error: invalid color value: bogus
        fatal: unable to parse default color value
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f6c5a296
    • J
      pass config slots as pointers instead of offsets · 8852117a
      Jonathan Nieder 提交于
      Many config-parsing helpers, like parse_branch_color_slot,
      take the name of a config variable and an offset to the
      "slot" name (e.g., "color.branch.plain" is passed along with
      "13" to effectively pass "plain"). This is leftover from the
      time that these functions would die() on error, and would
      want the full variable name for error reporting.
      
      These days they do not use the full variable name at all.
      Passing a single pointer to the slot name is more natural,
      and lets us more easily adjust the callers to use skip_prefix
      to avoid manually writing offset numbers.
      
      This is effectively a continuation of 9e1a5ebe, which did the
      same for parse_diff_color_slot. This patch covers all of the
      remaining similar constructs.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8852117a
  9. 14 10月, 2014 4 次提交
  10. 11 10月, 2014 1 次提交
    • P
      doc: add 'everyday' to 'git help' · 673151a9
      Philip Oakley 提交于
      The "Everyday GIT With 20 Commands Or So" is not accessible via the
      Git help system.  Move everyday.txt to giteveryday.txt so that "git
      help everyday" works, and create a new placeholder file everyday.html
      to refer people who follow existing URLs to the updated location.
      
      giteveryday.txt now formats well with AsciiDoc as a man page and
      refreshed content to a more command modern style.
      
      Add 'everyday' to the help --guides list and update git(1) and 5
      other links to giteveryday.
      Signed-off-by: NPhilip Oakley <philipoakley@iee.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      673151a9
  11. 08 10月, 2014 2 次提交
  12. 02 10月, 2014 2 次提交