1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-27 22:46:09 +02:00
Commit Graph

320 Commits

Author SHA1 Message Date
Thiago Farina 3cd474599f object.h: Add OBJECT_ARRAY_INIT macro and make use of it.
Signed-off-by: Thiago Farina <tfransosi@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-29 22:42:49 -07:00
Junio C Hamano 6b5005c88b Merge branch 'tf/string-list-init'
* tf/string-list-init:
  string_list: Add STRING_LIST_INIT macro and make use of it.
2010-08-18 12:47:04 -07:00
Nguyễn Thái Ngọc Duy ff38d1a995 grep: run setup_git_directory_gently() sooner
git grep already runs a repository search unconditionally,
even when the --no-index option is supplied; running such a
search earlier is not very risky.

Just like with shortlog, without this change, the
“[pager] grep” configuration is not respected at all.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-11 09:24:26 -07:00
Junio C Hamano a7d7853463 Merge branch 'jn/grep-open'
* jn/grep-open:
  grep -O: Do not pass color sequences as filenames to pager
2010-07-15 12:07:18 -07:00
Nazri Ramliy e7b082a411 grep -O: Do not pass color sequences as filenames to pager
With a .gitconfig like this:

 [color]
	ui = auto
 [color "grep"]
	filename = magenta

if stdout is a terminal, the grep machinery will output the color
sequence \e[36m before each filename in its output.

In the case of "git grep -O foo", output is argv for the pager.
Disable color when calling the grep machinery in this case.

Signed-off-by: Nazri Ramliy <ayiehere@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-07-07 11:23:17 -07:00
Thiago Farina 183113a5ca string_list: Add STRING_LIST_INIT macro and make use of it.
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Thiago Farina <tfransosi@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-07-05 11:47:57 -07:00
Junio C Hamano 6f82be0519 Merge branch 'jn/grep-open'
* jn/grep-open:
  t/t7811-grep-open.sh: remove broken/redundant creation of fake "less" script
  t/t7811-grep-open.sh: ensure fake "less" is made executable
  t/lib-pager.sh: remove unnecessary '^' from 'expr' regular expression
  grep -O: allow optional argument specifying the pager (or editor)
  grep: Add the option '--open-files-in-pager'
  Unify code paths of threaded greps
  grep: refactor grep_objects loop into its own function

Conflicts:
	t/t7006-pager.sh
2010-06-30 11:55:38 -07:00
Julian Phillips 0c72cead84 Merge branch 'jp/string-list-api-cleanup' into jn/grep-open
An evil merge to adjust the series to cleaned-up API.

  From: Julian Phillips <julian@quantumfyre.co.uk>
  Subject: [PATCH v2 7/7] grep: fix string_list_append calls
  Date: Sat, 26 Jun 2010 00:41:39 +0100
  Message-ID: <20100625234140.18927.35025.julian@quantumfyre.co.uk>

* jp/string-list-api-cleanup:
  string_list: Fix argument order for string_list_append
  string_list: Fix argument order for string_list_lookup
  string_list: Fix argument order for string_list_insert_at_index
  string_list: Fix argument order for string_list_insert
  string_list: Fix argument order for for_each_string_list
  string_list: Fix argument order for print_string_list

Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-27 10:17:18 -07:00
Junio C Hamano 534930807c Merge branch 'rs/grep-binary'
* rs/grep-binary:
  grep: support NUL chars in search strings for -F
  grep: use REG_STARTEND for all matching if available
  grep: continue case insensitive fixed string search after NUL chars
  grep: use memmem() for fixed string search
  grep: --name-only over binary
  grep: --count over binary
  grep: grep: refactor handling of binary mode options
  grep: add test script for binary file handling
2010-06-13 11:21:44 -07:00
Johannes Schindelin 0af88c15e2 grep -O: allow optional argument specifying the pager (or editor)
Suppose you want to edit all files that contain a specific search term.
Of course, you can do something totally trivial such as

	git grep -z -e <term> | xargs -0r vi +/<term>

but maybe you are happy that the same will be achieved by

	git grep -Ovi <term>

now.

[jn: rebased and added tests]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Paolo Bonzini <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-13 09:16:50 -07:00
Johannes Schindelin 678e484b7d grep: Add the option '--open-files-in-pager'
This adds an option to open the matching files in the pager, and if the
pager happens to be "less" (or "vi") and there is only one grep pattern,
it also jumps to the first match right away.

The short option was chose as '-O' to avoid clashes with GNU grep's
options (as suggested by Junio).

So, 'git grep -O abc' is a short form for 'less +/abc $(grep -l abc)'
except that it works also with spaces in file names, and it does not
start the pager if there was no matching file.

[jn: rebased and added tests; with error handling fix from Junio
squashed in]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-13 09:16:38 -07:00
Johannes Schindelin 685359cf2d Unify code paths of threaded greps
There were three awfully similar code paths ending the threaded grep. It
is better to avoid duplicated code, though.

This change might very well prevent a race, where the grep patterns were
free()d before waiting that all threads finished.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-13 09:15:11 -07:00
Jonathan Nieder 30d00c395e grep: refactor grep_objects loop into its own function
Simplify cmd_grep by splitting off the loop that finds matches in a
list of trees.  So now the main part of cmd_grep looks like:

	if (!use_index) {
		int hit = grep_directory(&opt, paths);
		if (use_threads)
			hit |= wait_all();
		return !hit;
	}
	if (!list.nr) {
		if (!cached)
			setup_work_tree();
		int hit = grep_cache(&opt, paths, cached);
		if (use_threads)
			hit |= wait_all;
		return !hit;
	}
	hit = grep_objects(&opt, path, &list);
	if (use_threads)
		hit |= wait_all();
	return !hit;

and is ripe for further refactoring.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-13 09:15:09 -07:00
René Scharfe ed40a0951c grep: support NUL chars in search strings for -F
Search patterns in a file specified with -f can contain NUL characters.
The current code ignores all characters on a line after a NUL.

Pass the actual length of the line all the way from the pattern file to
fixmatch() and use it for case-sensitive fixed string matching.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-05-24 11:22:07 -07:00
Junio C Hamano ea5f75a64a Merge branch 'np/malloc-threading'
* np/malloc-threading:
  Thread-safe xmalloc and xrealloc needs a recursive mutex
  Make xmalloc and xrealloc thread-safe
2010-05-21 04:02:16 -07:00
Junio C Hamano 07b838f087 Merge branch 'rs/threaded-grep-context'
* rs/threaded-grep-context:
  grep: enable threading for context line printing

Conflicts:
	grep.c
2010-04-03 12:28:39 -07:00
Junio C Hamano f1aa782a3b Merge branch 'ml/color-grep'
* ml/color-grep:
  grep: Colorize selected, context, and function lines
  grep: Colorize filename, line number, and separator
  Add GIT_COLOR_BOLD_* and GIT_COLOR_BG_*
2010-03-20 11:29:36 -07:00
René Scharfe 431d6e7bc8 grep: enable threading for context line printing
If context lines are to be printed, grep separates them with hunk marks
("--\n").  These marks are printed between matches from different files,
too.  They are not printed before the first file, though.

Threading was disabled when context line printing was enabled because
avoiding to print the mark before the first line was an unsolved
synchronisation problem.  This patch separates the code for printing
hunk marks for the threaded and the unthreaded case, allowing threading
to be turned on together with the common -ABC options.

->show_hunk_mark, which controls printing of hunk marks between files in
show_line(), is now set in grep_buffer_1(), but only if some results
have already been printed and threading is disabled.  The threaded case
is handled in work_done().

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-15 15:26:35 -07:00
Junio C Hamano 2e0e8b68e3 Merge branch 'lt/deepen-builtin-source'
* lt/deepen-builtin-source:
  Move 'builtin-*' into a 'builtin/' subdirectory

Conflicts:
	Makefile
2010-03-10 15:25:18 -08:00
Linus Torvalds 81b50f3ce4 Move 'builtin-*' into a 'builtin/' subdirectory
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: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-22 14:29:41 -08:00