1. 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
  2. 13 6月, 2007 2 次提交
    • 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
  3. 07 6月, 2007 1 次提交
    • 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
  4. 31 5月, 2007 1 次提交
  5. 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
  6. 22 5月, 2007 1 次提交
  7. 21 5月, 2007 1 次提交
  8. 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
  9. 17 5月, 2007 1 次提交
  10. 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
  11. 11 5月, 2007 2 次提交
    • D
      Custom compression levels for objects and packs · 960ccca6
      Dana How 提交于
      Add config variables pack.compression and core.loosecompression ,
      and switch --compression=level to pack-objects.
      
      Loose objects will be compressed using core.loosecompression if set,
      else core.compression if set, else Z_BEST_SPEED.
      Packed objects will be compressed using --compression=level if seen,
      else pack.compression if set, else core.compression if set,
      else Z_DEFAULT_COMPRESSION.  This is the "pack compression level".
      
      Loose objects added to a pack undeltified will be recompressed
      to the pack compression level if it is unequal to the current
      loose compression level by the preceding rules,  or if the loose
      object was written while core.legacyheaders = true.  Newly
      deltified loose objects are always compressed to the current
      pack compression level.
      
      Previously packed objects added to a pack are recompressed
      to the current pack compression level exactly when their
      deltification status changes,  since the previous pack data
      cannot be reused.
      
      In either case,  the --no-reuse-object switch from the first
      patch below will always force recompression to the current pack
      compression level,  instead of assuming the pack compression level
      hasn't changed and pack data can be reused when possible.
      
      This applies on top of the following patches from Nicolas Pitre:
      [PATCH] allow for undeltified objects not to be reused
      [PATCH] make "repack -f" imply "pack-objects --no-reuse-object"
      Signed-off-by: NDana L. How <danahow@gmail.com>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      960ccca6
    • N
      deprecate the new loose object header format · 726f852b
      Nicolas Pitre 提交于
      Now that we encourage and actively preserve objects in a packed form
      more agressively than we did at the time the new loose object format and
      core.legacyheaders were introduced, that extra loose object format
      doesn't appear to be worth it anymore.
      
      Because the packing of loose objects has to go through the delta match
      loop anyway, and since most of them should end up being deltified in
      most cases, there is really little advantage to have this parallel loose
      object format as the CPU savings it might provide is rather lost in the
      noise in the end.
      
      This patch gets rid of core.legacyheaders, preserve the legacy format as
      the only writable loose object format and deprecate the other one to
      keep things simpler.
      Signed-off-by: NNicolas Pitre <nico@cam.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      726f852b
  12. 26 4月, 2007 2 次提交
  13. 24 4月, 2007 2 次提交
  14. 23 4月, 2007 2 次提交
    • J
      Make read-cache.c "the_index" free. · 4aab5b46
      Junio C Hamano 提交于
      This makes all low-level functions defined in read-cache.c to
      take an explicit index_state structure as their first parameter,
      to specify which index to work on.  These functions
      traditionally operated on "the_index" and were named foo_cache();
      the counterparts this patch introduces are called foo_index().
      
      The traditional foo_cache() functions are made into macros that
      give "the_index" to their corresponding foo_index() functions.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      4aab5b46
    • J
      Move index-related variables into a structure. · 228e94f9
      Junio C Hamano 提交于
      This defines a index_state structure and moves index-related
      global variables into it.  Currently there is one instance of
      it, the_index, and everybody accesses it, so there is no code
      change.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      228e94f9
  15. 22 4月, 2007 1 次提交
    • J
      lockfile: record the primary process. · 5e635e39
      Junio C Hamano 提交于
      The usual process flow is the main process opens and holds the lock to
      the index, does its thing, perhaps spawning children during the course,
      and then writes the resulting index out by releaseing the lock.
      
      However, the lockfile interface uses atexit(3) to clean it up, without
      regard to who actually created the lock.  This typically leads to a
      confusing behaviour of lock being released too early when the child
      exits, and then the parent process when it calls commit_lockfile()
      finds that it cannot unlock it.
      
      This fixes the problem by recording who created and holds the lock, and
      upon atexit(3) handler, child simply ignores the lockfile the parent
      created.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      5e635e39
  16. 21 4月, 2007 1 次提交
  17. 18 4月, 2007 1 次提交
  18. 17 4月, 2007 3 次提交
  19. 16 4月, 2007 1 次提交
    • J
      attribute macro support · f48fd688
      Junio C Hamano 提交于
      This adds "attribute macros" (for lack of better name).  So far,
      we have low-level attributes such as crlf and diff, which are
      defined in operational terms --- setting or unsetting them on a
      particular path directly affects what is done to the path.  For
      example, in order to decline diffs or crlf conversions on a
      binary blob, no diffs on PostScript files, and treat all other
      files normally, you would have something like these:
      
      	*		diff crlf
      	*.ps		!diff
      	proprietary.o	!diff !crlf
      
      That is fine as the operation goes, but gets unwieldy rather
      rapidly, when we start adding more low-level attributes that are
      defined in operational terms.  A near-term example of such an
      attribute would be 'merge-3way' which would control if git
      should attempt the usual 3-way file-level merge internally, or
      leave merging to a specialized external program of user's
      choice.  When it is added, we do _not_ want to force the users
      to update the above to:
      
      	*		diff crlf merge-3way
      	*.ps		!diff
      	proprietary.o	!diff !crlf !merge-3way
      
      The way this patch solves this issue is to realize that the
      attributes the user is assigning to paths are not defined in
      terms of operations but in terms of what they are.
      
      All of the three low-level attributes usually make sense for
      most of the files that sane SCM users have git operate on (these
      files are typically called "text').  Only a few cases, such as
      binary blob, need exception to decline the "usual treatment
      given to text files" -- and people mark them as "binary".
      
      So this allows the $GIT_DIR/info/alternates and .gitattributes
      at the toplevel of the project to also specify attributes that
      assigns other attributes.  The syntax is '[attr]' followed by an
      attribute name followed by a list of attribute names:
      
      	[attr] binary	!diff !crlf !merge-3way
      
      When "binary" attribute is set to a path, if the path has not
      got diff/crlf/merge-3way attribute set or unset by other rules,
      this rule unsets the three low-level attributes.
      
      It is expected that the user level .gitattributes will be
      expressed mostly in terms of attributes based on what the files
      are, and the above sample would become like this:
      
      	(built-in attribute configuration)
      	[attr] binary	!diff !crlf !merge-3way
      	*		diff crlf merge-3way
      
      	(project specific .gitattributes)
      	proprietary.o	binary
      
      	(user preference $GIT_DIR/info/attributes)
      	*.ps		!diff
      
      There are a few caveats.
      
       * As described above, you can define these macros only in
         $GIT_DIR/info/attributes and toplevel .gitattributes.
      
       * There is no attempt to detect circular definition of macro
         attributes, and definitions are evaluated from bottom to top
         as usual to fill in other attributes that have not yet got
         values.  The following would work as expected:
      
      	[attr] text	diff crlf
      	[attr] ps	text !diff
      	*.ps	ps
      
         while this would most likely not (I haven't tried):
      
      	[attr] ps	text !diff
      	[attr] text	diff crlf
      	*.ps	ps
      
       * When a macro says "[attr] A B !C", saying that a path does
         not have attribute A does not let you tell anything about
         attributes B or C.  That is, given this:
      
      	[attr] text	diff crlf
      	[attr] ps	text !diff
      	*.txt !ps
      
        path hello.txt, which would match "*.txt" pattern, would have
        "ps" attribute set to zero, but that does not make text
        attribute of hello.txt set to false (nor diff attribute set to
        true).
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      f48fd688
  20. 14 4月, 2007 1 次提交
    • J
      Add basic infrastructure to assign attributes to paths · d0bfd026
      Junio C Hamano 提交于
      This adds the basic infrastructure to assign attributes to
      paths, in a way similar to what the exclusion mechanism does
      based on $GIT_DIR/info/exclude and .gitignore files.
      
      An attribute is just a simple string that does not contain any
      whitespace.  They can be specified in $GIT_DIR/info/attributes
      file, and .gitattributes file in each directory.
      
      Each line in these files defines a pattern matching rule.
      Similar to the exclusion mechanism, a later match overrides an
      earlier match in the same file, and entries from .gitattributes
      file in the same directory takes precedence over the ones from
      parent directories.  Lines in $GIT_DIR/info/attributes file are
      used as the lowest precedence default rules.
      
      A line is either a comment (an empty line, or a line that begins
      with a '#'), or a rule, which is a whitespace separated list of
      tokens.  The first token on the line is a shell glob pattern.
      The rest are names of attributes, each of which can optionally
      be prefixed with '!'.  Such a line means "if a path matches this
      glob, this attribute is set (or unset -- if the attribute name
      is prefixed with '!').  For glob matching, the same "if the
      pattern does not have a slash in it, the basename of the path is
      matched with fnmatch(3) against the pattern, otherwise, the path
      is matched with the pattern with FNM_PATHNAME" rule as the
      exclusion mechanism is used.
      
      This does not define what an attribute means.  Tying an
      attribute to various effects it has on git operation for paths
      that have it will be specified separately.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      d0bfd026
  21. 11 4月, 2007 3 次提交
  22. 07 4月, 2007 1 次提交
    • J
      A new merge stragety 'subtree'. · 68faf689
      Junio C Hamano 提交于
      This merge strategy largely piggy-backs on git-merge-recursive.
      When merging trees A and B, if B corresponds to a subtree of A,
      B is first adjusted to match the tree structure of A, instead of
      reading the trees at the same level.  This adjustment is also
      done to the common ancestor tree.
      
      If you are pulling updates from git-gui repository into git.git
      repository, the root level of the former corresponds to git-gui/
      subdirectory of the latter.  The tree object of git-gui's toplevel
      is wrapped in a fake tree object, whose sole entry has name 'git-gui'
      and records object name of the true tree, before being used by
      the 3-way merge code.
      
      If you are merging the other way, only the git-gui/ subtree of
      git.git is extracted and merged into git-gui's toplevel.
      
      The detection of corresponding subtree is done by comparing the
      pathnames and types in the toplevel of the tree.
      
      Heuristics galore!  That's the git way ;-).
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      68faf689
  23. 06 4月, 2007 3 次提交
  24. 04 4月, 2007 2 次提交
    • J
      git-read-tree --index-output=<file> · 5e7f56ac
      Junio C Hamano 提交于
      This corrects the interface mistake of the previous one, and
      gives a command line parameter to the only plumbing command that
      currently needs it: "git-read-tree".
      
      We can add the calls to set_alternate_index_output() to other
      plumbing commands that update the index if/when needed.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      5e7f56ac
    • J
      _GIT_INDEX_OUTPUT: allow plumbing to output to an alternative index file. · 30ca07a2
      Junio C Hamano 提交于
      When defined, this allows plumbing commands that update the
      index (add, apply, checkout-index, merge-recursive, mv,
      read-tree, rm, update-index, and write-tree) to write their
      resulting index to an alternative index file while holding a
      lock to the original index file.  With this, git-commit that
      jumps the index does not have to make an extra copy of the index
      file, and more importantly, it can do the update while holding
      the lock on the index.
      
      However, I think the interface to let an environment variable
      specify the output is a mistake, as shown in the documentation.
      If a curious user has the environment variable set to something
      other than the file GIT_INDEX_FILE points at, almost everything
      will break.  This should instead be a command line parameter to
      tell these plumbing commands to write the result in the named
      file, to prevent stupid mistakes.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      30ca07a2
  25. 21 3月, 2007 1 次提交
  26. 19 3月, 2007 1 次提交
    • S
      Limit the size of the new delta_base_cache · 18bdec11
      Shawn O. Pearce 提交于
      The new configuration variable core.deltaBaseCacheLimit allows the
      user to control how much memory they are willing to give to Git for
      caching base objects of deltas.  This is not normally meant to be
      a user tweakable knob; the "out of the box" settings are meant to
      be suitable for almost all workloads.
      
      We default to 16 MiB under the assumption that the cache is not
      meant to consume all of the user's available memory, and that the
      cache's main purpose was to cache trees, for faster path limiters
      during revision traversal.  Since trees tend to be relatively small
      objects, this relatively small limit should still allow a large
      number of objects.
      
      On the other hand we don't want the cache to start storing 200
      different versions of a 200 MiB blob, as this could easily blow
      the entire address space of a 32 bit process.
      
      We evict OBJ_BLOB from the cache first (credit goes to Junio) as
      we want to favor OBJ_TREE within the cache.  These are the objects
      that have the highest inflate() startup penalty, as they tend to
      be small and thus don't have that much of a chance to ammortize
      that penalty over the entire data.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      18bdec11
  27. 17 3月, 2007 1 次提交
    • N
      [PATCH] clean up pack index handling a bit · 42873078
      Nicolas Pitre 提交于
      Especially with the new index format to come, it is more appropriate
      to encapsulate more into check_packed_git_idx() and assume less of the
      index format in struct packed_git.
      
      To that effect, the index_base is renamed to index_data with void * type
      so it is not used directly but other pointers initialized with it. This
      allows for a couple pointer cast removal, as well as providing a better
      generic name to grep for when adding support for new index versions or
      formats.
      
      And index_data is declared const too while at it.
      Signed-off-by: NNicolas Pitre <nico@cam.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      42873078
  28. 13 3月, 2007 1 次提交