Commit Graph

312 Commits

Author SHA1 Message Date
Linus Torvalds
112d0bafd6 Make "git help" sort git commands in columns
This changes "pretty_print_string_list()" to show the git commands
alphabetically in column order, which is the normal one.

Ie instead of doing

	git commands available in '/home/torvalds/bin'
	----------------------------------------------
	  add                am                 ...
	  applypatch         archimport         ...
	  cat-file           check-ref-format   ...
	...

it does

	git commands available in '/home/torvalds/bin'
	----------------------------------------------
	  add                diff-tree          ...
	  am                 fetch              ...
	  apply              fetch-pack         ...
	...

where each column is sorted.

This is how "ls" sorts things too, and since visually the columns are much
more distinct than the rows, so it _looks_ more sorted.

The "ls" command has a "-x" option that lists entries by lines (the way
git.c used to): if somebody wants to do that, the new print-out logic
could be easily accomodated to that too. Matter of taste and preference, I
guess.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-18 13:53:40 -08:00
Linus Torvalds
ea77e675e5 Make "git help" react to window size correctly
Currently the git "show commands" function will react to the environment
variable COLUMNS, or just default to a width of 80 characters.

That's just soo eighties. Nobody sane sets COLUMNS any more, unless they
need to support some stone-age software from before the age of steam
engines, SIGWINCH and TIOCGWINSZ.

So get with the new century, and use TIOCGWINSZ to get the terminal size.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-18 13:53:33 -08:00
Junio C Hamano
4050c0df8e Clean up compatibility definitions.
This attempts to clean up the way various compatibility
functions are defined and used.

 - A new header file, git-compat-util.h, is introduced.  This
   looks at various NO_XXX and does necessary function name
   replacements, equivalent of -Dstrcasestr=gitstrcasestr in the
   Makefile.

 - Those function name replacements are removed from the Makefile.

 - Common features such as usage(), die(), xmalloc() are moved
   from cache.h to git-compat-util.h; cache.h includes
   git-compat-util.h itself.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 15:50:29 -08:00
Junio C Hamano
b270c634b7 git.c: remove excess output for debugging when command is too long.
When the given command name was too long, we exited with a
message with the number of bytes of the final command name
inside parentheses, without saying what that number is.  It was
only meant as a debugging aid while development, so remove it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 23:19:31 -08:00
Junio C Hamano
9a79c5a8b4 git.c: two fixes, gitsetenv type and off-by-one error.
gitsetenv as implemented in compat/setenv.c takes two const char*
and int; match that.

Also fix an incorrect attempt in prepend_to_path() to
NUL-terminate the string which stuffed the NUL character at one
past the end of allocation, and was not needed to begin with (we
copy the old_path string including the NUL which terminates it).

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 14:59:58 -08:00
Jason Riedy
e40b61fb6b Add compat/setenv.c, use in git.c.
There is no setenv() in Solaris 5.8.  The trivial calls to
setenv() were replaced by putenv() in a much earlier patch,
but setenv() was used again in git.c.  This patch just adds
a compat/setenv.c.

The rule for building git$(X) also needs to include compat.
objects and compiler flags.  Those are now in makefile vars
COMPAT_OBJS and COMPAT_CFLAGS.

Signed-off-by: E. Jason Riedy <ejr@cs.berkeley.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-03 22:25:25 -08:00
Alex Riesen
10b15b86f5 git wrapper: more careful argument stuffing
- Use stderr for error output
 - Build git_command more careful
 - ENOENT is good enough for check of failed exec to show usage, no
   access() check needed

[jc: Originally from Alex Riesen with inputs from Sven
 Verdoolaege mixed in.]

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-01 17:06:37 -08:00
YOSHIFUJI Hideaki / 吉藤英明
874fbc3323 Fix a warning about unused value.
Fix a warning:
  git.c:276: warning: value computed is not used

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-25 03:38:41 -08:00
Junio C Hamano
f9039f30d5 Do not show .exe in git command list.
Truncate the result from readdir() in the exec-path if they end
with .exe, to make it a bit more readable on Cygwin.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-18 15:40:22 -08:00
Junio C Hamano
7dbc2c0402 git wrapper: basic fixes.
Updates to fix the nits found during the list discussion.

 - Lose PATH_TO_MAN; just rely on execlp() to find whereever the
   "man" command is installed.

 - Do not randomly chdir(), but concatenate to the current
   working directory only if the given path is not absolute.

 - Lose use of glob(); read from exec_path and do sorting
   ourselves -- it is not that much more work.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-15 23:13:30 -08:00
Andreas Ericsson
97fc6c5fba git --help COMMAND brings up the git-COMMAND man-page.
It's by design a bit stupid (matching ^git rather than ^git-), so as
to work with 'gitk' and 'git' as well.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-15 16:03:00 -08:00
Andreas Ericsson
8e49d50388 C implementation of the 'git' program, take two.
This patch provides a C implementation of the 'git' program and
introduces support for putting the git-* commands in a directory
of their own. It also saves some time on executing those commands
in a tight loop and it prints the currently available git commands
in a nicely formatted list.

The location of the GIT_EXEC_PATH (name discussion's closed, thank gods)
can be obtained by running

	git --exec-path

which will hopefully give porcelainistas ample time to adapt their
heavy-duty loops to call the core programs directly and thus save
the extra fork() / execve() overhead, although that's not really
necessary any more.

The --exec-path value is prepended to $PATH, so the git-* programs
should Just Work without ever requiring any changes to how they call
other programs in the suite.

Some timing values for 10000 invocations of git-var >&/dev/null:
	git.sh: 24.194s
	git.c:   9.044s
	git-var: 7.377s

The git-<tab><tab> behaviour can, along with the someday-to-be-deprecated
git-<command> form of invocation, be indefinitely retained by adding
the following line to one's .bash_profile or equivalent:

	PATH=$PATH:$(git --exec-path)

Experimental libraries can be used by either setting the environment variable
GIT_EXEC_PATH, or by using

	git --exec-path=/some/experimental/exec-path

Relative paths are properly grok'ed as exec-path values.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-15 16:02:57 -08:00