1. 01 11月, 2008 1 次提交
  2. 31 10月, 2008 1 次提交
  3. 27 10月, 2008 2 次提交
  4. 09 7月, 2008 2 次提交
    • J
      avoid null SHA1 in oldest reflog · d1a4489a
      Jeff King 提交于
      When the user specifies a ref by a reflog entry older than
      one we have (e.g., "HEAD@{20 years ago"}), we issue a
      warning and give them the "from" value of the oldest reflog
      entry. That is, we say "we don't know what happened before
      this entry, but before this we know we had some particular
      SHA1".
      
      However, the oldest reflog entry is often a creation event
      such as clone or branch creation. In this case, the entry
      claims that the ref went from "00000..." (the null sha1) to
      the new value, and the reflog lookup returns the null sha1.
      
      While this is technically correct (the entry tells us that
      the ref didn't exist at the specified time) it is not
      terribly useful to the end user. What they probably want
      instead is "the oldest useful sha1 that this ref ever had".
      This patch changes the behavior such that if the oldest ref
      would return the null sha1, it instead returns the first
      value the ref ever had.
      
      We never discovered this problem in the test scripts because
      we created "fake" reflogs that had only a specified segment
      of history. This patch updates the tests with a creation
      event at the beginning of history.
      Signed-off-by: NJeff King <peff@peff.net>
      Acked-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d1a4489a
    • J
      make deleting a missing ref more quiet · 0b294c0a
      Jeff King 提交于
      If git attempts to delete a ref, but the unlink of the ref
      file fails, we print a message to stderr. This is usually a
      good thing, but if the error is ENOENT, then it indicates
      that the ref has _already_ been deleted. And since that's
      our goal, it doesn't make sense to complain to the user.
      
      This harmonizes the error reporting behavior for the
      unpacked and packed cases; the packed case already printed
      nothing on ENOENT, but the unpacked printed unconditionally.
      
      Additionally, send-pack would, when deleting the tracking
      ref corresponding to a remote delete, print "Failed to
      delete" on any failure. This can be a misleading
      message, since we actually _did_ delete at the remote side,
      but we failed to delete locally. Rather than make the
      message more precise, let's just eliminate it entirely; the
      delete_ref routine already takes care of printing out a much
      more specific message about what went wrong.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0b294c0a
  5. 05 5月, 2008 1 次提交
  6. 30 4月, 2008 1 次提交
  7. 09 4月, 2008 1 次提交
  8. 25 2月, 2008 1 次提交
    • S
      Optimize peel_ref for the current ref of a for_each_ref callback · 0ae91be0
      Shawn O. Pearce 提交于
      Currently the only caller of peel_ref is show-ref, which is using
      this function to show the peeled tag information if it is available
      from an existing packed-refs file.  The call happens during the
      for_each_ref callback function, so we have the proper struct ref_list
      already on the call stack but it is not easily available to return
      the peeled information to the caller.
      
      We now save the current struct ref_list item before calling back
      into the callback function so that future calls to peel_ref from
      within the callback function can quickly access the current ref.
      Doing so will save us an lstat() per ref processed as we no longer
      have to check the filesystem to see if the ref exists as a loose
      file or is packed.  This current ref caching also saves a linear
      scan of the cached packed refs list.
      
      As a micro-optimization we test the address of the passed ref name
      against the current_ref->name before we go into the much more costly
      strcmp().  Nearly any caller of peel_ref will be passing us the same
      string do_for_each_ref passed them, which is current_ref->name.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0ae91be0
  9. 24 2月, 2008 1 次提交
  10. 23 2月, 2008 1 次提交
  11. 17 1月, 2008 3 次提交
    • B
      refs.c: rework ref_locks by abstracting from underlying struct lock_file · b531394d
      Brandon Casey 提交于
      Instead of calling close_lock_file() and commit_lock_file() directly,
      which take a struct lock_file argument, add two new functions:
      close_ref() and commit_ref(), which handle calling the previous
      lock_file functions and modifying the ref_lock structure.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b531394d
    • B
      Improve use of lockfile API · 4ed7cd3a
      Brandon Casey 提交于
      Remove remaining double close(2)'s.  i.e. close() before
      commit_locked_index() or commit_lock_file().
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4ed7cd3a
    • L
      Be more careful about updating refs · c3b0dec5
      Linus Torvalds 提交于
      This makes write_ref_sha1() more careful: it actually checks the SHA1 of
      the ref it is updating, and refuses to update a ref with an object that it
      cannot find.
      
      Perhaps more importantly, it also refuses to update a branch head with a
      non-commit object. I don't quite know *how* the stable series maintainers
      were able to corrupt their repository to have a HEAD that pointed to a tag
      rather than a commit object, but they did. Which results in a totally
      broken repository that cannot be cloned or committed on.
      
      So make it harder for people to shoot themselves in the foot like that.
      
      The test t1400-update-ref.sh is fixed at the same time, as it
      assumed that the commands involved in the particular test would
      not care about corrupted repositories whose refs point at
      nonexistant bogus objects.  That assumption does not hold true
      anymore.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c3b0dec5
  12. 03 1月, 2008 1 次提交
    • J
      Update callers of check_ref_format() · 257f3020
      Junio C Hamano 提交于
      This updates send-pack and fast-import to use symbolic constants
      for checking the return values from check_ref_format(), and also
      futureproof the logic in lock_any_ref_for_update() to explicitly
      name the case that is usually considered an error but is Ok for
      this particular use.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      257f3020
  13. 02 1月, 2008 1 次提交
    • J
      lock_any_ref_for_update(): reject wildcard return from check_ref_format · 5f7b202a
      Junio C Hamano 提交于
      Recent check_ref_format() returns -3 as well as -1 (general
      error) and -2 (less than two levels).  The caller was explicitly
      checking for -1, to allow "HEAD" but still needed to disallow
      bogus refs.
      
      This introduces symbolic constants for the return values from
      check_ref_format() to make them read better and more
      meaningful.  Normal ref creation codepath can still treat
      non-zero return values as errors.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5f7b202a
  14. 09 12月, 2007 1 次提交
    • J
      Re-fix "builtin-commit: fix --signoff" · 774751a8
      Junio C Hamano 提交于
      An earlier fix to the said commit was incomplete; it mixed up the
      meaning of the flag parameter passed to the internal fmt_ident()
      function, so this corrects it.
      
      git_author_info() and git_committer_info() can be told to issue a
      warning when no usable user information is found, and optionally can be
      told to error out.  Operations that actually use the information to
      record a new commit or a tag will still error out, but the caller to
      leave reflog record will just silently use bogus user information.
      
      Not warning on misconfigured user information while writing a reflog
      entry is somewhat debatable, but it is probably nicer to the users to
      silently let it pass, because the only information you are losing is who
      checked out the branch.
      
       * git_author_info() and git_committer_info() used to take 1 (positive
         int) to error out with a warning on misconfiguration; this is now
         signalled with a symbolic constant IDENT_ERROR_ON_NO_NAME.
      
       * These functions used to take -1 (negative int) to warn but continue;
         this is now signalled with a symbolic constant IDENT_WARN_ON_NO_NAME.
      
       * fmt_ident() function implements the above error reporting behaviour
         common to git_author_info() and git_committer_info().  A symbolic
         constant IDENT_NO_DATE can be or'ed in to the flag parameter to make
         it return only the "Name <email@address.xz>".
      
       * fmt_name() is a thin wrapper around fmt_ident() that always passes
         IDENT_ERROR_ON_NO_NAME and IDENT_NO_DATE.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      774751a8
  15. 19 11月, 2007 2 次提交
    • S
      refactor fetch's ref matching to use refname_match() · 605b4978
      Steffen Prohaska 提交于
      The old rules used by fetch were coded as a series of ifs.  The old
      rules are:
      1) match full refname if it starts with "refs/" or matches "HEAD"
      2) verify that full refname starts with "refs/"
      3) match abbreviated name in "refs/" if it starts with "heads/",
          "tags/", or "remotes/".
      4) match abbreviated name in "refs/heads/"
      
      This is replaced by the new rules
      a) match full refname
      b) match abbreviated name prefixed with "refs/"
      c) match abbreviated name prefixed with "refs/heads/"
      
      The details of the new rules are different from the old rules.  We no
      longer verify that the full refname starts with "refs/".  The new rule
      (a) matches any full string.  The old rules (1) and (2) were stricter.
      Now, the caller is responsible for using sensible full refnames.  This
      should be the case for the current code.  The new rule (b) is less
      strict than old rule (3).  The new rule accepts abbreviated names that
      start with a non-standard prefix below "refs/".
      
      Despite this modifications the new rules should handle all cases as
      expected.  Two tests are added to verify that fetch does not resolve
      short tags or HEAD in remotes.
      
      We may even think about loosening the rules a bit more and unify them
      with the rev-parse rules.  This would be done by replacing
      ref_ref_fetch_rules with ref_ref_parse_rules.  Note, the two new test
      would break.
      Signed-off-by: NSteffen Prohaska <prohaska@zib.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      605b4978
    • S
      add refname_match() · 79803322
      Steffen Prohaska 提交于
      We use at least two rulesets for matching abbreviated refnames with
      full refnames (starting with 'refs/').  git-rev-parse and git-fetch
      use slightly different rules.
      
      This commit introduces a new function refname_match
      (const char *abbrev_name, const char *full_name, const char **rules).
      
      abbrev_name is expanded using the rules and matched against full_name.
      If a match is found the function returns true.  rules is a NULL-terminate
      list of format patterns with "%.*s", for example:
      
          const char *ref_rev_parse_rules[] = {
                     "%.*s",
                     "refs/%.*s",
                     "refs/tags/%.*s",
                     "refs/heads/%.*s",
                     "refs/remotes/%.*s",
                     "refs/remotes/%.*s/HEAD",
                     NULL
          };
      
      Asterisks are included in the format strings because this is the form
      required in sha1_name.c.  Sharing the list with the functions there is
      a good idea to avoid duplicating the rules.  Hopefully this
      facilitates unified matching rules in the future.
      
      This commit makes the rules used by rev-parse for resolving refs to
      sha1s available for string comparison.  Before this change, the rules
      were buried in get_sha1*() and dwim_ref().
      
      A follow-up commit will refactor the rules used by fetch.
      
      refname_match() will be used for matching refspecs in git-send-pack.
      
      Thanks to Daniel Barkalow <barkalow@iabervon.org> for pointing
      out that ref_matches_abbrev in remote.c solves a similar problem
      and care should be taken to avoid confusion.
      Signed-off-by: NSteffen Prohaska <prohaska@zib.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      79803322
  16. 18 11月, 2007 1 次提交
  17. 16 11月, 2007 1 次提交
  18. 30 9月, 2007 1 次提交
  19. 19 9月, 2007 1 次提交
  20. 06 9月, 2007 1 次提交
  21. 11 8月, 2007 1 次提交
  22. 30 7月, 2007 1 次提交
  23. 14 7月, 2007 1 次提交
  24. 27 6月, 2007 1 次提交
  25. 13 6月, 2007 1 次提交
  26. 26 5月, 2007 1 次提交
  27. 11 5月, 2007 1 次提交
  28. 19 4月, 2007 1 次提交
  29. 18 4月, 2007 1 次提交
  30. 11 4月, 2007 1 次提交
  31. 07 4月, 2007 2 次提交
  32. 22 3月, 2007 1 次提交
  33. 10 3月, 2007 1 次提交
  34. 08 3月, 2007 1 次提交
    • S
      Cast 64 bit off_t to 32 bit size_t · dc49cd76
      Shawn O. Pearce 提交于
      Some systems have sizeof(off_t) == 8 while sizeof(size_t) == 4.
      This implies that we are able to access and work on files whose
      maximum length is around 2^63-1 bytes, but we can only malloc or
      mmap somewhat less than 2^32-1 bytes of memory.
      
      On such a system an implicit conversion of off_t to size_t can cause
      the size_t to wrap, resulting in unexpected and exciting behavior.
      Right now we are working around all gcc warnings generated by the
      -Wshorten-64-to-32 option by passing the off_t through xsize_t().
      
      In the future we should make xsize_t on such problematic platforms
      detect the wrapping and die if such a file is accessed.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      dc49cd76