1. 18 6月, 2014 2 次提交
  2. 11 12月, 2013 1 次提交
    • N
      shallow.c: the 8 steps to select new commits for .git/shallow · 58babfff
      Nguyễn Thái Ngọc Duy 提交于
      Suppose a fetch or push is requested between two shallow repositories
      (with no history deepening or shortening). A pack that contains
      necessary objects is transferred over together with .git/shallow of
      the sender. The receiver has to determine whether it needs to update
      .git/shallow if new refs needs new shallow comits.
      
      The rule here is avoid updating .git/shallow by default. But we don't
      want to waste the received pack. If the pack contains two refs, one
      needs new shallow commits installed in .git/shallow and one does not,
      we keep the latter and reject/warn about the former.
      
      Even if .git/shallow update is allowed, we only add shallow commits
      strictly necessary for the former ref (remember the sender can send
      more shallow commits than necessary) and pay attention not to
      accidentally cut the receiver history short (no history shortening is
      asked for)
      
      So the steps to figure out what ref need what new shallow commits are:
      
      1. Split the sender shallow commit list into "ours" and "theirs" list
         by has_sha1_file. Those that exist in current repo in "ours", the
         remaining in "theirs".
      
      2. Check the receiver .git/shallow, remove from "ours" the ones that
         also exist in .git/shallow.
      
      3. Fetch the new pack. Either install or unpack it.
      
      4. Do has_sha1_file on "theirs" list again. Drop the ones that fail
         has_sha1_file. Obviously the new pack does not need them.
      
      5. If the pack is kept, remove from "ours" the ones that do not exist
         in the new pack.
      
      6. Walk the new refs to answer the question "what shallow commits,
         both ours and theirs, are required in .git/shallow in order to add
         this ref?". Shallow commits not associated to any refs are removed
         from their respective list.
      
      7. (*) Check reachability (from the current refs) of all remaining
         commits in "ours". Those reachable are removed. We do not want to
         cut any part of our (reachable) history. We only check up
         commits. True reachability test is done by
         check_everything_connected() at the end as usual.
      
      8. Combine the final "ours" and "theirs" and add them all to
         .git/shallow. Install new refs. The case where some hook rejects
         some refs on a push is explained in more detail in the push
         patches.
      
      Of these steps, #6 and #7 are expensive. Both require walking through
      some commits, or in the worst case all commits. And we rather avoid
      them in at least common case, where the transferred pack does not
      contain any shallow commits that the sender advertises. Let's look at
      each scenario:
      
      1) the sender has longer history than the receiver
      
         All shallow commits from the sender will be put into "theirs" list
         at step 1 because none of them exists in current repo. In the
         common case, "theirs" becomes empty at step 4 and exit early.
      
      2) the sender has shorter history than the receiver
      
         All shallow commits from the sender are likely in "ours" list at
         step 1. In the common case, if the new pack is kept, we could empty
         "ours" and exit early at step 5.
      
         If the pack is not kept, we hit the expensive step 6 then exit
         after "ours" is emptied. There'll be only a handful of objects to
         walk in fast-forward case. If it's forced update, we may need to
         walk to the bottom.
      
      3) the sender has same .git/shallow as the receiver
      
         This is similar to case 2 except that "ours" should be emptied at
         step 2 and exit early.
      
      A fetch after "clone --depth=X" is case 1. A fetch after "clone" (from
      a shallow repo) is case 3. Luckily they're cheap for the common case.
      
      A push from "clone --depth=X" falls into case 2, which is expensive.
      Some more work may be done at the sender/client side to avoid more
      work on the server side: if the transferred pack does not contain any
      shallow commits, send-pack should not send any shallow commits to the
      receive-pack, effectively turning it into a normal push and avoid all
      steps.
      
      This patch implements all steps except #3, already handled by
      fetch-pack and receive-pack, #6 and #7, which has their own patch due
      to their size.
      
      (*) in previous versions step 7 was put before step 3. I reorder it so
          that the common case that keeps the pack does not need to walk
          commits at all. In future if we implement faster commit
          reachability check (maybe with the help of pack bitmaps or commit
          cache), step 7 could become cheap and be moved up before 6 again.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      58babfff
  3. 10 7月, 2013 1 次提交
    • J
      add missing "format" function attributes · 4621085b
      Jeff King 提交于
      For most of our functions that take printf-like formats, we
      use gcc's __attribute__((format)) to get compiler warnings
      when the functions are misused. Let's give a few more
      functions the same protection.
      
      In most cases, the annotations do not uncover any actual
      bugs; the only code change needed is that we passed a size_t
      to transfer_debug, which expected an int. Since we expect
      the passed-in value to be a relatively small buffer size
      (and cast a similar value to int directly below), we can
      just cast away the problem.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4621085b
  4. 16 9月, 2012 1 次提交
  5. 23 3月, 2011 1 次提交
    • S
      Fix sparse warnings · c2e86add
      Stephen Boyd 提交于
      Fix warnings from 'make check'.
      
       - These files don't include 'builtin.h' causing sparse to complain that
         cmd_* isn't declared:
      
         builtin/clone.c:364, builtin/fetch-pack.c:797,
         builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78,
         builtin/merge-index.c:69, builtin/merge-recursive.c:22
         builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426
         builtin/notes.c:822, builtin/pack-redundant.c:596,
         builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149,
         builtin/remote.c:1512, builtin/remote-ext.c:240,
         builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384,
         builtin/unpack-file.c:25, builtin/var.c:75
      
       - These files have symbols which should be marked static since they're
         only file scope:
      
         submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13,
         submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79,
         unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123,
         url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48
      
       - These files redeclare symbols to be different types:
      
         builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571,
         usage.c:49, usage.c:58, usage.c:63, usage.c:72
      
       - These files use a literal integer 0 when they really should use a NULL
         pointer:
      
         daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362
      
      While we're in the area, clean up some unused #includes in builtin files
      (mostly exec_cmd.h).
      Signed-off-by: NStephen Boyd <bebarino@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c2e86add
  6. 09 3月, 2011 5 次提交
  7. 26 2月, 2011 1 次提交
  8. 07 1月, 2011 1 次提交
  9. 22 12月, 2010 1 次提交
  10. 18 12月, 2010 1 次提交
  11. 30 11月, 2010 1 次提交
  12. 09 5月, 2010 1 次提交
  13. 25 2月, 2009 1 次提交
  14. 04 12月, 2007 1 次提交
  15. 27 11月, 2007 1 次提交
  16. 14 11月, 2007 1 次提交
    • S
      Handle broken vsnprintf implementations in strbuf · f141bd80
      Shawn O. Pearce 提交于
      Solaris 9's vsnprintf implementation returns -1 if we pass it a
      buffer of length 0.  The only way to get it to give us the actual
      length necessary for the formatted string is to grow the buffer
      out to have at least 1 byte available in the strbuf and then ask
      it to compute the length.
      
      If the available space is 0 I'm growing it out by 64 to ensure
      we will get an accurate length estimate from all implementations.
      Some callers may need to grow the strbuf again but 64 should be a
      reasonable enough initial growth.
      
      We also no longer silently fail to append to the string when we are
      faced with a broken vsnprintf implementation.  On Solaris 9 this
      silent failure caused me to no longer be able to execute "git clone"
      as we tried to exec the empty string rather than "git-clone".
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f141bd80
  17. 21 9月, 2007 2 次提交
    • P
      sq_quote_argv and add_to_string rework with strbuf's. · 7a33bcbe
      Pierre Habouzit 提交于
      * sq_quote_buf is made public, and works on a strbuf.
      * sq_quote_argv also works on a strbuf.
      * make sq_quote_argv take a "maxlen" argument to check the buffer won't grow
        too big.
      Signed-off-by: NPierre Habouzit <madcoder@debian.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7a33bcbe
    • P
      nfv?asprintf are broken without va_copy, workaround them. · 19247e55
      Pierre Habouzit 提交于
      * drop nfasprintf.
      * move nfvasprintf into imap-send.c back, and let it work on a 8k buffer,
        and die() in case of overflow. It should be enough for imap commands, if
        someone cares about imap-send, he's welcomed to fix it properly.
      * replace nfvasprintf use in merge-recursive with a copy of the strbuf_addf
        logic, it's one place, we'll live with it.
        To ease the change, output_buffer string list is replaced with a strbuf ;)
      * rework trace.c to call vsnprintf itself.  It's used to format strerror()s
        and git command names, it should never be more than a few octets long, let
        it work on a 8k static buffer with vsnprintf or die loudly.
      Signed-off-by: NPierre Habouzit <madcoder@debian.org>
      19247e55
  18. 11 3月, 2007 1 次提交
    • P
      git-branch, git-checkout: autosetup for remote branch tracking · 0746d19a
      Paolo Bonzini 提交于
      In order to track and build on top of a branch 'topic' you track from
      your upstream repository, you often would end up doing this sequence:
      
        git checkout -b mytopic origin/topic
        git config --add branch.mytopic.remote origin
        git config --add branch.mytopic.merge refs/heads/topic
      
      This would first fork your own 'mytopic' branch from the 'topic'
      branch you track from the 'origin' repository; then it would set up two
      configuration variables so that 'git pull' without parameters does the
      right thing while you are on your own 'mytopic' branch.
      
      This commit adds a --track option to git-branch, so that "git
      branch --track mytopic origin/topic" performs the latter two actions
      when creating your 'mytopic' branch.
      
      If the configuration variable branch.autosetupmerge is set to true, you
      do not have to pass the --track option explicitly; further patches in
      this series allow setting the variable with a "git remote add" option.
      The configuration variable is off by default, and there is a --no-track
      option to countermand it even if the variable is set.
      Signed-off-by: NPaolo Bonzini  <bonzini@gnu.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      0746d19a
  19. 09 1月, 2007 1 次提交
    • A
      short i/o: clean up the naming for the write_{in,or}_xxx family · e0814056
      Andy Whitcroft 提交于
      We recently introduced a write_in_full() which would either write
      the specified object or emit an error message and fail.  In order
      to fix the read side we now want to introduce a read_in_full()
      but without an error emit.  This patch cleans up the naming
      of this family of calls:
      
      1) convert the existing write_or_whine() to write_or_whine_pipe()
         to better indicate its pipe specific nature,
      2) convert the existing write_in_full() calls to write_or_whine()
         to better indicate its nature,
      3) introduce a write_in_full() providing a write or fail semantic,
         and
      4) convert write_or_whine() and write_or_whine_pipe() to use
         write_in_full().
      Signed-off-by: NAndy Whitcroft <apw@shadowen.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      e0814056
  20. 15 10月, 2006 1 次提交
  21. 13 9月, 2006 1 次提交
  22. 03 9月, 2006 1 次提交
    • C
      Trace into a file or an open fd and refactor tracing code. · 6ce4e61f
      Christian Couder 提交于
      If GIT_TRACE is set to an absolute path (starting with a
      '/' character), we interpret this as a file path and we
      trace into it.
      
      Also if GIT_TRACE is set to an integer value greater than
      1 and lower than 10, we interpret this as an open fd value
      and we trace into it.
      
      Note that this behavior is not compatible with the
      previous one.
      
      We also trace whole messages using one write(2) call to
      make sure messages from processes do net get mixed up in
      the middle.
      
      This patch makes it possible to get trace information when
      running "make test".
      Signed-off-by: NChristian Couder <chriscool@tuxfamily.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      6ce4e61f
  23. 01 9月, 2006 1 次提交