1. 01 10月, 2006 4 次提交
  2. 27 9月, 2006 2 次提交
  3. 23 9月, 2006 2 次提交
  4. 21 9月, 2006 2 次提交
    • J
      Tell between packed, unpacked and symbolic refs. · 8da19775
      Junio C Hamano 提交于
      This adds a "int *flag" parameter to resolve_ref() and makes
      for_each_ref() family to call callback function with an extra
      "int flag" parameter.  They are used to give two bits of
      information (REF_ISSYMREF and REF_ISPACKED) about the ref.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      8da19775
    • J
      Add callback data to for_each_ref() family. · cb5d709f
      Junio C Hamano 提交于
      This is a long overdue fix to the API for for_each_ref() family
      of functions.  It allows the callers to specify a callback data
      pointer, so that the caller does not have to use static
      variables to communicate with the callback funciton.
      
      The updated for_each_ref() family takes a function of type
      
      	int (*fn)(const char *, const unsigned char *, void *)
      
      and a void pointer as parameters, and calls the function with
      the name of the ref and its SHA-1 with the caller-supplied void
      pointer as parameters.
      
      The commit updates two callers, builtin-name-rev.c and
      builtin-pack-refs.c as an example.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      cb5d709f
  5. 20 9月, 2006 1 次提交
    • P
      Fix broken sha1 locking · 53cce84c
      Petr Baudis 提交于
      Current git#next is totally broken wrt. cloning over HTTP, generating refs
      at random directories. Of course it's caused by the static get_pathname()
      buffer. lock_ref_sha1() stores return value of mkpath()'s get_pathname()
      call, then calls lock_ref_sha1_basic() which calls git_path(ref) which
      calls get_pathname() at that point returning pointer to the same buffer.
      So now you are sprintf()ing a format string into itself, wow! The resulting
      pathnames are really cute. (If you've been paying attention, yes, the
      mere fact that a format string _could_ write over itself is very wrong
      and probably exploitable here. See the other mail I've just sent.)
      
      I've never liked how we use return values of those functions so liberally,
      the "allow some random number of get_pathname() return values to work
      concurrently" is absolutely horrible pit and we've already fallen in this
      before IIRC. I consider it an awful coding practice, you add a call
      somewhere and at some other point some distant caller of that breaks since
      it reuses the same return values. Not to mention this takes quite some time
      to debug.
      
      My gut feeling tells me that there might be more of this.  I don't have
      time to review the rest of the users of the refs.c functions though.
      Signed-off-by: NPetr Baudis <pasky@suse.cz>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      53cce84c
  6. 18 9月, 2006 4 次提交
    • L
      Enable the packed refs file format · 434cd0cd
      Linus Torvalds 提交于
      This actually "turns on" the packed ref file format, now that the
      infrastructure to do so sanely exists (ie notably the change to make the
      reference reading logic take refnames rather than pathnames to the loose
      objects that no longer necessarily even exist).
      
      In particular, when the ref lookup hits a refname that has no loose file
      associated with it, it falls back on the packed-ref information. Also, the
      ref-locking code, while still using a loose file for the locking itself
      (and _creating_ a loose file for the new ref) no longer requires that the
      old ref be in such an unpacked state.
      
      Finally, this does a minimal hack to git-checkout.sh to rather than check
      the ref-file directly, do a "git-rev-parse" on the "heads/$refname".
      That's not really wonderful - we should rather really have a special
      routine to verify the names as proper branch head names, but it is a
      workable solution for now.
      
      With this, I can literally do something like
      
      	git pack-refs
      	find .git/refs -type f -print0 | xargs -0 rm -f --
      
      and the end result is a largely working repository (ie I've done two
      commits - which creates _one_ unpacked ref file - done things like run
      "gitk" and "git log" etc, and it all looks ok).
      
      There are probably things missing, but I'm hoping that the missing things
      are now of the "small and obvious" kind, and that somebody else might want
      to start looking at this too. Hint hint ;)
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      434cd0cd
    • L
      Make ref resolution saner · ed378ec7
      Linus Torvalds 提交于
      The old code used to totally mix up the notion of a ref-name and the path
      that that ref was associated with.  That was not only horribly ugly (a
      number of users got the path, and then wanted to try to turn it back into
      a ref-name again), but it fundamnetally doesn't work at all once we do any
      setup where a ref doesn't have a 1:1 relationship with a particular
      pathname.
      
      This fixes things up so that we use the ref-name throughout, and only
      turn it into a pathname once we actually look it up in the filesystem.
      That makes a lot of things much clearer and more straightforward.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      ed378ec7
    • L
      Add support for negative refs · b37a562a
      Linus Torvalds 提交于
      You can remove a ref that is packed two different ways: either simply
      repack all the refs without that one, or create a loose ref that has the
      magic all-zero SHA1.
      
      This also adds back the test that a ref actually has the object it
      points to.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      b37a562a
    • L
      Start handling references internally as a sorted in-memory list · e1e22e37
      Linus Torvalds 提交于
      This also adds some very rudimentary support for the notion of packed
      refs.  HOWEVER! At this point it isn't used to actually look up a ref
      yet, only for listing them (ie "for_each_ref()" and friends see the
      packed refs, but none of the other single-ref lookup routines).
      
      Note how we keep two separate lists: one for the loose refs, and one for
      the packed refs we read. That's so that we can easily keep the two apart,
      and read only one set or the other (and still always make sure that the
      loose refs take precedence).
      
      [ From this, it's not actually obvious why we'd keep the two separate
        lists, but it's important to have the packed refs on their own list
        later on, when I add support for looking up a single loose one.
      
        For that case, we will want to read _just_ the packed refs in case the
        single-ref lookup fails, yet we may end up needing the other list at
        some point in the future, so keeping them separated is important ]
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      e1e22e37
  7. 02 9月, 2006 1 次提交
    • S
      Replace uses of strdup with xstrdup. · 9befac47
      Shawn Pearce 提交于
      Like xmalloc and xrealloc xstrdup dies with a useful message if
      the native strdup() implementation returns NULL rather than a
      valid pointer.
      
      I just tried to use xstrdup in new code and found it to be missing.
      However I expected it to be present as xmalloc and xrealloc are
      already commonly used throughout the code.
      
      [jc: removed the part that deals with last_XXX, which I am
       finding more and more dubious these days.]
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      9befac47
  8. 28 8月, 2006 1 次提交
  9. 24 8月, 2006 1 次提交
    • S
      Convert memcpy(a,b,20) to hashcpy(a,b). · e702496e
      Shawn Pearce 提交于
      This abstracts away the size of the hash values when copying them
      from memory location to memory location, much as the introduction
      of hashcmp abstracted away hash value comparsion.
      
      A few call sites were using char* rather than unsigned char* so
      I added the cast rather than open hashcpy to be void*.  This is a
      reasonable tradeoff as most call sites already use unsigned char*
      and the existing hashcmp is also declared to be unsigned char*.
      
      [jc: Splitted the patch to "master" part, to be followed by a
       patch for merge-recursive.c which is not in "master" yet.
      
       Fixed the cast in the latter hunk to combine-diff.c which was
       wrong in the original.
      
       Also converted ones left-over in combine-diff.c, diff-lib.c and
       upload-pack.c ]
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      e702496e
  10. 18 8月, 2006 1 次提交
  11. 13 8月, 2006 1 次提交
    • J
      Better error message when we are unable to lock the index file · 40aaae88
      Junio C Hamano 提交于
      Most of the callers except the one in refs.c use the function to
      update the index file.  Among the index writers, everybody
      except write-tree dies if they cannot open it for writing.
      
      This gives the function an extra argument, to tell it to die
      when it cannot create a new file as the lockfile.
      
      The only caller that does not have to die is write-tree, because
      updating the index for the cache-tree part is optional and not
      being able to do so does not affect the correctness.  I think we
      do not have to be so careful and make the failure into die() the
      same way as other callers, but that would be a different patch.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      40aaae88
  12. 12 8月, 2006 1 次提交
    • R
      drop length argument of has_extension · 5bb1cda5
      Rene Scharfe 提交于
      As Fredrik points out the current interface of has_extension() is
      potentially confusing.  Its parameters include both a nul-terminated
      string and a length-limited string.
      
      This patch drops the length argument, requiring two nul-terminated
      strings; all callsites are updated.  I checked that all of them indeed
      provide nul-terminated strings.  Filenames need to be nul-terminated
      anyway if they are to be passed to open() etc.  The performance penalty
      of the additional strlen() is negligible compared to the system calls
      which inevitably surround has_extension() calls.
      
      Additionally, change has_extension() to use size_t inside instead of
      int, as that is the exact type strlen() returns and memcmp() expects.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      5bb1cda5
  13. 11 8月, 2006 1 次提交
  14. 29 7月, 2006 1 次提交
    • S
      Display an error from update-ref if target ref name is invalid. · 818f477c
      Shawn Pearce 提交于
      Alex Riesen (raa.lkml@gmail.com) recently observed that git branch
      would fail with no error message due to unexpected situations with
      regards to refs.  For example, if .git/refs/heads/gu is a file but
      "git branch -b refs/heads/gu/fixa HEAD" was invoked by the user
      it would fail silently due to refs/heads/gu being a file and not
      a directory.
      
      This change adds a test for trying to create a ref within a directory
      that is actually currently a file, and adds error printing within
      the ref locking routine should the resolve operation fail.
      
      The error printing code probably belongs at this level of the library
      as other failures within the ref locking, writing and logging code
      are also currently at this level of the code.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      818f477c
  15. 11 7月, 2006 1 次提交
  16. 09 7月, 2006 1 次提交
  17. 10 6月, 2006 1 次提交
    • J
      shared repository - add a few missing calls to adjust_shared_perm(). · 138086a7
      Junio C Hamano 提交于
      There were a few calls to adjust_shared_perm() that were
      missing:
      
       - init-db creates refs, refs/heads, and refs/tags before
         reading from templates that could specify sharedrepository in
         the config file;
      
       - updating config file created it under user's umask without
         adjusting;
      
       - updating refs created it under user's umask without
         adjusting;
      
       - switching branches created .git/HEAD under user's umask
         without adjusting.
      
      This moves adjust_shared_perm() from sha1_file.c to path.c,
      since a few SIMPLE_PROGRAM need to call repository configuration
      functions which in turn need to call adjust_shared_perm().
      sha1_file.c needs to link with SHA1 computation library which
      is usually not linked to SIMPLE_PROGRAM.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      138086a7
  18. 07 6月, 2006 2 次提交
    • J
      ref-log: style fixes. · e5f38ec3
      Junio C Hamano 提交于
      A few style fixes to get the code in line with the rest.
      
       - asterisk to make a type a pointer to something goes in front
         of the variable, not at the end of the base type.
         E.g. a pointer to an integer is "int *ip", not "int* ip".
      
       - open parenthesis for function parameter list, unlike
         syntactic constructs, comes immediately after the function
         name.  E.g. "if (foo) bar();" not "if(foo) bar ();".
      
       - "else" does not come on the same line as the closing brace of
         corresponding "if".
      
      The style is mostly a matter of personal taste, and people may
      disagree, but consistency is important.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      e5f38ec3
    • J
      refs.c: convert it to use lockfile interface. · c33d5174
      Junio C Hamano 提交于
      This updates the ref locking code to use creat-rename locking
      code we use for the index file, so that it can borrow the code
      to clean things up upon signals and program termination.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      c33d5174
  19. 20 5月, 2006 4 次提交
    • S
      Correct force_write bug in refs.c · 8fe92775
      Shawn Pearce 提交于
      My earlier attempt at forcing a write for non-existant refs worked;
      it forced a write for pretty much all refs.  This corrects the
      condition to only force a write for refs which don't exist yet.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      8fe92775
    • S
      Log ref updates made by fetch. · d0740d92
      Shawn Pearce 提交于
      If a ref is changed by http-fetch, local-fetch or ssh-fetch
      record the change and the remote URL/name in the log for the ref.
      This requires loading the config file to check logAllRefUpdates.
      
      Also fixed a bug in the ref lock generation; the log file name was
      not being produced right due to a bad prefix length.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      d0740d92
    • S
      Force writing ref if it doesn't exist. · 732232a1
      Shawn Pearce 提交于
      Normally we try to skip writing a ref if its value hasn't changed
      but in the special case that the ref doesn't exist but the new
      value is going to be 0{40} then force writing the ref anyway.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      732232a1
    • S
      General ref log reading improvements. · e5229042
      Shawn Pearce 提交于
      Corrected the log starting time displayed in the error message
      (as it was always showing the epoch due to a bad input to strtoul).
      
      Improved the log parser so we only scan backwards towards the
      '\n' from the end of the prior log; during this scan the last '>'
      is remembered to improve performance (rather than scanning forward
      to it).
      
      If the log record matched is the last log record in the file only
      use its new sha1 value if the date matches exactly; otherwise we
      leave the passed in sha1 alone as it already contains the current
      value of the ref.  This way lookups of dates later than the log
      end to stick with the current ref value in case the ref was updated
      without logging.
      
      If it looks like someone changed the ref without logging it and we
      are going to return the sha1 which should have been valid during
      the missing period then warn the user that there might be log data
      missing and thus their query result may not be accurate.  The check
      isn't perfect as its just based on comparing the old and new sha1
      values between the two log records but its better than not checking
      at all.
      
      Implemented test cases based on git-rev-parse for most of the
      boundary conditions.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      e5229042
  20. 18 5月, 2006 5 次提交
  21. 15 5月, 2006 1 次提交
  22. 06 5月, 2006 1 次提交
  23. 03 5月, 2006 1 次提交