1. 08 11月, 2007 1 次提交
  2. 06 11月, 2007 1 次提交
  3. 03 11月, 2007 1 次提交
    • D
      Miscellaneous const changes and utilities · 4577370e
      Daniel Barkalow 提交于
      The list of remote refs in struct transport should be const, because
      builtin-fetch will get confused if it changes.
      
      The url in git_connect should be const (and work on a copy) instead of
      requiring the caller to copy it.
      
      match_refs doesn't modify the refspecs it gets.
      
      get_fetch_map and get_remote_ref don't change the list they get.
      
      Allow transport get_refs_list methods to modify the struct transport.
      
      Add a function to copy a list of refs, when a function needs a mutable
      copy of a const list.
      
      Add a function to check the type of a ref, as per the code in connect.c
      Signed-off-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4577370e
  4. 21 10月, 2007 1 次提交
  5. 30 9月, 2007 1 次提交
  6. 27 9月, 2007 1 次提交
  7. 21 9月, 2007 1 次提交
    • 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
  8. 19 9月, 2007 1 次提交
    • D
      Make fetch a builtin · b888d61c
      Daniel Barkalow 提交于
      Thanks to Johannes Schindelin for review and fixes, and Julian
      Phillips for the original C translation.
      
      This changes a few small bits of behavior:
      
      branch.<name>.merge is parsed as if it were the lhs of a fetch
      refspec, and does not have to exactly match the actual lhs of a
      refspec, so long as it is a valid abbreviation for the same ref.
      
      branch.<name>.merge is no longer ignored if the remote is configured
      with a branches/* file. Neither behavior is useful, because there can
      only be one ref that gets fetched, but this is more consistant.
      
      Also, fetch prints different information to standard out.
      Signed-off-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b888d61c
  9. 18 9月, 2007 1 次提交
  10. 17 9月, 2007 1 次提交
    • P
      Rewrite convert_to_{git,working_tree} to use strbuf's. · 5ecd293d
      Pierre Habouzit 提交于
      * Now, those functions take an "out" strbuf argument, where they store their
        result if any. In that case, it also returns 1, else it returns 0.
      * those functions support "in place" editing, in the sense that it's OK to
        call them this way:
          convert_to_git(path, sb->buf, sb->len, sb);
        When doable, conversions are done in place for real, else the strbuf
        content is just replaced with the new one, transparentely for the caller.
      
      If you want to create a new filter working this way, being the accumulation
      of filter1, filter2, ... filtern, then your meta_filter would be:
      
          int meta_filter(..., const char *src, size_t len, struct strbuf *sb)
          {
              int ret = 0;
              ret |= filter1(...., src, len, sb);
              if (ret) {
                  src = sb->buf;
                  len = sb->len;
              }
              ret |= filter2(...., src, len, sb);
              if (ret) {
                  src = sb->buf;
                  len = sb->len;
              }
              ....
              return ret | filtern(..., src, len, sb);
          }
      
      That's why subfilters the convert_to_* functions called were also rewritten
      to work this way.
      Signed-off-by: NPierre Habouzit <madcoder@debian.org>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5ecd293d
  11. 13 9月, 2007 1 次提交
  12. 11 9月, 2007 1 次提交
  13. 04 9月, 2007 1 次提交
  14. 01 9月, 2007 1 次提交
    • J
      git-diff: resurrect the traditional empty "diff --git" behaviour · aecbf914
      Junio C Hamano 提交于
      The warning message to suggest "Consider running git-status" from
      "git-diff" that we experimented with during the 1.5.3 cycle turns
      out to be a bad idea.  It robbed cache-dirty information from people
      who valued it, while still asking users to run "update-index --refresh".
      It was hoped that the new behaviour would at least have some educational
      value, but not showing the cache-dirty paths like before meant that the
      user would not even know easily which paths were cache-dirty, and it
      made the need to refresh the index look like even more unnecessary chore.
      
      This commit reinstates the traditional behaviour, but with a twist.
      
      By default, the empty "diff --git" output is totally squelched out
      from "git diff" output.  At the end of the command, it automatically
      runs "update-index --refresh" as needed, without even bothering the
      user.  In other words, people who do not care about the cache-dirtyness
      do not even have to see the warning.
      
      The traditional behaviour to see the stat-dirty output and to bypassing
      the overhead of content comparison can be specified by setting the
      configuration variable diff.autorefreshindex to false.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aecbf914
  15. 14 8月, 2007 1 次提交
  16. 11 8月, 2007 1 次提交
    • J
      Optimize "diff --cached" performance. · af3785dc
      Junio C Hamano 提交于
      The read_tree() function is called only from the call chain to
      run "git diff --cached" (this includes the internal call made by
      git-runstatus to run_diff_index()).  The function vacates stage
      without any funky "merge" magic.  The caller then goes and
      compares stage #1 entries from the tree with stage #0 entries
      from the original index.
      
      When adding the cache entries this way, it used the general
      purpose add_cache_entry().  This function looks for an existing
      entry to replace or if there is none to find where to insert the
      new entry, resolves D/F conflict and all the other things.
      
      For the purpose of reading entries into an empty stage, none of
      that processing is needed.  We can instead append everything and
      then sort the result at the end.
      
      This commit changes read_tree() to first make sure that there is
      no existing cache entries at specified stage, and if that is the
      case, it runs add_cache_entry() with ADD_CACHE_JUST_APPEND flag
      (new), and then sort the resulting cache using qsort().
      
      This new flag tells add_cache_entry() to omit all the checks
      such as "Does this path already exist?  Does adding this path
      remove other existing entries because it turns a directory to a
      file?" and instead append the given cache entry straight at the
      end of the active cache.  The caller of course is expected to
      sort the resulting cache at the end before using the result.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      af3785dc
  17. 01 8月, 2007 3 次提交
    • J
      Clean up work-tree handling · e90fdc39
      Johannes Schindelin 提交于
      The old version of work-tree support was an unholy mess, barely readable,
      and not to the point.
      
      For example, why do you have to provide a worktree, when it is not used?
      As in "git status".  Now it works.
      
      Another riddle was: if you can have work trees inside the git dir, why
      are some programs complaining that they need a work tree?
      
      IOW it is allowed to call
      
      	$ git --git-dir=../ --work-tree=. bla
      
      when you really want to.  In this case, you are both in the git directory
      and in the working tree.  So, programs have to actually test for the right
      thing, namely if they are inside a working tree, and not if they are
      inside a git directory.
      
      Also, GIT_DIR=../.git should behave the same as if no GIT_DIR was
      specified, unless there is a repository in the current working directory.
      It does now.
      
      The logic to determine if a repository is bare, or has a work tree
      (tertium non datur), is this:
      
      --work-tree=bla overrides GIT_WORK_TREE, which overrides core.bare = true,
      which overrides core.worktree, which overrides GIT_DIR/.. when GIT_DIR
      ends in /.git, which overrides the directory in which .git/ was found.
      
      In related news, a long standing bug was fixed: when in .git/bla/x.git/,
      which is a bare repository, git formerly assumed ../.. to be the
      appropriate git dir.  This problem was reported by Shawn Pearce to have
      caused much pain, where a colleague mistakenly ran "git init" in "/" a
      long time ago, and bare repositories just would not work.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e90fdc39
    • J
      Add set_git_dir() function · d7ac12b2
      Johannes Schindelin 提交于
      With the function set_git_dir() you can reset the path that will
      be used for git_path(), git_dir() and friends.
      
      The responsibility to close files and throw away information from the
      old git_dir lies with the caller.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d7ac12b2
    • J
      Add is_absolute_path() and make_absolute_path() · e5392c51
      Johannes Schindelin 提交于
      This patch adds convenience functions to work with absolute paths.
      The function is_absolute_path() should help the efforts to integrate
      the MinGW fork.
      
      Note that make_absolute_path() returns a pointer to a static buffer.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e5392c51
  18. 22 7月, 2007 1 次提交
  19. 19 7月, 2007 1 次提交
    • C
      Rename read_pipe() with read_fd() and make its buffer nul-terminated. · c4fba0a3
      Carlos Rica 提交于
      The new name is closer to the purpose of the function.
      
      A NUL-terminated buffer makes things easier when callers need that.
      Since the function returns only the memory written with data,
      almost always allocating more space than needed because final
      size is unknown, an extra NUL terminating the buffer is harmless.
      It is not included in the returned size, so the function
      remains working as before.
      
      Also, now the function allows the buffer passed to be NULL at first,
      and alloc_nr is now used for growing the buffer, instead size=*2.
      Signed-off-by: NCarlos Rica <jasampler@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c4fba0a3
  20. 14 7月, 2007 2 次提交
  21. 13 7月, 2007 1 次提交
  22. 05 7月, 2007 1 次提交
  23. 01 7月, 2007 1 次提交
    • T
      Don't fflush(stdout) when it's not helpful · 06f59e9f
      Theodore Ts'o 提交于
      This patch arose from a discussion started by Jim Meyering's patch
      whose intention was to provide better diagnostics for failed writes.
      Linus proposed a better way to do things, which also had the added
      benefit that adding a fflush() to git-log-* operations and incremental
      git-blame operations could improve interactive respose time feel, at
      the cost of making things a bit slower when we aren't piping the
      output to a downstream program.
      
      This patch skips the fflush() calls when stdout is a regular file, or
      if the environment variable GIT_FLUSH is set to "0".  This latter can
      speed up a command such as:
      
      GIT_FLUSH=0 strace -c -f -e write time git-rev-list HEAD | wc -l
      
      a tiny amount.
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      06f59e9f
  24. 25 6月, 2007 1 次提交
    • J
      Add core.quotepath configuration variable. · 9378c161
      Junio C Hamano 提交于
      We always quote "unusual" byte values in a pathname using
      C-string style, to make it safer for parsing scripts that do not
      handle NUL separated records well (or just too lazy to bother).
      The absolute minimum bytes that need to be quoted for this
      purpose are TAB, LF (and other control characters), double quote
      and backslash.
      
      However, we have also always quoted the bytes in high 8-bit
      range; this was partly because we were lazy and partly because
      we were being cautious.
      
      This introduces an internal "quote_path_fully" variable, and
      core.quotepath configuration variable to control it.  When set
      to false, it does not quote bytes in high 8-bit range anymore
      but passes them intact.
      
      The variable defaults to "true" to retain the traditional
      behaviour for now.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9378c161
  25. 17 6月, 2007 1 次提交
    • J
      Fix ALLOC_GROW off-by-one · c927e6c6
      Jeff King 提交于
      The ALLOC_GROW macro will never let us fill the array completely,
      instead allocating an extra chunk if that would be the case. This is
      because the 'nr' argument was originally treated as "how much we do have
      now" instead of "how much do we want". The latter makes much more
      sense because you can grow by more than one item.
      
      This off-by-one never resulted in an error because it meant we were
      overly conservative about when to allocate. Any callers which passed
      "how much we have now" need to be updated, or they will fail to allocate
      enough.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c927e6c6
  26. 13 6月, 2007 3 次提交
    • J
      More static · 4175e9e3
      Junio C Hamano 提交于
      There still are quite a few symbols that ought to be static.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4175e9e3
    • J
      Extend --pretty=oneline to cover the first paragraph, · 4234a761
      Junio C Hamano 提交于
      so that an ugly commit message like this can be
      handled sanely.
      
      Currently, --pretty=oneline and --pretty=email (hence
      format-patch) take and use only the first line of the commit log
      message.  This changes them to:
      
       - Take the first paragraph, where the definition of the first
         paragraph is "skip all blank lines from the beginning, and
         then grab everything up to the next empty line".
      
       - Replace all line breaks with a whitespace.
      
      This change would not affect a well-behaved commit message that
      adheres to the convention of "single line summary, a blank line,
      and then body of message", as its first paragraph always
      consists of a single line.  Commit messages from different
      culture, such as the ones imported from CVS/SVN, can however get
      chomped with the existing behaviour at the first linebreak in
      the middle of sentence right now, which would become much easier
      to see with this change.
      
      The Subject: and --pretty=oneline output would become very long
      and unsightly for non-conforming commits, but their messages are
      already ugly anyway, and thischange at least avoids the loss of
      information.
      
      The Subject: line from a multi-line paragraph is folded using
      RFC2822 line folding rules at the places where line breaks were
      in the original.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4234a761
    • J
      refactor dir_add_name · 6815e569
      Jeff King 提交于
      This is in preparation for keeping two entry lists in the
      dir object.
      
      This patch adds and uses the ALLOC_GROW() macro, which
      implements the commonly used idiom of growing a dynamic
      array using the alloc_nr function (not just in dir.c, but
      everywhere).
      
      We also move creation of a dir_entry to dir_entry_new.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6815e569
  27. 07 6月, 2007 2 次提交
    • J
      War on whitespace · a6080a0a
      Junio C Hamano 提交于
      This uses "git-apply --whitespace=strip" to fix whitespace errors that have
      crept in to our source files over time.  There are a few files that need
      to have trailing whitespaces (most notably, test vectors).  The results
      still passes the test, and build result in Documentation/ area is unchanged.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a6080a0a
    • M
      introduce GIT_WORK_TREE to specify the work tree · 892c41b9
      Matthias Lederhofer 提交于
      setup_gdg is used as abbreviation for setup_git_directory_gently.
      
      The work tree can be specified using the environment variable
      GIT_WORK_TREE and the config option core.worktree (the environment
      variable has precendence over the config option).  Additionally
      there is a command line option --work-tree which sets the
      environment variable.
      
      setup_gdg does the following now:
      
      GIT_DIR unspecified
      repository in .git directory
          parent directory of the .git directory is used as work tree,
          GIT_WORK_TREE is ignored
      
      GIT_DIR unspecified
      repository in cwd
          GIT_DIR is set to cwd
          see the cases with GIT_DIR specified what happens next and
          also see the note below
      
      GIT_DIR specified
      GIT_WORK_TREE/core.worktree unspecified
          cwd is used as work tree
      
      GIT_DIR specified
      GIT_WORK_TREE/core.worktree specified
          the specified work tree is used
      
      Note on the case where GIT_DIR is unspecified and repository is in cwd:
          GIT_WORK_TREE is used but is_inside_git_dir is always true.
          I did it this way because setup_gdg might be called multiple
          times (e.g. when doing alias expansion) and in successive calls
          setup_gdg should do the same thing every time.
      
      Meaning of is_bare/is_inside_work_tree/is_inside_git_dir:
      
      (1) is_bare_repository
          A repository is bare if core.bare is true or core.bare is
          unspecified and the name suggests it is bare (directory not
          named .git).  The bare option disables a few protective
          checks which are useful with a working tree.  Currently
          this changes if a repository is bare:
              updates of HEAD are allowed
              git gc packs the refs
              the reflog is disabled by default
      
      (2) is_inside_work_tree
          True if the cwd is inside the associated working tree (if there
          is one), false otherwise.
      
      (3) is_inside_git_dir
          True if the cwd is inside the git directory, false otherwise.
          Before this patch is_inside_git_dir was always true for bare
          repositories.
      
      When setup_gdg finds a repository git_config(git_default_config) is
      always called.  This ensure that is_bare_repository makes use of
      core.bare and does not guess even though core.bare is specified.
      
      inside_work_tree and inside_git_dir are set if setup_gdg finds a
      repository.  The is_inside_work_tree and is_inside_git_dir functions
      will die if they are called before a successful call to setup_gdg.
      Signed-off-by: NMatthias Lederhofer <matled@gmx.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      892c41b9
  28. 31 5月, 2007 1 次提交
  29. 27 5月, 2007 1 次提交
    • S
      Lazily open pack index files on demand · d079837e
      Shawn O. Pearce 提交于
      In some repository configurations the user may have many packfiles,
      but all of the recent commits/trees/tags/blobs are likely to
      be in the most recent packfile (the one with the newest mtime).
      It is therefore common to be able to complete an entire operation
      by accessing only one packfile, even if there are 25 packfiles
      available to the repository.
      
      Rather than opening and mmaping the corresponding .idx file for
      every pack found, we now only open and map the .idx when we suspect
      there might be an object of interest in there.
      
      Of course we cannot known in advance which packfile contains an
      object, so we still need to scan the entire packed_git list to
      locate anything.  But odds are users want to access objects in the
      most recently created packfiles first, and that may be all they
      ever need for the current operation.
      
      Junio observed in b867092f that placing recent packfiles before
      older ones can slightly improve access times for recent objects,
      without degrading it for historical object access.
      
      This change improves upon Junio's observations by trying even harder
      to avoid the .idx files that we won't need.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      d079837e
  30. 22 5月, 2007 1 次提交
  31. 21 5月, 2007 1 次提交
  32. 19 5月, 2007 1 次提交
    • R
      git-archive: convert archive entries like checkouts do · 5e6cfc80
      René Scharfe 提交于
      As noted by Johan Herland, git-archive is a kind of checkout and needs
      to apply any checkout filters that might be configured.
      
      This patch adds the convenience function convert_sha1_file which returns
      a buffer containing the object's contents, after converting, if necessary
      (i.e. it's a combination of read_sha1_file and convert_to_working_tree).
      Direct calls to read_sha1_file in git-archive are then replaced by calls
      to convert_sha1_file.
      
      Since convert_sha1_file expects its path argument to be NUL-terminated --
      a convention it inherits from convert_to_working_tree -- the patch also
      changes the path handling in archive-tar.c to always NUL-terminate the
      string.  It used to solely rely on the len field of struct strbuf before.
      
      archive-zip.c already NUL-terminates the path and thus needs no such
      change.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      5e6cfc80
  33. 17 5月, 2007 1 次提交
  34. 12 5月, 2007 1 次提交
    • J
      Add has_symlink_leading_path() function. · f859c846
      Junio C Hamano 提交于
      When we are applying a patch that creates a blob at a path, or
      when we are switching from a branch that does not have a blob at
      the path to another branch that has one, we need to make sure
      that there is nothing at the path in the working tree, as such a
      file is a local modification made by the user that would be lost
      by the operation.
      
      Normally, lstat() on the path and making sure ENOENT is returned
      is good enough for that purpose.  However there is a twist.  We
      may be creating a regular file arch/x86_64/boot/Makefile, while
      removing an existing symbolic link at arch/x86_64/boot that
      points at existing ../i386/boot directory that has Makefile in
      it.  We always first check without touching filesystem and then
      perform the actual operation, so when we verify the new file,
      arch/x86_64/boot/Makefile, does not exist, we haven't removed
      the symbolic link arc/x86_64/boot symbolic link yet.  lstat() on
      the file sees through the symbolic link and reports the file is
      there, which is not what we want.
      
      The function has_symlink_leading_path() function takes a path,
      and sees if any of the leading directory component is a symbolic
      link.
      
      When files in a new directory are created, we tend to process
      them together because both index and tree are sorted.  The
      function takes advantage of this and allows the caller to cache
      and reuse which symbolic link on the filesystem caused the
      function to return true.
      
      The calling sequence would be:
      
      	char last_symlink[PATH_MAX];
      
              *last_symlink = '\0';
              for each index entry {
      		if (!lose)
      			continue;
      		if (lstat(it))
      			if (errno == ENOENT)
      				; /* happy */
      			else
      				error;
      		else if (has_symlink_leading_path(it, last_symlink))
      			; /* happy */
      		else
      			error; /* would lose local changes */
      		unlink_entry(it, last_symlink);
      	}
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      f859c846