1. 13 9月, 2010 1 次提交
    • J
      log --author: take union of multiple "author" requests · 5aaeb733
      Junio C Hamano 提交于
      In the olden days,
      
          log --author=me --committer=him --grep=this --grep=that
      
      used to be turned into:
      
          (OR (HEADER-AUTHOR me)
              (HEADER-COMMITTER him)
              (PATTERN this)
              (PATTERN that))
      
      showing my patches that do not have any "this" nor "that", which was
      totally useless.
      
      80235ba7 ("log --author=me --grep=it" should find intersection, not union,
      2010-01-17) improved it greatly to turn the same into:
      
          (ALL-MATCH
            (HEADER-AUTHOR me)
            (HEADER-COMMITTER him)
            (OR (PATTERN this) (PATTERN that)))
      
      That is, "show only patches by me and committed by him, that have either
      this or that", which is a lot more natural thing to ask.
      
      We however need to be a bit more clever when the user asks more than one
      "author" (or "committer"); because a commit has only one author (and one
      committer), they ought to be interpreted as asking for union to be useful.
      The current implementation simply added another author/committer pattern
      at the same top-level for ALL-MATCH to insist on matching all, finding
      nothing.
      
      Turn
      
          log --author=me --author=her \
          	--committer=him --committer=you \
      	--grep=this --grep=that
      
      into
      
          (ALL-MATCH
            (OR (HEADER-AUTHOR me) (HEADER-AUTHOR her))
            (OR (HEADER-COMMITTER him) (HEADER-COMMITTER you))
            (OR (PATTERN this) (PATTERN that)))
      
      instead.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5aaeb733
  2. 21 7月, 2010 1 次提交
  3. 14 6月, 2010 1 次提交
  4. 01 6月, 2010 1 次提交
  5. 14 2月, 2010 1 次提交
  6. 08 2月, 2010 1 次提交
    • J
      accept "git grep -- pattern" · 1123c67c
      Jeff King 提交于
      Currently the only way to "quote" a grep pattern that might
      begin with a dash is to use "git grep -e pattern". This
      works just fine, and is also the way right way to do it on
      many traditional grep implemenations.
      
      Some people prefer to use "git grep -- pattern", however, as
      "--" is the usual "end of options" marker, and at least GNU
      grep and Solaris 10 grep support this. This patch makes that
      syntax work.
      
      There is a slight behavior change, in that "git grep -- $X"
      used to be interpreted as "grep for -- in $X". However, that
      usage is questionable. "--" is usually the end-of-options
      marker, so "git grep" was unlike many other greps in
      treating it as a literal pattern (e.g., both GNU grep and
      Solaris 10 grep will treat "grep --" as missing a pattern).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1123c67c
  7. 06 2月, 2010 1 次提交
  8. 29 1月, 2010 1 次提交
  9. 26 1月, 2010 1 次提交
    • J
      "log --author=me --grep=it" should find intersection, not union · 80235ba7
      Junio C Hamano 提交于
      Historically, any grep filter in "git log" family of commands were taken
      as restricting to commits with any of the words in the commit log message.
      However, the user almost always want to find commits "done by this person
      on that topic".  With "--all-match" option, a series of grep patterns can
      be turned into a requirement that all of them must produce a match, but
      that makes it impossible to ask for "done by me, on either this or that"
      with:
      
      	log --author=me --committer=him --grep=this --grep=that
      
      because it will require both "this" and "that" to appear.
      
      Change the "header" parser of grep library to treat the headers specially,
      and parse it as:
      
      	(all-match-OR (HEADER-AUTHOR me)
      		      (HEADER-COMMITTER him)
      		      (OR
      		      	(PATTERN this)
      			(PATTERN that) ) )
      
      Even though the "log" command line parser doesn't give direct access to
      the extended grep syntax to group terms with parentheses, this change will
      cover the majority of the case the users would want.
      
      This incidentally revealed that one test in t7002 was bogus.  It ran:
      
      	log --author=Thor --grep=Thu --format='%s'
      
      and expected (wrongly) "Thu" to match "Thursday" in the author/committer
      date, but that would never match, as the timestamp in raw commit buffer
      does not have the name of the day-of-the-week.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      80235ba7
  10. 19 1月, 2010 1 次提交
    • J
      Fix mis-backport of t7002 · 8de65185
      Junio C Hamano 提交于
      The original patch that became cfe370c6 (grep: do not segfault when -f is
      used, 2009-10-16), was made against "maint" or newer branch back then, but
      the fix addressed the issue that was present as far as in 1.6.4 series.
      
      The maintainer backported the patch to the 1.6.4 maintenance branch, but
      failed to notice that the new tests assumed the setup done by the script
      in "maint", which did quite a lot more than the same test script in 1.6.4
      series, and the output didn't match the expected result.
      
      This should fix it.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8de65185
  11. 16 1月, 2010 1 次提交
  12. 13 1月, 2010 1 次提交
  13. 07 1月, 2010 2 次提交
  14. 23 11月, 2009 1 次提交
  15. 17 11月, 2009 1 次提交
  16. 17 10月, 2009 1 次提交
  17. 08 9月, 2009 1 次提交
  18. 23 7月, 2009 1 次提交
    • M
      grep: Add --max-depth option. · a91f453f
      Michał Kiedrowicz 提交于
      It is useful to grep directories non-recursively, e.g. when one wants to
      look for all files in the toplevel directory, but not in any subdirectory,
      or in Documentation/, but not in Documentation/technical/.
      
      This patch adds support for --max-depth <depth> option to git-grep. If it is
      given, git-grep descends at most <depth> levels of directories below paths
      specified on the command line.
      
      Note that if path specified on command line contains wildcards, this option
      makes no sense, e.g.
      
          $ git grep -l --max-depth 0 GNU -- 'contrib/*'
      
      (note the quotes) will search all files in contrib/, even in
      subdirectories, because '*' matches all files.
      
      Documentation updates, bash-completion and simple test cases are also
      provided.
      Signed-off-by: NMichał Kiedrowicz <michal.kiedrowicz@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a91f453f
  19. 02 7月, 2009 3 次提交
  20. 28 6月, 2009 1 次提交
  21. 24 5月, 2009 1 次提交
  22. 28 4月, 2009 1 次提交
  23. 28 12月, 2008 1 次提交
  24. 01 10月, 2008 1 次提交
  25. 05 9月, 2008 1 次提交
    • J
      log --author/--committer: really match only with name part · a4d7d2c6
      Junio C Hamano 提交于
      When we tried to find commits done by AUTHOR, the first implementation
      tried to pattern match a line with "^author .*AUTHOR", which later was
      enhanced to strip leading caret and look for "^author AUTHOR" when the
      search pattern was anchored at the left end (i.e. --author="^AUTHOR").
      
      This had a few problems:
      
       * When looking for fixed strings (e.g. "git log -F --author=x --grep=y"),
         the regexp internally used "^author .*x" would never match anything;
      
       * To match at the end (e.g. "git log --author='google.com>$'"), the
         generated regexp has to also match the trailing timestamp part the
         commit header lines have.  Also, in order to determine if the '$' at
         the end means "match at the end of the line" or just a literal dollar
         sign (probably backslash-quoted), we would need to parse the regexp
         ourselves.
      
      An earlier alternative tried to make sure that a line matches "^author "
      (to limit by field name) and the user supplied pattern at the same time.
      While it solved the -F problem by introducing a special override for
      matching the "^author ", it did not solve the trailing timestamp nor tail
      match problem.  It also would have matched every commit if --author=author
      was asked for, not because the author's email part had this string, but
      because every commit header line that talks about the author begins with
      that field name, regardleses of who wrote it.
      
      Instead of piling more hacks on top of hacks, this rethinks the grep
      machinery that is used to look for strings in the commit header, and makes
      sure that (1) field name matches literally at the beginning of the line,
      followed by a SP, and (2) the user supplied pattern is matched against the
      remainder of the line, excluding the trailing timestamp data.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a4d7d2c6
  26. 02 2月, 2008 1 次提交
    • J
      Sane use of test_expect_failure · 41ac414e
      Junio C Hamano 提交于
      Originally, test_expect_failure was designed to be the opposite
      of test_expect_success, but this was a bad decision.  Most tests
      run a series of commands that leads to the single command that
      needs to be tested, like this:
      
          test_expect_{success,failure} 'test title' '
      	setup1 &&
              setup2 &&
              setup3 &&
              what is to be tested
          '
      
      And expecting a failure exit from the whole sequence misses the
      point of writing tests.  Your setup$N that are supposed to
      succeed may have failed without even reaching what you are
      trying to test.  The only valid use of test_expect_failure is to
      check a trivial single command that is expected to fail, which
      is a minority in tests of Porcelain-ish commands.
      
      This large-ish patch rewrites all uses of test_expect_failure to
      use test_expect_success and rewrites the condition of what is
      tested, like this:
      
          test_expect_success 'test title' '
      	setup1 &&
              setup2 &&
              setup3 &&
              ! this command should fail
          '
      
      test_expect_failure is redefined to serve as a reminder that
      that test *should* succeed but due to a known breakage in git it
      currently does not pass.  So if git-foo command should create a
      file 'bar' but you discovered a bug that it doesn't, you can
      write a test like this:
      
          test_expect_failure 'git-foo should create bar' '
              rm -f bar &&
              git foo &&
              test -f bar
          '
      
      This construct acts similar to test_expect_success, but instead
      of reporting "ok/FAIL" like test_expect_success does, the
      outcome is reported as "FIXED/still broken".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      41ac414e
  27. 15 9月, 2007 1 次提交
    • J
      Split grep arguments in a way that does not requires to add /dev/null. · d99ebf08
      Junio C Hamano 提交于
      In order to (almost) always show the name of the file without
      relying on "-H" option of GNU grep, we used to add /dev/null to
      the argument list unless we are doing -l or -L.  This caused
      "/dev/null:0" to show up when -c is given in the output.
      
      It is not enough to add -c to the set of options we do not pass
      /dev/null for.  When we have too many files, we invoke grep
      multiple times and we need to avoid giving a widow filename to
      the last invocation -- otherwise we will not see the name.
      
      This keeps two filenames when the argv[] buffer is about to
      overflow and we have not finished iterating over the index, so
      that the last round will always have at least two paths to work
      with (and not require /dev/null).
      
      An obvious and the only exception is when there is only 1 file
      that is given to the underlying grep, and in that case we avoid
      passing /dev/null and let the external "grep -c" report only the
      number of matches.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d99ebf08
  28. 12 8月, 2006 1 次提交
  29. 06 8月, 2006 1 次提交
    • J
      Fix "grep -w" · f25b7939
      Junio C Hamano 提交于
      We used to find the first match of the pattern and then if the
      match is not for the entire word, declared that the whole line
      does not match.
      
      But that is wrong.  The command "git grep -w -e mmap" should
      find that a line "foo_mmap bar mmap baz" matches, by tring the
      second instance of pattern "mmap" on the same line.
      
      Problems an earlier round of "fix" had were pointed out by Morten
      Welinder, which have been incorporated in the t7002 tests.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      f25b7939