1. 18 2月, 2015 1 次提交
  2. 13 2月, 2015 2 次提交
  3. 14 1月, 2015 1 次提交
  4. 30 12月, 2014 1 次提交
  5. 23 12月, 2014 5 次提交
  6. 13 12月, 2014 1 次提交
  7. 11 12月, 2014 3 次提交
    • J
      read_packed_refs: use skip_prefix instead of static array · ea417833
      Jeff King 提交于
      We want to recognize the packed-refs header and skip to the
      "traits" part of the line. We currently do it by feeding
      sizeof() a static const array to strncmp. However, it's a
      bit simpler to just skip_prefix, which expresses the
      intention more directly, and without remembering to account
      for the NUL-terminator in each sizeof() call.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ea417833
    • J
      read_packed_refs: pass strbuf to parse_ref_line · 6a49870a
      Jeff King 提交于
      Now that we have a strbuf in read_packed_refs, we can pass
      it straight to the line parser, which saves us an extra
      strlen.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6a49870a
    • J
      read_packed_refs: use a strbuf for reading lines · 10c497aa
      Jeff King 提交于
      Current code uses a fixed PATH_MAX-sized buffer for reading
      packed-refs lines. This is a reasonable guess, in the sense
      that git generally cannot work with refs larger than
      PATH_MAX.  However, there are a few cases where it is not
      great:
      
        1. Some systems may have a low value of PATH_MAX, but can
           actually handle larger paths in practice. Fixing this
           code path probably isn't enough to make them work
           completely with long refs, but it is a step in the
           right direction.
      
        2. We use fgets, which will happily give us half a line on
           the first read, and then the rest of the line on the
           second. This is probably OK in practice, because our
           refline parser is careful enough to look for the
           trailing newline on the first line. The second line may
           look like a peeled line to us, but since "^" is illegal
           in refnames, it is not likely to come up.
      
           Still, it does not hurt to be more careful.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      10c497aa
  8. 06 12月, 2014 2 次提交
    • J
      for_each_reflog_ent_reverse: turn leftover check into assertion · 69216bf7
      Jeff King 提交于
      Our loop should always process all lines, even if we hit the
      beginning of the file. We have a conditional after the loop
      ends to double-check that there is nothing left and to
      process it. But this should never happen, and is a sign of a
      logic bug in the loop. Let's turn it into a BUG assertion.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      69216bf7
    • J
      for_each_reflog_ent_reverse: fix newlines on block boundaries · e5e73ff2
      Jeff King 提交于
      When we read a reflog file in reverse, we read whole chunks
      of BUFSIZ bytes, then loop over the buffer, parsing any
      lines we find. We find the beginning of each line by looking
      for the newline from the previous line. If we don't find
      one, we know that we are either at the beginning of
      the file, or that we have to read another block.
      
      In the latter case, we stuff away what we have into a
      strbuf, read another block, and continue our parse. But we
      missed one case here. If we did find a newline, and it is at
      the beginning of the block, we must also stuff that newline
      into the strbuf, as it belongs to the block we are about to
      read.
      
      The minimal fix here would be to add this special case to
      the conditional that checks whether we found a newline.
      But we can make the flow a little clearer by rearranging a
      bit: we first handle lines that we are going to show, and
      then at the end of each loop, stuff away any leftovers if
      necessary. That lets us fold this special-case in with the
      more common "we ended in the middle of a line" case.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e5e73ff2
  9. 05 12月, 2014 2 次提交
  10. 26 11月, 2014 1 次提交
  11. 21 11月, 2014 1 次提交
    • R
      lock_ref_sha1_basic: do not die on locking errors · 06839515
      Ronnie Sahlberg 提交于
      lock_ref_sha1_basic is inconsistent about when it calls
      die() and when it returns NULL to signal an error. This is
      annoying to any callers that want to recover from a locking
      error.
      
      This seems to be mostly historical accident. It was added in
      4bd18c43 (Improve abstraction of ref lock/write.,
      2006-05-17), which returned an error in all cases except
      calling safe_create_leading_directories, in which case it
      died.  Later, 40aaae88 (Better error message when we are
      unable to lock the index file, 2006-08-12) asked
      hold_lock_file_for_update to die for us, leaving the
      resolve_ref code-path the only one which returned NULL.
      
      We tried to correct that in 5cc3cef9 (lock_ref_sha1(): do not
      sometimes error() and sometimes die()., 2006-09-30),
      by converting all of the die() calls into returns. But we
      missed the "die" flag passed to the lock code, leaving us
      inconsistent. This state persisted until e5c223e9
      (lock_ref_sha1_basic(): if locking fails with ENOENT, retry,
      2014-01-18). Because of its retry scheme, it does not ask
      the lock code to die, but instead manually dies with
      unable_to_lock_die().
      
      We can make this consistent with the other return paths by
      converting this to use unable_to_lock_message(), and
      returning NULL. This is safe to do because all callers
      already needed to check the return value of the function,
      since it could fail (and return NULL) for other reasons.
      
      [jk: Added excessive history explanation]
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJeff King <peff@peff.net>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      06839515
  12. 05 11月, 2014 1 次提交
    • J
      ignore stale directories when checking reflog existence · 9233887c
      Jeff King 提交于
      When we update a ref, we have two rules for whether or not
      we actually update the reflog:
      
        1. If the reflog already exists, we will always append to
           it.
      
        2. If log_all_ref_updates is set, we will create a new
           reflog file if necessary.
      
      We do the existence check by trying to open the reflog file,
      either with or without O_CREAT (depending on log_all_ref_updates).
      If it fails, then we check errno to see what happened.
      
      If we were not using O_CREAT and we got ENOENT, the file
      doesn't exist, and we return success (there isn't a reflog
      already, and we were not told to make a new one).
      
      If we get EISDIR, then there is likely a stale directory
      that needs to be removed (e.g., there used to be "foo/bar",
      it was deleted, and the directory "foo" was left. Now we
      want to create the ref "foo"). If O_CREAT is set, then we
      catch this case, try to remove the directory, and retry our
      open. So far so good.
      
      But if we get EISDIR and O_CREAT is not set, then we treat
      this as any other error, which is not right. Like ENOENT,
      EISDIR is an indication that we do not have a reflog, and we
      should silently return success (we were not told to create
      it). Instead, the current code reports this as an error, and
      we fail to update the ref at all.
      
      Note that this is relatively unlikely to happen, as you
      would have to have had reflogs turned on, and then later
      turned them off (it could also happen due to a bug in fetch,
      but that was fixed in the previous commit). However, it's
      quite easy to fix: we just need to treat EISDIR like ENOENT
      for the non-O_CREAT case, and silently return (note that
      this early return means we can also simplify the O_CREAT
      case).
      
      Our new tests cover both cases (O_CREAT and non-O_CREAT).
      The first one already worked, of course.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9233887c
  13. 16 10月, 2014 16 次提交
  14. 02 10月, 2014 3 次提交