1. 16 11月, 2010 3 次提交
  2. 13 11月, 2010 1 次提交
    • N
      add: do not rely on dtype being NULL behavior · 0188f6b3
      Nguyễn Thái Ngọc Duy 提交于
      Commit c84de707 (excluded_1(): support exclude files in index -
      2009-08-20) added support for excluded() where dtype can be NULL. It
      was designed specifically for index matching because there was no
      other way to extract dtype information from index. It did not support
      wildcard matching (for example, "a*/" pattern would fail to match).
      
      The code was probably misread when commit 108da0db (git add: Add the
      "--ignore-missing" option for the dry run - 2010-07-10) was made
      because DT_UNKNOWN happens to be zero (NULL) too.
      
      Do not pass DT_UNKNOWN/NULL to excluded(), instead pass a pointer to a
      variable that contains DT_UNKNOWN. The real dtype will be extracted
      from worktree by excluded(), as expected.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0188f6b3
  3. 13 7月, 2010 1 次提交
  4. 01 6月, 2010 1 次提交
    • G
      Rewrite dynamic structure initializations to runtime assignment · 66dbfd55
      Gary V. Vaughan 提交于
      Unfortunately, there are still plenty of production systems with
      vendor compilers that choke unless all compound declarations can be
      determined statically at compile time, for example hpux10.20 (I can
      provide a comprehensive list of our supported platforms that exhibit
      this problem if necessary).
      
      This patch simply breaks apart any compound declarations with dynamic
      initialisation expressions, and moves the initialisation until after
      the last declaration in the same block, in all the places necessary to
      have the offending compilers accept the code.
      Signed-off-by: NGary V. Vaughan <gary@thewrittenword.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      66dbfd55
  5. 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
  6. 17 2月, 2010 1 次提交
  7. 22 1月, 2010 1 次提交
    • L
      Remove diff machinery dependency from read-cache · fb7d3f32
      Linus Torvalds 提交于
      Exal Sibeaz pointed out that some git files are way too big, and that
      add_files_to_cache() brings in all the diff machinery to any git binary
      that needs the basic git SHA1 object operations from read-cache.c. Which
      is pretty much all of them.
      
      It's doubly silly, since add_files_to_cache() is only used by builtin
      programs (add, checkout and commit), so it's fairly easily fixed by just
      moving the thing to builtin-add.c, and avoiding the dependency entirely.
      
      I initially argued to Exal that it would probably be best to try to depend
      on smart compilers and linkers, but after spending some time trying to
      make -ffunction-sections work and giving up, I think Exal was right, and
      the fix is to just do some trivial cleanups like this.
      
      This trivial cleanup results in pretty stunning file size differences.
      The diff machinery really is mostly used by just the builtin programs, and
      you have things like these trivial before-and-after numbers:
      
        -rwxr-xr-x 1 torvalds torvalds 1727420 2010-01-21 10:53 git-hash-object
        -rwxrwxr-x 1 torvalds torvalds  940265 2010-01-21 11:16 git-hash-object
      
      Now, I'm not saying that 940kB is good either, but that's mostly all the
      debug information - you can see the real code with 'size':
      
         text	   data	    bss	    dec	    hex	filename
       418675	   3920	 127408	 550003	  86473	git-hash-object (before)
       230650	   2288	 111728	 344666	  5425a	git-hash-object (after)
      
      ie we have a nice 24% size reduction from this trivial cleanup.
      
      It's not just that one file either. I get:
      
      	[torvalds@nehalem git]$ du -s /home/torvalds/libexec/git-core
      	45640	/home/torvalds/libexec/git-core (before)
      	33508	/home/torvalds/libexec/git-core (after)
      
      so we're talking 12MB of diskspace here.
      
      (Of course, stripping all the binaries brings the 33MB down to 9MB, so the
      whole debug information thing is still the bulk of it all, but that's a
      separate issue entirely)
      
      Now, I'm sure there are other things we should do, and changing our
      compiler flags from -O2 to -Os would bring the text size down by an
      additional almost 20%, but this thing Exal pointed out seems to be some
      good low-hanging fruit.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fb7d3f32
  8. 13 9月, 2009 1 次提交
  9. 22 8月, 2009 2 次提交
  10. 15 8月, 2009 1 次提交
  11. 09 7月, 2009 1 次提交
    • L
      Add 'fill_directory()' helper function for directory traversal · 1d8842d9
      Linus Torvalds 提交于
      Most of the users of "read_directory()" actually want a much simpler
      interface than the whole complex (but rather powerful) one.
      
      In fact 'git add' had already largely abstracted out the core interface
      issues into a private "fill_directory()" function that was largely
      applicable almost as-is to a number of callers.  Yes, 'git add' wants to
      do some extra work of its own, specific to the add semantics, but we can
      easily split that out, and use the core as a generic function.
      
      This function does exactly that, and now that much simplified
      'fill_directory()' function can be shared with a number of callers,
      while also ensuring that the rather more complex calling conventions of
      read_directory() are used by fewer call-sites.
      
      This also makes the 'common_prefix()' helper function private to dir.c,
      since all callers are now in that file.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1d8842d9
  12. 28 6月, 2009 1 次提交
    • T
      Use die_errno() instead of die() when checking syscalls · 0721c314
      Thomas Rast 提交于
      Lots of die() calls did not actually report the kind of error, which
      can leave the user confused as to the real problem.  Use die_errno()
      where we check a system/library call that sets errno on failure, or
      one of the following that wrap such calls:
      
        Function              Passes on error from
        --------              --------------------
        odb_pack_keep         open
        read_ancestry         fopen
        read_in_full          xread
        strbuf_read           xread
        strbuf_read_file      open or strbuf_read_file
        strbuf_readlink       readlink
        write_in_full         xwrite
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0721c314
  13. 21 6月, 2009 1 次提交
    • L
      Fix various sparse warnings in the git source code · 2af202be
      Linus Torvalds 提交于
      There are a few remaining ones, but this fixes the trivial ones. It boils
      down to two main issues that sparse complains about:
      
       - warning: Using plain integer as NULL pointer
      
         Sparse doesn't like you using '0' instead of 'NULL'. For various good
         reasons, not the least of which is just the visual confusion. A NULL
         pointer is not an integer, and that whole "0 works as NULL" is a
         historical accident and not very pretty.
      
         A few of these remain: zlib is a total mess, and Z_NULL is just a 0.
         I didn't touch those.
      
       - warning: symbol 'xyz' was not declared. Should it be static?
      
         Sparse wants to see declarations for any functions you export. A lack
         of a declaration tends to mean that you should either add one, or you
         should mark the function 'static' to show that it's in file scope.
      
         A few of these remain: I only did the ones that should obviously just
         be made static.
      
      That 'wt_status_submodule_summary' one is debatable. It has a few related
      flags (like 'wt_status_use_color') which _are_ declared, and are used by
      builtin-commit.c. So maybe we'd like to export it at some point, but it's
      not declared now, and not used outside of that file, so 'static' it is in
      this patch.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2af202be
  14. 19 6月, 2009 1 次提交
  15. 25 5月, 2009 1 次提交
  16. 09 5月, 2009 1 次提交
    • J
      add: don't complain when adding empty project root · 07d7bedd
      Jeff King 提交于
      We try to warn the user if one of their pathspecs caused no
      matches, as it may have been a typo. However, we disable the
      warning if the pathspec points to an existing file, since
      that means it is not a typo but simply an empty directory.
      
      Unfortunately, the file_exists() test was broken for one
      special case: the pathspec of the project root is just "".
      This patch detects this special case and acts as if the file
      exists (which it must, since it is the project root).
      
      The user-visible effect is that this:
      
        $ mkdir repo && cd repo && git init && git add .
      
      used to complain like:
      
        fatal: pathspec '' did not match any files
      
      but now is a silent no-op.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      07d7bedd
  17. 13 4月, 2009 1 次提交
    • J
      git-add: introduce --edit (to edit the diff vs. the index) · c59cb03a
      Johannes Schindelin 提交于
      With "git add -e [<files>]", Git will fire up an editor with the current
      diff relative to the index (i.e. what you would get with "git diff
      [<files>]").
      
      Now you can edit the patch as much as you like, including adding/removing
      lines, editing the text, whatever.  Make sure, though, that the first
      character of the hunk lines is still a space, a plus or a minus.
      
      After you closed the editor, Git will adjust the line counts of the hunks
      if necessary, thanks to the --recount option of apply, and commit the
      patch.  Except if you deleted everything, in which case nothing happens
      (for obvious reasons).
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c59cb03a
  18. 25 2月, 2009 1 次提交
  19. 19 2月, 2009 1 次提交
  20. 10 2月, 2009 1 次提交
  21. 06 1月, 2009 1 次提交
  22. 11 12月, 2008 1 次提交
  23. 01 9月, 2008 1 次提交
    • J
      git-add --intent-to-add (-N) · 39425819
      Junio C Hamano 提交于
      This adds "--intent-to-add" option to "git add".  This is to let the
      system know that you will tell it the final contents to be staged later,
      iow, just be aware of the presense of the path with the type of the blob
      for now.  It is implemented by staging an empty blob as the content.
      
      With this sequence:
      
          $ git reset --hard
          $ edit newfile
          $ git add -N newfile
          $ edit newfile oldfile
          $ git diff
      
      the diff will show all changes relative to the current commit.  Then you
      can do:
      
          $ git commit -a ;# commit everything
      
      or
      
          $ git commit oldfile ;# only oldfile, newfile not yet added
      
      to pretend you are working with an index-free system like CVS.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      39425819
  24. 05 8月, 2008 1 次提交
  25. 26 7月, 2008 2 次提交
    • J
      builtin-add.c: optimize -A option and "git add ." · 1e5f764c
      Junio C Hamano 提交于
      The earlier "git add -A" change was done in a quite inefficient
      way (i.e. it is as unefficient as "git add -u && git add ." modulo
      one fork/exec and read/write index).
      
      When the user asks "git add .", we do not have to examine all paths
      we encounter and perform the excluded() and dir_add_name()
      processing, both of which are slower code and use slower data structure
      by git standards, especially when the index is already populated.
      
      Instead, we implement "git add $pathspec..." as:
      
       - read the index;
      
       - read_directory() to process untracked, unignored files the current
         way, that is, recursively doing readdir(), filtering them by pathspec
         and excluded(), queueing them via dir_add_name() and finally do
         add_files(); and
      
       - iterate over the index, filtering them by pathspec, and update only
         the modified/type changed paths but not deleted ones.
      
      And "git add -A" becomes exactly the same as above, modulo:
      
       - missing $pathspec means "." instead of being an error; and
      
       - "iterate over the index" part handles deleted ones as well,
         i.e. exactly what the current update_callback() in builtin-add.c does.
      
      In either case, because fill_directory() does not use read_directory() to
      read everything in, we need to add an extra logic to iterate over the
      index to catch mistyped pathspec.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1e5f764c
    • J
      builtin-add.c: restructure the code for maintainability · 041aee31
      Junio C Hamano 提交于
      A private function add_files_to_cache() in builtin-add.c was borrowed by
      checkout and commit re-implementors without getting properly refactored to
      more library-ish place.  This does the refactoring.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      041aee31
  26. 21 7月, 2008 1 次提交
    • J
      "needs update" considered harmful · d14e7407
      Junio C Hamano 提交于
      "git update-index --refresh", "git reset" and "git add --refresh" have
      reported paths that have local modifications as "needs update" since the
      beginning of git.
      
      Although this is logically correct in that you need to update the index at
      that path before you can commit that change, it is now becoming more and
      more clear, especially with the continuous push for user friendliness
      since 1.5.0 series, that the message is suboptimal.  After all, the change
      may be something the user might want to get rid of, and "updating" would
      be absolutely a wrong thing to do if that is the case.
      
      I prepared two alternatives to solve this.  Both aim to reword the message
      to more neutral "locally modified".
      
      This patch is a more intrusive variant that changes the message for only
      Porcelain commands ("add" and "reset") while keeping the plumbing
      "update-index" intact.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d14e7407
  27. 20 7月, 2008 2 次提交
    • J
      git-add --all: add all files · 3ba1f114
      Junio C Hamano 提交于
      People sometimes find that "git add -u && git add ." are 13 keystrokes too
      many.  This reduces it by nine.
      
      The support of this has been very low priority for me personally, because
      I almost never do "git add ." in a directory with already tracked files,
      and in a new directory, there is no point saying "git add -u".
      
      However, for two types of people (that are very different from me), this
      mode of operation may make sense and there is no reason to leave it
      unsupported.  That is:
      
       (1) If you are extremely well disciplined and keep perfect .gitignore, it
           always is safe to say "git add ."; or
      
       (2) If you are extremely undisciplined and do not even know what files
           you created, and you do not very much care what goes in your history,
           it does not matter if "git add ." included everything.
      
      So there it is, although I suspect I will not use it myself, ever.
      
      It will be too much of a change that is against the expectation of the
      existing users to allow "git commit -a" to include untracked files, and
      it would be inconsistent if we named this new option "-a", so the short
      option is "-A".  We _might_ want to later add "git commit -A" but that is
      a separate topic.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3ba1f114
    • J
      builtin-add.c: restructure the code for maintainability · c972ec04
      Junio C Hamano 提交于
      The implementation of "git add" has four major codepaths that are mutually
      exclusive:
      
       - if "--interactive" or "--patch" is given, spawn "git add--interactive"
         and exit without doing anything else.  Otherwise things are handled
         internally in this C code;
      
       - if "--update" is given, update the modified files and exit without
         doing anything else;
      
       - if "--refresh" is given, do refresh and exit without doing anything
         else;
      
       - otherwise, find the paths that match pathspecs and stage their
         contents.
      
      It led to an unholy mess in the code structure; each of the latter three
      codepaths has a separate call to read_cache(), even though they are all
      about "read the current index, update it and write it back", and logically
      they should read the index once _anyway_.
      
      This cleans up the latter three cases by introducing a pair of helper
      variables:
      
       - "add_new_files" is set if we need to scan the working tree for paths
         that match the pathspec.  This variable is false for "--update" and
         "--refresh", because they only work on already tracked files.
      
       - "require_pathspec" is set if the user must give at least one pathspec.
         "--update" does not need it but all the other cases do.
      
      This is in preparation for introducing a new option "--all", that does the
      equivalent of "git add -u && git add ." (aka "addremove").
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c972ec04
  28. 14 7月, 2008 1 次提交
    • S
      Make usage strings dash-less · 1b1dd23f
      Stephan Beyer 提交于
      When you misuse a git command, you are shown the usage string.
      But this is currently shown in the dashed form.  So if you just
      copy what you see, it will not work, when the dashed form
      is no longer supported.
      
      This patch makes git commands show the dash-less version.
      
      For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh
      generates a dash-less usage string now.
      Signed-off-by: NStephan Beyer <s-beyer@gmx.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1b1dd23f
  29. 15 6月, 2008 1 次提交
  30. 24 5月, 2008 1 次提交
    • G
      Make git add -n and git -u -n output consistent · 205ffa94
      Gustaf Hendeby 提交于
      Output format from "git add -n $path" lists path to blobs that are going
      to be added on a single line, separated with SP.  On the other hand, the
      suggested "git add -u -n" shows one path per line, like "add '<file>'\n".
      Of course, these two are inconsistent.
      
      Plain "git add -n" can afford to only say names of paths, as all it does
      is to add (update).  However, "git add -u" needs to be able to express
      "remove" somehow.  So if we need to have them formatted the same way, we
      need to unify with the "git add -n -u" format.  Incidentally, this is
      consistent with how 'update-index' says it.
      
      This changes the output from "git add -n $paths" but as a general
      principle, output from Porcelain commands is a fair game for improvements
      and not for script consumption.
      Signed-off-by: NGustaf Hendeby <hendeby@isy.liu.se>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      205ffa94
  31. 22 5月, 2008 1 次提交
  32. 15 5月, 2008 1 次提交
  33. 13 5月, 2008 3 次提交