1. 20 5月, 2011 2 次提交
    • J
      receive-pack: eliminate duplicate .have refs · cff38a5e
      Jeff King 提交于
      When receiving a push, we advertise ref tips from any
      alternate repositories, in case that helps the client send a
      smaller pack. Since these refs don't actually exist in the
      destination repository, we don't transmit the real ref
      names, but instead use the pseudo-ref ".have".
      
      If your alternate has a large number of duplicate refs (for
      example, because it is aggregating objects from many related
      repositories, some of which will have the same tags and
      branch tips), then we will send each ".have $sha1" line
      multiple times. This is a pointless waste of bandwidth, as
      we are simply repeating the same fact to the client over and
      over.
      
      This patch eliminates duplicate .have refs early on. It does
      so efficiently by sorting the complete list and skipping
      duplicates. This has the side effect of re-ordering the
      .have lines by ascending sha1; this isn't a problem, though,
      as the original order was meaningless.
      
      There is a similar .have system in fetch-pack, but it
      does not suffer from the same problem. For each alternate
      ref we consider in fetch-pack, we actually open the object
      and mark it with the SEEN flag, so duplicates are
      automatically culled.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cff38a5e
    • J
      refactor refs_from_alternate_cb to allow passing extra data · 114a6a88
      Jeff King 提交于
      The foreach_alt_odb function triggers a callback for each
      alternate object db we have, with room for a single void
      pointer as data. Currently, we always call refs_from_alternate_cb
      as the callback function, and then pass another callback (to
      receive each ref individually) as the void pointer.
      
      This has two problems:
      
        1. C technically forbids stuffing a function pointer into
           a "void *". In practice, this probably doesn't matter
           on any architectures git runs on, but it never hurts to
           follow the letter of the law.
      
        2. There is no room for an extra data pointer. Indeed, the
           alternate_ref_fn that refs_from_alternate_cb calls
           takes a void* for data, but we always pass it NULL.
      
      Instead, let's properly stuff our function pointer into a
      data struct, which also leaves room for an extra
      caller-supplied data pointer. And to keep things simple for
      existing callers, let's make a for_each_alternate_ref
      function that takes care of creating the extra struct.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      114a6a88
  2. 04 4月, 2011 1 次提交
  3. 18 3月, 2011 2 次提交
    • J
      refs_from_alternate: helper to use refs from alternates · 36cfda15
      Junio C Hamano 提交于
      The receiving end of "git push" advertises the objects that the repository
      itself does not use, but are at the tips of refs in other repositories
      whose object databases are used as alternates for it. This helps it avoid
      having to receive (and the pusher having to send) objects that are already
      available to the receiving repository via the alternates mechanism.
      
      Tweak the helper function that implements this feature, and move it to
      transport.[ch] for future reuse by other programs.
      
      The additional test demonstrates how this optimization is helping "git push",
      and "git fetch" is ignorant about it.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Acked-by: NShawn O. Pearce <spearce@spearce.org>
      36cfda15
    • C
      Name make_*_path functions more accurately · e2a57aac
      Carlos Martín Nieto 提交于
      Rename the make_*_path functions so it's clearer what they do, in
      particlar make clear what the differnce between make_absolute_path and
      make_nonrelative_path is by renaming them real_path and absolute_path
      respectively. make_relative_path has an understandable name and is
      renamed to relative_path to maintain the name convention.
      
      The function calls have been replaced 1-to-1 in their usage.
      Signed-off-by: NCarlos Martín Nieto <cmn@elego.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e2a57aac
  4. 09 3月, 2011 1 次提交
    • J
      add packet tracing debug code · bbc30f99
      Jeff King 提交于
      This shows a trace of all packets coming in or out of a given
      program. This can help with debugging object negotiation or
      other protocol issues.
      
      To keep the code changes simple, we operate at the lowest
      level, meaning we don't necessarily understand what's in the
      packets. The one exception is a packet starting with "PACK",
      which causes us to skip that packet and turn off tracing
      (since the gigantic pack data will not be interesting to
      read, at least not in the trace format).
      
      We show both written and read packets. In the local case,
      this may mean you will see packets twice (written by the
      sender and read by the receiver). However, for cases where
      the other end is remote, this allows you to see the full
      conversation.
      
      Packet tracing can be enabled with GIT_TRACE_PACKET=<foo>,
      where <foo> takes the same arguments as GIT_TRACE.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bbc30f99
  5. 06 7月, 2010 1 次提交
  6. 28 6月, 2010 2 次提交
  7. 01 6月, 2010 1 次提交
    • G
      enums: omit trailing comma for portability · 4b05548f
      Gary V. Vaughan 提交于
      Without this patch at least IBM VisualAge C 5.0 (I have 5.0.2) on AIX
      5.1 fails to compile git.
      
      enum style is inconsistent already, with some enums declared on one
      line, some over 3 lines with the enum values all on the middle line,
      sometimes with 1 enum value per line... and independently of that the
      trailing comma is sometimes present and other times absent, often
      mixing with/without trailing comma styles in a single file, and
      sometimes in consecutive enum declarations.
      
      Clearly, omitting the comma is the more portable style, and this patch
      changes all enum declarations to use the portable omitted dangling
      comma style consistently.
      Signed-off-by: NGary V. Vaughan <gary@thewrittenword.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4b05548f
  8. 23 2月, 2010 1 次提交
    • L
      Move 'builtin-*' into a 'builtin/' subdirectory · 81b50f3c
      Linus Torvalds 提交于
      This shrinks the top-level directory a bit, and makes it much more
      pleasant to use auto-completion on the thing. Instead of
      
      	[torvalds@nehalem git]$ em buil<tab>
      	Display all 180 possibilities? (y or n)
      	[torvalds@nehalem git]$ em builtin-sh
      	builtin-shortlog.c     builtin-show-branch.c  builtin-show-ref.c
      	builtin-shortlog.o     builtin-show-branch.o  builtin-show-ref.o
      	[torvalds@nehalem git]$ em builtin-shor<tab>
      	builtin-shortlog.c  builtin-shortlog.o
      	[torvalds@nehalem git]$ em builtin-shortlog.c
      
      you get
      
      	[torvalds@nehalem git]$ em buil<tab>		[type]
      	builtin/   builtin.h
      	[torvalds@nehalem git]$ em builtin		[auto-completes to]
      	[torvalds@nehalem git]$ em builtin/sh<tab>	[type]
      	shortlog.c     shortlog.o     show-branch.c  show-branch.o  show-ref.c     show-ref.o
      	[torvalds@nehalem git]$ em builtin/sho		[auto-completes to]
      	[torvalds@nehalem git]$ em builtin/shor<tab>	[type]
      	shortlog.c  shortlog.o
      	[torvalds@nehalem git]$ em builtin/shortlog.c
      
      which doesn't seem all that different, but not having that annoying
      break in "Display all 180 possibilities?" is quite a relief.
      
      NOTE! If you do this in a clean tree (no object files etc), or using an
      editor that has auto-completion rules that ignores '*.o' files, you
      won't see that annoying 'Display all 180 possibilities?' message - it
      will just show the choices instead.  I think bash has some cut-off
      around 100 choices or something.
      
      So the reason I see this is that I'm using an odd editory, and thus
      don't have the rules to cut down on auto-completion.  But you can
      simulate that by using 'ls' instead, or something similar.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      81b50f3c
  9. 11 2月, 2010 1 次提交
  10. 06 2月, 2010 3 次提交
  11. 05 11月, 2009 1 次提交
    • S
      Add stateless RPC options to upload-pack, receive-pack · 42526b47
      Shawn O. Pearce 提交于
      When --stateless-rpc is passed as a command line parameter to
      upload-pack or receive-pack the programs now assume they may
      perform only a single read-write cycle with stdin and stdout.
      This fits with the HTTP POST request processing model where a
      program may read the request, write a response, and must exit.
      
      When --advertise-refs is passed as a command line parameter only
      the initial ref advertisement is output, and the program exits
      immediately.  This fits with the HTTP GET request model, where
      no request content is received but a response must be produced.
      
      HTTP headers and/or environment are not processed here, but
      instead are assumed to be handled by the program invoking
      either service backend.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      42526b47
  12. 25 10月, 2009 1 次提交
  13. 22 10月, 2009 1 次提交
  14. 30 7月, 2009 2 次提交
  15. 06 7月, 2009 4 次提交
    • J
      receive-pack: remove unnecessary run_status report · 90e41a89
      Johannes Sixt 提交于
      The function run_status was used to report failures after a hook was run.
      By now, the only thing that the function itself reported was the exit code
      of the hook (if it was non-zero). But this is redundant because it can be
      expected that the hook itself will have reported a suitable error.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      90e41a89
    • J
      run_command: report failure to execute the program, but optionally don't · c024beb5
      Johannes Sixt 提交于
      In the case where a program was not found, it was still the task of the
      caller to report an error to the user. Usually, this is an interesting case
      but only few callers actually reported a specific error (though many call
      sites report a generic error message regardless of the cause).
      
      With this change the error is reported by run_command, but since there is
      one call site in git.c that does not want that, an option is added to
      struct child_process, which is used to turn the error off.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c024beb5
    • J
      run_command: report system call errors instead of returning error codes · 0ac77ec3
      Johannes Sixt 提交于
      The motivation for this change is that system call failures are serious
      errors that should be reported to the user, but only few callers took the
      burden to decode the error codes that the functions returned into error
      messages.
      
      If at all, then only an unspecific error message was given. A prominent
      example is this:
      
         $ git upload-pack . | :
         fatal: unable to run 'git-upload-pack'
      
      In this example, git-upload-pack, the external command invoked through the
      git wrapper, dies due to SIGPIPE, but the git wrapper does not bother to
      report the real cause. In fact, this very error message is copied to the
      syslog if git-daemon's client aborts the connection early.
      
      With this change, system call failures are reported immediately after the
      failure and only a generic failure code is returned to the caller. In the
      above example the error is now to the point:
      
         $ git upload-pack . | :
         error: git-upload-pack died of signal
      
      Note that there is no error report if the invoked program terminated with
      a non-zero exit code, because it is reasonable to expect that the invoked
      program has already reported an error. (But many run_command call sites
      nevertheless write a generic error message.)
      
      There was one special return code that was used to identify the case where
      run_command failed because the requested program could not be exec'd. This
      special case is now treated like a system call failure with errno set to
      ENOENT. No error is reported in this case, because the call site in git.c
      expects this as a normal result. Therefore, the callers that carefully
      decoded the return value still check for this condition.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0ac77ec3
    • J
      run_command: return exit code as positive value · 5709e036
      Johannes Sixt 提交于
      As a general guideline, functions in git's code return zero to indicate
      success and negative values to indicate failure. The run_command family of
      functions followed this guideline. But there are actually two different
      kinds of failure:
      
      - failures of system calls;
      
      - non-zero exit code of the program that was run.
      
      Usually, a non-zero exit code of the program is a failure and means a
      failure to the caller. Except that sometimes it does not. For example, the
      exit code of merge programs (e.g. external merge drivers) conveys
      information about how the merge failed, and not all exit calls are
      actually failures.
      
      Furthermore, the return value of run_command is sometimes used as exit
      code by the caller.
      
      This change arranges that the exit code of the program is returned as a
      positive value, which can now be regarded as the "result" of the function.
      System call failures continue to be reported as negative values.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5709e036
  16. 22 6月, 2009 1 次提交
    • J
      receive-pack: do not send error details to the client · 2ff4d1ab
      Johannes Sixt 提交于
      If the objects that a client pushes to the server cannot be processed for
      any reason, an error is reported back to the client via the git protocol.
      We used to send quite detailed information if a system call failed if
      unpack-objects is run. This can be regarded as an information leak. Now we
      do not send any error details like we already do in the case where
      index-pack failed.
      
      Errors in system calls as well as the exit code of unpack-objects and
      index-pack are now reported to stderr; in the case of a local push or via
      ssh these messages still go to the client, but that is OK since these forms
      of access to the server assume that the client can be trusted. If
      receive-pack is run from git-daemon, then the daemon should put the error
      messages into the syslog.
      
      With this reasoning a new status report is added for the post-update-hook;
      untrusted (i.e. daemon's) clients cannot observe its status anyway, others
      may want to know failure details.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2ff4d1ab
  17. 09 6月, 2009 1 次提交
  18. 02 5月, 2009 1 次提交
    • N
      allow OFS_DELTA objects during a push · b74fce16
      Nicolas Pitre 提交于
      The fetching of OFS_DELTA objects has been negotiated between both peers
      since git version 1.4.4.  However, this was missing from the push side
      where every OFS_DELTA objects were always converted to REF_DELTA objects
      causing an increase in transferred data.
      
      To fix this, both the client and the server processes have to be
      modified: the former to invoke pack-objects with --delta-base-offset
      when the server provides the ofs-delta capability, and the later to send
      that capability when OFS_DELTA objects are allowed as already indicated
      by the repack.usedeltabaseoffset config variable which is TRUE by
      default since git v1.6.0.
      Signed-off-by: NNicolas Pitre <nico@cam.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b74fce16
  19. 30 4月, 2009 1 次提交
    • A
      replace direct calls to unlink(2) with unlink_or_warn · 691f1a28
      Alex Riesen 提交于
      This helps to notice when something's going wrong, especially on
      systems which lock open files.
      
      I used the following criteria when selecting the code for replacement:
      - it was already printing a warning for the unlink failures
      - it is in a function which already printing something or is
        called from such a function
      - it is in a static function, returning void and the function is only
        called from a builtin main function (cmd_)
      - it is in a function which handles emergency exit (signal handlers)
      - it is in a function which is obvously cleaning up the lockfiles
      Signed-off-by: NAlex Riesen <raa.lkml@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      691f1a28
  20. 05 3月, 2009 1 次提交
  21. 16 2月, 2009 1 次提交
    • R
      builtin-receive-pack.c: fix compiler warnings about format string · 88a667f0
      René Scharfe 提交于
      While all of the strings passed to warning() are, in fact, literals, the
      compiler doesn't recognize them as such because it doesn't see through
      the loop used to iterate over them:
      
         builtin-receive-pack.c: In function 'warn_unconfigured_deny':
         builtin-receive-pack.c:247: warning: format not a string literal and no format arguments
         builtin-receive-pack.c: In function 'warn_unconfigured_deny_delete_current':
         builtin-receive-pack.c:273: warning: format not a string literal and no format arguments
      
      Calm the compiler by adding easily recognizable format string literals.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      88a667f0
  22. 11 2月, 2009 2 次提交
  23. 05 2月, 2009 1 次提交
  24. 03 2月, 2009 1 次提交
  25. 18 1月, 2009 1 次提交
  26. 10 11月, 2008 1 次提交
    • J
      receive-pack: detect push to current branch of non-bare repo · 986e8239
      Jeff King 提交于
      Pushing into the currently checked out branch of a non-bare
      repository can be dangerous; the HEAD then loses sync with
      the index and working tree, and it looks in the receiving
      repo as if the pushed changes have been reverted in the
      index (since they were never there in the first place).
      
      This patch adds a safety valve that checks for this
      condition and either generates a warning or denies the
      update. We trigger the check only on a non-bare repository,
      since a bare repo does not have a working tree (and in fact,
      pushing to the HEAD branch is a common workflow for
      publishing repositories).
      
      The behavior is configurable via receive.denyCurrentBranch,
      defaulting to "warn" so as not to break existing setups
      (though it may, after a deprecation period, switch to
      "refuse" by default). For users who know what they are doing
      and want to silence the warning (e.g., because they have a
      post-receive hook that reconciles the HEAD and working
      tree), they can turn off the warning by setting it to false
      or "ignore".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      986e8239
  27. 02 11月, 2008 1 次提交
  28. 27 10月, 2008 1 次提交
    • J
      receive-pack: fix "borrowing from alternate object store" implementation · b8492539
      Junio C Hamano 提交于
      In the alternate_object_database structure, ent->base[] is a buffer the
      users can use to form pathnames to loose objects, and ent->name is a
      pointer into that buffer (it points at one beyond ".git/objects/").  If
      you get a call to add_refs_from_alternate() after somebody used the entry
      (has_loose_object() has been called, for example), *ent->name would not be
      NUL, and ent->base[] won't be the path to the object store.
      
      This caller is expecting to read the path to the object store in ent->base[];
      it needs to NUL terminate the buffer if it wants to.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b8492539
  29. 10 9月, 2008 2 次提交
    • J
      push: receiver end advertises refs from alternate repositories · d79796bc
      Junio C Hamano 提交于
      Earlier, when pushing into a repository that borrows from alternate object
      stores, we followed the longstanding design decision not to trust refs in
      the alternate repository that houses the object store we are borrowing
      from.  If your public repository is borrowing from Linus's public
      repository, you pushed into it long time ago, and now when you try to push
      your updated history that is in sync with more recent history from Linus,
      you will end up sending not just your own development, but also the
      changes you acquired through Linus's tree, even though the objects needed
      for the latter already exists at the receiving end.  This is because the
      receiving end does not advertise that the objects only reachable from the
      borrowed repository (i.e. Linus's) are already available there.
      
      This solves the issue by making the receiving end advertise refs from
      borrowed repositories.  They are not sent with their true names but with a
      phoney name ".have" to make sure that the old senders will safely ignore
      them (otherwise, the old senders will misbehave, trying to push matching
      refs, and mirror push that deletes refs that only exist at the receiving
      end).
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d79796bc
    • J
      receive-pack: make it a builtin · be5908ae
      Junio C Hamano 提交于
      It is a good thing to do in general, but more importantly, transport
      routines can only be used by built-ins, which is what I'll be adding next.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      be5908ae