1. 03 1月, 2007 1 次提交
    • J
      Fix infinite loop when deleting multiple packed refs. · 1084b845
      Junio C Hamano 提交于
      It was stupid to link the same element twice to lock_file_list
      and end up in a loop, so we certainly need a fix.
      
      But it is not like we are taking a lock on multiple files in
      this case.  It is just that we leave the linked element on the
      list even after commit_lock_file() successfully removes the
      cruft.
      
      We cannot remove the list element in commit_lock_file(); if we
      are interrupted in the middle of list manipulation, the call to
      remove_lock_file_on_signal() will happen with a broken list
      structure pointed by lock_file_list, which would cause the cruft
      to remain, so not removing the list element is the right thing
      to do.  Instead we should be reusing the element already on the
      list.
      
      There is already a code for that in lock_file() function in
      lockfile.c.  The code checks lk->next and the element is linked
      only when it is not already on the list -- which is incorrect
      for the last element on the list (which has NULL in its next
      field), but if you read the check as "is this element already on
      the list?" it actually makes sense.  We do not want to link it
      on the list again, nor we would want to set up signal/atexit
      over and over.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      1084b845
  2. 30 12月, 2006 1 次提交
    • S
      Replace mmap with xmmap, better handling MAP_FAILED. · c4712e45
      Shawn O. Pearce 提交于
      In some cases we did not even bother to check the return value of
      mmap() and just assume it worked.  This is bad, because if we are
      out of virtual address space the kernel returned MAP_FAILED and we
      would attempt to dereference that address, segfaulting without any
      real error output to the user.
      
      We are replacing all calls to mmap() with xmmap() and moving all
      MAP_FAILED checking into that single location.  If a mmap call
      fails we try to release enough least-recently-used pack windows
      to possibly succeed, then retry the mmap() attempt.  If we cannot
      mmap even after releasing pack memory then we die() as none of our
      callers have any reasonable recovery strategy for a failed mmap.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      c4712e45
  3. 29 12月, 2006 1 次提交
  4. 21 12月, 2006 3 次提交
  5. 17 12月, 2006 1 次提交
  6. 14 12月, 2006 1 次提交
    • J
      send-pack: tighten checks for remote names · 37adac76
      Junio C Hamano 提交于
      "git push $URL HEAD~6" created a bogus ref HEAD~6 immediately
      under $GIT_DIR of the remote repository.  While we should keep
      refspecs that have arbitrary extended SHA-1 expression on the
      source side working (e.g. "HEAD~6:refs/tags/yesterday"), we
      should not create bogus ref on the other end.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      37adac76
  7. 06 12月, 2006 3 次提交
  8. 22 11月, 2006 1 次提交
    • J
      Store peeled refs in packed-refs (take 2). · f4204ab9
      Junio C Hamano 提交于
      This fixes the previous implementation which failed to optimize
      repositories with tons of lightweight tags.  The updated
      packed-refs format begins with "# packed-refs with:" line that
      lists the kind of extended data the file records.  Currently,
      there is only one such extension defined, "peeled".  This stores
      the "peeled tag" on a line that immediately follows a line for a
      tag object itself in the format "^<sha-1>".
      
      The header line itself and any extended data are ignored by
      older implementation, so packed-refs file generated with this
      version can still be used by older git.  packed-refs made by
      older git can of course be used with this version.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      f4204ab9
  9. 20 11月, 2006 2 次提交
  10. 19 10月, 2006 1 次提交
  11. 10 10月, 2006 1 次提交
  12. 08 10月, 2006 1 次提交
  13. 06 10月, 2006 1 次提交
  14. 03 10月, 2006 2 次提交
  15. 02 10月, 2006 1 次提交
  16. 01 10月, 2006 6 次提交
  17. 27 9月, 2006 2 次提交
  18. 23 9月, 2006 2 次提交
  19. 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
  20. 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
  21. 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
  22. 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
  23. 28 8月, 2006 1 次提交