1. 25 7月, 2009 1 次提交
    • J
      git repack: keep commits hidden by a graft · 7f3140cd
      Johannes Schindelin 提交于
      When you have grafts that pretend that a given commit has different
      parents than the ones recorded in the commit object, it is dangerous
      to let 'git repack' remove those hidden parents, as you can easily
      remove the graft and end up with a broken repository.
      
      So let's play it safe and keep those parent objects and everything
      that is reachable by them, in addition to the grafted parents.
      
      As this behavior can only be triggered by git pack-objects, and as that
      command handles duplicate parents gracefully, we do not bother to cull
      duplicated parents that may result by using both true and grafted
      parents.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7f3140cd
  2. 02 5月, 2009 1 次提交
  3. 30 4月, 2009 1 次提交
  4. 26 4月, 2009 1 次提交
  5. 28 3月, 2009 1 次提交
    • J
      set_shared_perm(): sometimes we know what the final mode bits should look like · 17e61b82
      Junio C Hamano 提交于
      adjust_shared_perm() first obtains the mode bits from lstat(2), expecting
      to find what the result of applying user's umask is, and then tweaks it
      as necessary.  When the file to be adjusted is created with mkstemp(3),
      however, the mode thusly obtained does not have anything to do with user's
      umask, and we would need to start from 0444 in such a case and there is no
      point running lstat(2) for such a path.
      
      This introduces a new API set_shared_perm() to bypass the lstat(2) and
      instead force setting the mode bits to the desired value directly.
      adjust_shared_perm() becomes a thin wrapper to the function.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      17e61b82
  6. 23 3月, 2009 1 次提交
    • J
      Rename interpret/substitute nth_last_branch functions · 431b1969
      Junio C Hamano 提交于
      These allow you to say "git checkout @{-2}" to switch to the branch two
      "branch switching" ago by pretending as if you typed the name of that
      branch.  As it is likely that we will be introducing more short-hands to
      write the name of a branch without writing it explicitly, rename the
      functions from "nth_last_branch" to more generic "branch_name", to prepare
      for different semantics.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      431b1969
  7. 21 3月, 2009 1 次提交
  8. 18 3月, 2009 1 次提交
    • F
      New config push.default to decide default behavior for push · 52153747
      Finn Arne Gangstad 提交于
      When "git push" is not told what refspecs to push, it pushes all matching
      branches to the current remote.  For some workflows this default is not
      useful, and surprises new users.  Some have even found that this default
      behaviour is too easy to trigger by accident with unwanted consequences.
      
      Introduce a new configuration variable "push.default" that decides what
      action git push should take if no refspecs are given or implied by the
      command line arguments or the current remote configuration.
      
      Possible values are:
      
        'nothing'  : Push nothing;
        'matching' : Current default behaviour, push all branches that already
                     exist in the current remote;
        'tracking' : Push the current branch to whatever it is tracking;
        'current'  : Push the current branch to a branch of the same name,
                     i.e. HEAD.
      Signed-off-by: NFinn Arne Gangstad <finnag@pvv.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      52153747
  9. 28 2月, 2009 4 次提交
    • J
      is_kept_pack(): final clean-up · 69e020ae
      Junio C Hamano 提交于
      Now is_kept_pack() is just a member lookup into a structure, we can write
      it as such.
      
      Also rewrite the sole caller of has_sha1_kept_pack() to switch on the
      criteria the callee uses (namely, revs->kept_pack_only) between calling
      has_sha1_kept_pack() and has_sha1_pack(), so that these two callees do not
      have to take a pointer to struct rev_info as an argument.
      
      This removes the header file dependency issue temporarily introduced by
      the earlier commit, so we revert changes associated to that as well.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      69e020ae
    • J
      Consolidate ignore_packed logic more · 386cb772
      Junio C Hamano 提交于
      This refactors three loops that check if a given packfile is on the
      ignore_packed list into a function is_kept_pack().  The function returns
      false for a pack on the list, and true for a pack not on the list, because
      this list is solely used by "git repack" to pass list of packfiles that do
      not have corresponding .keep files, i.e. a packfile not on the list is
      "kept".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      386cb772
    • J
      has_sha1_kept_pack(): take "struct rev_info" · b8431b03
      Junio C Hamano 提交于
      Its "ignore_packed" parameter always comes from struct rev_info.  This
      patch makes the function take a pointer to the surrounding structure, so
      that the refactoring in the next patch becomes easier to review.
      
      There is an unfortunate header file dependency and the easiest workaround
      is to temporarily move the function declaration from cache.h to
      revision.h; this will be moved back to cache.h once the function loses
      this "ignore_packed" parameter altogether in the later part of the
      series.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b8431b03
    • J
      has_sha1_pack(): refactor "pretend these packs do not exist" interface · cd673c1f
      Junio C Hamano 提交于
      Most of the callers of this function except only one pass NULL to its last
      parameter, ignore_packed.
      
      Introduce has_sha1_kept_pack() function that has the function signature
      and the semantics of this function, and convert the sole caller that does
      not pass NULL to call this new function.
      
      All other callers and has_sha1_pack() lose the ignore_packed parameter.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cd673c1f
  10. 26 2月, 2009 1 次提交
    • J
      refactor find_ref_by_name() to accept const list · 5483f799
      Jeff King 提交于
      Since it doesn't actually touch its argument, this makes
      sense.
      
      However, we still want to return a non-const version (which
      requires a cast) so that this:
      
        struct ref *a, *b;
        a = find_ref_by_name(b);
      
      works. Unfortunately, you can also silently strip the const
      from a variable:
      
        struct ref *a;
        const struct ref *b;
        a = find_ref_by_name(b);
      
      This is a classic C const problem because there is no way to
      say "return the type with the same constness that was passed
      to us"; we provide the same semantics as standard library
      functions like strchr.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5483f799
  11. 24 2月, 2009 1 次提交
    • K
      write_index(): update index_state->timestamp after flushing to disk · e1afca4f
      Kjetil Barvik 提交于
      Since this timestamp is used to check for racy-clean files, it is
      important to keep it uptodate.
      
      For the 'git checkout' command without the '-q' option, this make a
      huge difference.  Before, each and every file which was updated, was
      racy-clean after the call to unpack_trees() and write_index() but
      before the GIT process ended.
      
      And because of the call to show_local_changes() in builtin-checkout.c,
      we ended up reading those files back into memory, doing a SHA1 to
      check if the files was really different from the index.  And, of
      course, no file was different.
      
      With this fix, 'git checkout' without the '-q' option should now be
      almost as fast as with the '-q' option, but not quite, as we still do
      some few lstat(2) calls more without the '-q' option.
      
      Below is some average numbers for 10 checkout's to v2.6.27 and 10 to
      v2.6.25 of the Linux kernel, to show the difference:
      
      before (git version 1.6.2.rc1.256.g58a87):
       7.860 user  2.427 sys  19.465 real  52.8% CPU  faults: 0 major 95331 minor
      after:
       6.184 user  2.160 sys  17.619 real  47.4% CPU  faults: 0 major 38994 minor
      Signed-off-by: NKjetil Barvik <barvik@broadpark.no>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e1afca4f
  12. 21 2月, 2009 1 次提交
    • L
      Support 'raw' date format · 7dff9b30
      Linus Torvalds 提交于
      Talking about --date, one thing I wanted for the 1234567890 date was to
      get things in the raw format. Sure, you get them with --pretty=raw, but it
      felt a bit sad that you couldn't just ask for the date in raw format.
      
      So here's a throw-away patch (meaning: I won't be re-sending it, because I
      really don't think it's a big deal) to add "--date=raw". It just prints
      out the internal raw git format - seconds since epoch plus timezone (put
      another way: 'date +"%s %z"' format)
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7dff9b30
  13. 20 2月, 2009 3 次提交
    • M
      More friendly message when locking the index fails. · e43a6fd3
      Matthieu Moy 提交于
      Just saying that index.lock exists doesn't tell the user _what_ to do
      to fix the problem. We should give an indication that it's normally
      safe to delete index.lock after making sure git isn't running here.
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e43a6fd3
    • J
      Introduce the function strip_path_suffix() · 4fcc86b0
      Johannes Schindelin 提交于
      The function strip_path_suffix() will try to strip a given suffix from
      a given path.  The suffix must start at a directory boundary (i.e. "core"
      is not a path suffix of "libexec/git-core", but "git-core" is).
      
      Arbitrary runs of directory separators ("slashes") are assumed identical.
      
      Example:
      
      	strip_path_suffix("C:\\msysgit/\\libexec\\git-core",
      		"libexec///git-core", &prefix)
      
      will set prefix to "C:\\msysgit" and return 0.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Acked-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4fcc86b0
    • K
      make USE_NSEC work as expected · fba2f38a
      Kjetil Barvik 提交于
      Since the filesystem ext4 is now defined as stable in Linux v2.6.28,
      and ext4 supports nanonsecond resolution timestamps natively, it is
      time to make USE_NSEC work as expected.
      
      This will make racy git situations less likely to happen.  For 'git
      checkout' this means it will be less likely that we have to open, read
      the contents of the file into RAM, and check if file is really
      modified or not.  The result sould be a litle less used CPU time, less
      pagefaults and a litle faster program, at least for 'git checkout'.
      
      Since the number of possible racy git situations would increase when
      disks gets faster, this patch would be more and more helpfull as times
      go by.  For a fast Solid State Disk, this patch should be helpfull.
      
      Note that, when file operations starts to take less than 1 nanosecond,
      one would again start to get more racy git situations.
      
      For more info on racy git, see Documentation/technical/racy-git.txt
      For more info on ext4, see http://kernelnewbies.org/Ext4Signed-off-by: NKjetil Barvik <barvik@broadpark.no>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fba2f38a
  14. 19 2月, 2009 1 次提交
    • K
      check_updates(): effective removal of cache entries marked CE_REMOVE · 36419c8e
      Kjetil Barvik 提交于
      Below is oprofile output from GIT command 'git chekcout -q my-v2.6.25'
      (move from tag v2.6.27 to tag v2.6.25 of the Linux kernel):
      
      CPU: Core 2, speed 1999.95 MHz (estimated)
      Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit
                               mask of 0x00 (Unhalted core cycles) count 20000
      Counted INST_RETIRED_ANY_P events (number of instructions retired) with a
                                 unit mask of 0x00 (No unit mask) count 20000
      CPU_CLK_UNHALT...|INST_RETIRED:2...|
        samples|      %|  samples|      %|
      ------------------------------------
         409247 100.000    342878 100.000 git
              CPU_CLK_UNHALT...|INST_RETIRED:2...|
                samples|      %|  samples|      %|
              ------------------------------------
                 260476 63.6476    257843 75.1996 libz.so.1.2.3
                 100876 24.6492     64378 18.7758 kernel-2.6.28.4_2.vmlinux
                  30850  7.5382      7874  2.2964 libc-2.9.so
                  14775  3.6103      8390  2.4469 git
                   2020  0.4936      4325  1.2614 libcrypto.so.0.9.8
                    191  0.0467        32  0.0093 libpthread-2.9.so
                     58  0.0142        36  0.0105 ld-2.9.so
                      1 2.4e-04         0       0 libldap-2.3.so.0.2.31
      
      Detail list of the top 20 function entries (libz counted in one blob):
      
      CPU_CLK_UNHALTED  INST_RETIRED_ANY_P
      samples  %        samples  %        image name               symbol name
      260476   63.6862  257843   75.2725  libz.so.1.2.3            /lib/libz.so.1.2.3
      16587     4.0555  3636      1.0615  libc-2.9.so              memcpy
      7710      1.8851  277       0.0809  libc-2.9.so              memmove
      3679      0.8995  1108      0.3235  kernel-2.6.28.4_2.vmlinux d_validate
      3546      0.8670  2607      0.7611  kernel-2.6.28.4_2.vmlinux __getblk
      3174      0.7760  1813      0.5293  libc-2.9.so              _int_malloc
      2396      0.5858  3681      1.0746  kernel-2.6.28.4_2.vmlinux copy_to_user
      2270      0.5550  2528      0.7380  kernel-2.6.28.4_2.vmlinux __link_path_walk
      2205      0.5391  1797      0.5246  kernel-2.6.28.4_2.vmlinux ext4_mark_iloc_dirty
      2103      0.5142  1203      0.3512  kernel-2.6.28.4_2.vmlinux find_first_zero_bit
      2077      0.5078  997       0.2911  kernel-2.6.28.4_2.vmlinux do_get_write_access
      2070      0.5061  514       0.1501  git                      cache_name_compare
      2043      0.4995  1501      0.4382  kernel-2.6.28.4_2.vmlinux rcu_irq_exit
      2022      0.4944  1732      0.5056  kernel-2.6.28.4_2.vmlinux __ext4_get_inode_loc
      2020      0.4939  4325      1.2626  libcrypto.so.0.9.8       /usr/lib/libcrypto.so.0.9.8
      1965      0.4804  1384      0.4040  git                      patch_delta
      1708      0.4176  984       0.2873  kernel-2.6.28.4_2.vmlinux rcu_sched_grace_period
      1682      0.4112  727       0.2122  kernel-2.6.28.4_2.vmlinux sysfs_slab_alias
      1659      0.4056  290       0.0847  git                      find_pack_entry_one
      1480      0.3619  1307      0.3816  kernel-2.6.28.4_2.vmlinux ext4_writepage_trans_blocks
      
      Notice the memmove line, where the CPU did 7710 / 277 = 27.8 cycles
      per instruction, and compared to the total cycles spent inside the
      source code of GIT for this command, all the memmove() calls
      translates to (7710 * 100) / 14775 = 52.2% of this.
      
      Retesting with a GIT program compiled for gcov usage, I found out that
      the memmove() calls came from remove_index_entry_at() in read-cache.c,
      where we have:
      
              memmove(istate->cache + pos,
                      istate->cache + pos + 1,
                      (istate->cache_nr - pos) * sizeof(struct cache_entry *));
      
      remove_index_entry_at() is called 4902 times from check_updates() in
      unpack-trees.c, and each time called we move each cache_entry pointers
      (from the removed one) one step to the left.
      
      Since we have 28828 entries in the cache this time, and if we on
      average move half of them each time, we in total move approximately
      4902 * 0.5 * 28828 * 4 = 282 629 712 bytes, or twice this amount if
      each pointer is 8 bytes (64 bit).
      
      OK, is seems that the function check_updates() is called 28 times, so
      the estimated guess above had been more correct if check_updates() had
      been called only once, but the point is: we get lots of bytes moved.
      
      To fix this, and use an O(N) algorithm instead, where N is the number
      of cache_entries, we delete/remove all entries in one loop through all
      entries.
      
      From a retest, the new remove_marked_cache_entries() from the patch
      below, ended up with the following output line from oprofile:
      
      46        0.0105  15        0.0041  git                      remove_marked_cache_entries
      
      If we can trust the numbers from oprofile in this case, we saved
      approximately ((7710 - 46) * 20000) / (2 * 1000 * 1000 * 1000) = 0.077
      seconds CPU time with this fix for this particular test.  And notice
      that now the CPU did only 46 / 15 = 3.1 cycles/instruction.
      Signed-off-by: NKjetil Barvik <barvik@broadpark.no>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      36419c8e
  15. 11 2月, 2009 2 次提交
  16. 10 2月, 2009 2 次提交
  17. 09 2月, 2009 1 次提交
  18. 08 2月, 2009 2 次提交
  19. 19 1月, 2009 4 次提交
    • K
      lstat_cache(): introduce clear_lstat_cache() function · bda6eb0d
      Kjetil Barvik 提交于
      If you want to completely clear the contents of the lstat_cache(), then
      call this new function.
      Signed-off-by: NKjetil Barvik <barvik@broadpark.no>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bda6eb0d
    • K
      lstat_cache(): introduce invalidate_lstat_cache() function · aeabab5c
      Kjetil Barvik 提交于
      In some cases it could maybe be necessary to say to the cache that
      "Hey, I deleted/changed the type of this pathname and if you currently
      have it inside your cache, you should deleted it".
      
      This patch introduce a function which support this.
      Signed-off-by: NKjetil Barvik <barvik@broadpark.no>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aeabab5c
    • K
      lstat_cache(): introduce has_dirs_only_path() function · bad4a54f
      Kjetil Barvik 提交于
      The create_directories() function in entry.c currently calls stat()
      or lstat() for each path component of the pathname 'path' each and every
      time.  For the 'git checkout' command, this function is called on each
      file for which we must do an update (ce->ce_flags & CE_UPDATE), so we get
      lots and lots of calls.
      
      To fix this, we make a new wrapper to the lstat_cache() function, and
      call the wrapper function instead of the calls to the stat() or the
      lstat() functions.  Since the paths given to the create_directories()
      function, is sorted alphabetically, the new wrapper would be very
      cache effective in this situation.
      
      To support it we must update the lstat_cache() function to be able to
      say that "please test the complete length of 'name'", and also to give
      it the length of a prefix, where the cache should use the stat()
      function instead of the lstat() function to test each path component.
      
      Thanks to Junio C Hamano, Linus Torvalds and Rene Scharfe for valuable
      comments to this patch!
      Signed-off-by: NKjetil Barvik <barvik@broadpark.no>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bad4a54f
    • K
      lstat_cache(): introduce has_symlink_or_noent_leading_path() function · 09c93066
      Kjetil Barvik 提交于
      In some cases, especially inside the unpack-trees.c file, and inside
      the verify_absent() function, we can avoid some unnecessary calls to
      lstat(), if the lstat_cache() function can also be told to keep track
      of non-existing directories.
      
      So we update the lstat_cache() function to handle this new fact,
      introduce a new wrapper function, and the result is that we save lots
      of lstat() calls for a removed directory which previously contained
      lots of files, when we call this new wrapper of lstat_cache() instead
      of the old one.
      
      We do similar changes inside the unlink_entry() function, since if we
      can already say that the leading directory component of a pathname
      does not exist, it is not necessary to try to remove a pathname below
      it!
      
      Thanks to Junio C Hamano, Linus Torvalds and Rene Scharfe for valuable
      comments to this patch!
      Signed-off-by: NKjetil Barvik <barvik@broadpark.no>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      09c93066
  20. 18 1月, 2009 1 次提交
  21. 15 1月, 2009 1 次提交
  22. 13 1月, 2009 1 次提交
  23. 11 1月, 2009 1 次提交
    • L
      Wrap inflate and other zlib routines for better error reporting · 39c68542
      Linus Torvalds 提交于
      R. Tyler Ballance reported a mysterious transient repository corruption;
      after much digging, it turns out that we were not catching and reporting
      memory allocation errors from some calls we make to zlib.
      
      This one _just_ wraps things; it doesn't do the "retry on low memory
      error" part, at least not yet. It is an independent issue from the
      reporting.  Some of the errors are expected and passed back to the caller,
      but we die when zlib reports it failed to allocate memory for now.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      39c68542
  24. 21 12月, 2008 1 次提交
    • J
      Introduce commit notes · 879ef248
      Johannes Schindelin 提交于
      Commit notes are blobs which are shown together with the commit
      message.  These blobs are taken from the notes ref, which you can
      configure by the config variable core.notesRef, which in turn can
      be overridden by the environment variable GIT_NOTES_REF.
      
      The notes ref is a branch which contains "files" whose names are
      the names of the corresponding commits (i.e. the SHA-1).
      
      The rationale for putting this information into a ref is this: we
      want to be able to fetch and possibly union-merge the notes,
      maybe even look at the date when a note was introduced, and we
      want to store them efficiently together with the other objects.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      879ef248
  25. 11 12月, 2008 1 次提交
  26. 29 11月, 2008 1 次提交
    • J
      git add --intent-to-add: fix removal of cached emptiness · 388b2acd
      Junio C Hamano 提交于
      This uses the extended index flag mechanism introduced earlier to mark
      the entries added to the index via "git add -N" with CE_INTENT_TO_ADD.
      
      The logic to detect an "intent to add" entry for the purpose of allowing
      "git rm --cached $path" is tightened to check not just for a staged empty
      blob, but with the CE_INTENT_TO_ADD bit.  This protects an empty blob that
      was explicitly added and then modified in the work tree from being dropped
      with this sequence:
      
      	$ >empty
      	$ git add empty
      	$ echo "non empty" >empty
      	$ git rm --cached empty
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      388b2acd
  27. 15 11月, 2008 1 次提交
    • L
      Add cache preload facility · 671c9b7e
      Linus Torvalds 提交于
      This can do the lstat() storm in parallel, giving potentially much
      improved performance for cold-cache cases or things like NFS that have
      weak metadata caching.
      
      Just use "read_cache_preload()" instead of "read_cache()" to force an
      optimistic preload of the index stat data.  The function takes a
      pathspec as its argument, allowing us to preload only the relevant
      portion of the index.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      671c9b7e
  28. 13 11月, 2008 2 次提交
    • J
      checkout: Fix "initial checkout" detection · fa7b3c2f
      Junio C Hamano 提交于
      Earlier commit 55218834 (checkout: do not lose staged removal, 2008-09-07)
      tightened the rule to prevent switching branches from losing local
      changes, so that staged removal of paths can be protected, while
      attempting to keep a loophole to still allow a special case of switching
      out of an un-checked-out state.
      
      However, the loophole was made a bit too tight, and did not allow
      switching from one branch (in an un-checked-out state) to check out
      another branch.
      
      The change to builtin-checkout.c in this commit loosens it to allow this,
      by not insisting the original commit and the new commit to be the same.
      
      It also introduces a new function, is_index_unborn (and an associated
      macro, is_cache_unborn), to check if the repository is truly in an
      un-checked-out state more reliably, by making sure that $GIT_INDEX_FILE
      did not exist when populating the in-core index structure.  A few places
      the earlier commit 55218834 added the check for the initial checkout
      condition are updated to use this function.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fa7b3c2f
    • J
      define empty tree sha1 as a macro · 14d9c578
      Jeff King 提交于
      This can potentially be used in a few places, so let's make
      it available to all parts of the code.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      14d9c578