1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-24 20:06:11 +02:00
Commit Graph

50 Commits

Author SHA1 Message Date
Stephan Beyer 1b1dd23f2d Make usage strings dash-less
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: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-13 14:12:48 -07:00
Junio C Hamano bb1ab2db08 Merge branch 'j6t/mingw'
* j6t/mingw: (38 commits)
  compat/pread.c: Add a forward declaration to fix a warning
  Windows: Fix ntohl() related warnings about printf formatting
  Windows: TMP and TEMP environment variables specify a temporary directory.
  Windows: Make 'git help -a' work.
  Windows: Work around an oddity when a pipe with no reader is written to.
  Windows: Make the pager work.
  When installing, be prepared that template_dir may be relative.
  Windows: Use a relative default template_dir and ETC_GITCONFIG
  Windows: Compute the fallback for exec_path from the program invocation.
  Turn builtin_exec_path into a function.
  Windows: Use a customized struct stat that also has the st_blocks member.
  Windows: Add a custom implementation for utime().
  Windows: Add a new lstat and fstat implementation based on Win32 API.
  Windows: Implement a custom spawnve().
  Windows: Implement wrappers for gethostbyname(), socket(), and connect().
  Windows: Work around incompatible sort and find.
  Windows: Implement asynchronous functions as threads.
  Windows: Disambiguate DOS style paths from SSH URLs.
  Windows: A rudimentary poll() emulation.
  Windows: Implement start_command().
  ...
2008-07-02 21:57:52 -07:00
Christian Couder 2dce956e39 help: check early if we have a command, if not try a documentation topic
Before this patch, something like "git help tutorial" did not work,
people had to use "git help gittutorial" which is not very intuitive.

This patch uses the "is_git_command" function to test early if the
argument passed to "git help" is a git command, and if this is not the
case then we prefix the argument with "git" instead of "git-".

This way, things like "git help tutorial" or "git help glossary" will
work fine.

The little downside of this patch is that the "is_git_command" is a
little bit slow.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-27 23:21:45 -07:00
Johannes Sixt cc3b7a9732 Windows: Make 'git help -a' work.
git help -a scans the PATH for git commands. On Windows it failed for two
reasons:

- The PATH separator is ';', not ':' on Windows.

- stat() does not set the executable bit.

We now open the file and guess whether it is executable.

The result of the guess is good enough for the list of git commands, but
it is of no use for a general stat() implementation because (1) it is a
guess, (2) the user has no way to influence the outcome (via chmod or
similar), and (3) it would reduce stat() performance by an unacceptable
amount. Therefore, this strategy is a special-case local to help.c.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-26 08:47:16 +02:00
Teemu Likonen b7d9681974 Print info about "git help COMMAND" on git's main usage pages
Git's main usage pages did not show "git help" as a way to get more
information on a specific subcommand. This patch adds an info line after
the list of git commands currently printed by "git", "git help", "git
--help" and "git help --all".

Signed-off-by: Teemu Likonen <tlikonen@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-06 09:22:18 -07:00
Johannes Schindelin ef90d6d420 Provide git_config with a callback-data parameter
git_config() only had a function parameter, but no callback data
parameter.  This assumes that all callback functions only modify
global variables.

With this patch, every callback gets a void * parameter, and it is hoped
that this will help the libification effort.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-14 12:34:44 -07:00
Christian Couder a26a06afed help: use "man.<tool>.cmd" as custom man viewer command
Currently "git help -m GITCMD" is restricted to a set of man viewers
defined at compile time. You can subvert the "man.<tool>.path" to
force "git help -m" to use a different man, viewer, but if you have a
man viewer whose invocation syntax does not match one of the current
tools then you would have to write a wrapper script for it.

This patch adds a git config variable "man.<tool>.cmd" which allows a
more flexible man viewer choice.

If you run "git help -m GITCMD" with the "man.viewer" config variable
set to an unrecognized tool then it will query the "man.<tool>.cmd"
config variable. If this variable exists, then the specified tool will
be treated as a custom man viewer and it will be run in a shell with
the man page name of the GITCMD added as extra parameter.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-26 14:33:56 -07:00
Christian Couder 7b15f872f2 help: use man viewer path from "man.<tool>.path" config var
This patch implements reading values from "man.<tool>.path"
configuration variables, and using these values as pathes to
the man viewer <tool>s when lauching them.

This makes it possible to use different version of the tools
than the one on the current PATH, or maybe a custom script.

In this patch we also try to launch "konqueror" using
"kfmclient" even if a path to a konqueror binary is given
in "man.konqueror.path".

The "man_viewer_list" becomes a simple string list to simplify
things for the following patches.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-26 14:33:39 -07:00
Christian Couder 4637e47acc help: Add a missing OPT_END().
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-01 23:40:06 -07:00
Christian Couder 5fb0b3e007 help: warn if specified 'man.viewer' is unsupported, instead of erroring out
When a document viewer that is unknown to the current version of git is
specified in the .git/config file, instead of erroring out the process
entirely, just issue a warning.  It might be that the user usually is
using a newer git that supports it (and the configuration is written for
that version) but is temporarily using an older git that does not know the
viewer.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-12 23:23:27 -07:00
Christian Couder 69099d6bed help: implement multi-valued "man.viewer" config option
This allows multiple viewer candidates to be listed in the configuration
file, like this:

        [man]
                viewer = woman
                viewer = konqueror
                viewer = man

The candidates are tried in the order listed in the configuration file,
and the first suitable one (e.g. konqueror cannot be used outside windowed
environment) is used.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Tested-by: Xavier Maillard <xma@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-11 23:02:01 -07:00
Christian Couder 649499845c help: add "man.viewer" config var to use "woman" or "konqueror"
This patch makes it possible to view man pages using other tools
than the "man" program. It also implements support for emacs'
"woman" and konqueror with the man KIO slave to view man pages.

Note that "emacsclient" is used with option "-e" to launch "woman"
on emacs and this works only on versions >= 22.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Tested-by: Xavier Maillard <xma@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-11 23:02:01 -07:00
Jeff King 2156435ff2 help: respect aliases
If we have an alias "foo" defined, then the help text for
"foo" (via "git help foo" or "git foo --help") now shows the
definition of the alias.

Before showing an alias definition, we make sure that there
is no git command which would override the alias (so that
even though you may have a "log" alias, even though it will
not work, we don't want to it supersede "git help log").

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-24 18:31:50 -08:00
Jeff King 41eb33bd0c help: use parseopt
This patch converts cmd_help to use parseopt, along with a
few style cleanups, including:

  - enum constants are now ALL_CAPS

  - parse_help_format returns an enum value rather than
    setting a global as a side effect

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-24 18:31:49 -08:00
Christian Couder 9886ea417b help.c: use 'git_config_string' to get 'help_default_format'.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-17 20:54:01 -08:00
Junio C Hamano 990732609c Merge branch 'cc/browser'
* cc/browser:
  Documentation: add 'git-web--browse.txt' and simplify other docs.
  git-web--browse: fix misplaced quote in init_browser_path()
  web--browse: Add a few quotes in 'init_browser_path'.
  Documentation: instaweb: add 'git-web--browse' information.
  Adjust .gitignore for 5884f1(Rename 'git-help--browse.sh'...)
  git-web--browse: do not start the browser with nohup
  instaweb: use 'git-web--browse' to launch browser.
  Rename 'git-help--browse.sh' to 'git-web--browse.sh'.
  help--browse: add '--config' option to check a config option for a browser.
  help: make 'git-help--browse' usable outside 'git-help'.

Conflicts:

	git-web--browse.sh
2008-02-16 17:57:47 -08:00
Junio C Hamano b51b2bb4c3 help.c: guard config parser from value=NULL
help.format configuration expects a string value

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-11 13:11:37 -08:00
Christian Couder 5884f1fe96 Rename 'git-help--browse.sh' to 'git-web--browse.sh'.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-05 01:01:48 -08:00
Christian Couder caa87713bc help--browse: add '--config' option to check a config option for a browser.
The value of this new command line option will be used as a key to
check the configuration for an help browser.

This should remove the last bit in 'git-help--browse' that was
specific to 'git-help', so that other git command can use
'git-help--browse'.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-05 01:01:47 -08:00
Christian Couder 482cce8205 help: make 'git-help--browse' usable outside 'git-help'.
"git-help--browse" helper is to launch a browser of the user's choice
to view the HTML version of git documentation for a given command.  It
used to take the name of a command, convert it to the path of the
documentation by prefixing the directory name and appending the
".html" suffix, and start the browser on the path.

This updates the division of labor between the caller in help.c and
git-help--browser helper.  The helper is now responsible for launching
a browser of the user's choice on given URLs, and it is the caller's
responsibility to tell it the paths to documentation files.

This is in preparation to reuse the logic to choose user's preferred
browser in instaweb.

The helper had a provision for running it without any command name, in
which case it showed the toplevel "git(7)" documentation, but the
caller in help.c never makes such a call.  The helper now exits with a
usage message when no path is given.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-05 01:01:45 -08:00
Jeff King d7e522cffb rename git-browse--help to git-help--browse
The convention for helper scripts has been
git-$TOOL--$HELPER. Since this is a "browse" helper for the
"help" tool, git-help--browse is a more sensible name.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-16 12:52:40 -08:00
Junio C Hamano 5b4617c749 Rename git-browse-help helper to git-browse--help
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-14 22:04:43 -08:00
Christian Couder 70087cdbd3 git-help: add "help.format" config variable.
This config variable makes it possible to choose the default format
used to display help. This format will be used only if no option
like -a|--all|-i|--info|-m|--man|-w|--web is passed to "git-help".

The following values are possible for this variable:

	- "man"  --> "man" program is used
	- "info" --> "info" program is used
	- "web"  --> "git-browse-help" is used

By default we still show help using "man".

This patch also adds -m|--man command line option to use "man"
to allow overriding the "help.format" configuration variable.

Note that this patch also revert some recent changes in
"git-browse-help" because they prevented to look for config
variables in the global configuration file.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-14 21:58:35 -08:00
Junio C Hamano a149a1a44a git-help -i: show info documentation from matching version of git
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-10 01:36:31 -08:00
Junio C Hamano 78d39f98f3 git-help -i: invoke info with document and node name
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-10 01:36:31 -08:00
Junio C Hamano 7be2b6e02b Merge branch 'master' into cc/help
This is to primarily pull in MANPATH tweak and help.txt formatting fix
from the master branch.
2007-12-10 01:22:42 -08:00
Christian Couder 5d6491c7c7 git-help: add -w|--web option to display html man page in a browser.
Now when using "git help -w cmd", we will try to show the HTML man
page "git-cmd.html" in your prefered web browser.

To do that "help.c" code will call a new shell script
"git-browse-help".

This currently works only if the HTML versions of the man page
have been installed in $(htmldir) (typically "/usr/share/doc/git-doc"),
so new target to do that is added to "Documentation/Makefile".

The browser to use can be configured using the "web.browser"
config variable.

We try to open a new tab in an existing web browser, if possible.

The code in "git-browse-help" is heavily stolen from "git-mergetool"
by Theodore Y. Ts'o. Thanks.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-09 01:19:44 -08:00
Sergei Organov 8e566f24b3 Let git-help prefer man-pages installed with this version of git
Prepend $(prefix)/share/man to the MANPATH environment variable before
invoking 'man' from help.c:show_man_page().  There may be other git
documentation in the user's MANPATH but the user is asking a specific
instance of git about its own documentation, so we'd better show the
documentation for _that_ instance of git.

Signed-off-by: Sergei Organov <osv@javad.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-08 02:50:54 -08:00
Christian Couder df55c9cbc3 git-help: add -i|--info option to display info page.
"git help --info subcommand" will now call "info git-subcommand".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-03 22:15:05 -08:00
Junio C Hamano 8256c6e010 Merge branch 'tt/help'
* tt/help:
  Remove hint to use "git help -a"
  Make the list of common commands more exclusive
2007-12-01 20:05:49 -08:00
Johannes Sixt 80bbe72b76 Move #include <sys/select.h> and <sys/ioctl.h> to git-compat-util.h.
... since all system headers are pulled in via git-compat-util.h

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-14 15:18:39 -08:00
Theodore Ts'o 15f80a539b Remove hint to use "git help -a"
The newbie user will run away screaming when they see all possible
commands.  The expert user will already know about the -a option from
reading the git man page.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-14 14:46:18 -08:00
Junio C Hamano f3fa183802 Style: place opening brace of a function definition at column 1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-08 15:35:32 -08:00
Scott R Parish 1eb056905a include $PATH in generating list of commands for "help -a"
Git had previously been using the $PATH for scripts--a previous
patch moved exec'ed commands to also use the $PATH. For consistency
"help -a" should also list commands in the $PATH.

The main commands are still listed from the git_exec_path(), but
the $PATH is walked and other git commands (probably extensions) are
listed.

Signed-off-by: Scott R Parish <srp@srparish.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-29 20:51:37 -07:00
Scott R Parish 0966003c8e list_commands(): simplify code by using chdir()
The current code builds absolute path strings for each file to
stat(), this can easily be avoided by chdir()ing into the directory.

Signed-off-by: Scott R Parish <srp@srparish.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-29 20:51:37 -07:00
Scott R Parish edb6ddc53e remove unused/unneeded "pattern" argument of list_commands
list_commands() currently accepts and ignores a "pattern" argument,
and then hard codes a prefix as well as some magic numbers. This
hardcodes the prefix inside of the function and removes the magic
numbers.

Signed-off-by: Scott R Parish <srp@srparish.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-29 20:51:37 -07:00
Scott R Parish 3d7e2d857a "git" returns 1; "git help" and "git help -a" return 0
Signed-off-by: Scott R Parish <srp@srparish.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-29 20:51:36 -07:00
Junio C Hamano a238917ba4 help: remove extra blank line after "See 'git --help'" message
The double LF were there only because we gave a list of common
commands.  WIth the list gone, there is no reason to have the
extra blank line.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-26 23:26:41 -07:00
Jari Aalto b5d21a4b68 On error, do not list all commands, but point to --help option
- Remove out call to list_common_cmds_help()
- Send error message to stderr, not stdout.

Signed-off-by: Jari Aalto <jari.aalto@cante.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-22 01:57:50 -04:00
Junio C Hamano a6080a0a44 War on whitespace
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: Junio C Hamano <gitster@pobox.com>
2007-06-07 00:04:01 -07:00
James Bowes c6e0caa384 use xrealloc in help.c
Signed-off-by: James Bowes <jbowes@dangerouslyinc.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-27 16:57:57 -07:00
James Bowes 3301521a25 use xmalloc in git.c and help.c
Signed-off-by: James Bowes <jbowes@dangerouslyinc.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-25 18:00:23 -07:00
Junio C Hamano cc44c7655f Mechanical conversion to use prefixcmp()
This mechanically converts strncmp() to use prefixcmp(), but only when
the parameters match specific patterns, so that they can be verified
easily.  Leftover from this will be fixed in a separate step, including
idiotic conversions like

    if (!strncmp("foo", arg, 3))

  =>

    if (!(-prefixcmp(arg, "foo")))

This was done by using this script in px.perl

   #!/usr/bin/perl -i.bak -p
   if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) {
           s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|;
   }
   if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) {
           s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|;
   }

and running:

   $ git grep -l strncmp -- '*.c' | xargs perl px.perl

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-20 22:03:15 -08:00
Ren,bi(B Scharfe 4f75b115d7 Avoid ugly linewrap in git help
Some of the short help texts that are shown e.g. when running 'git'
without any parameters wrap on a 80-column terminal.  They are just
one character over the line.  This patch avoids it by decreasing the
number of spaces around the preceding command name from four to
three (on both sides for symmetry).

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-11 12:42:01 -08:00
Junio C Hamano 85023577a8 simplify inclusion of system header files.
This is a mechanical clean-up of the way *.c files include
system header files.

 (1) sources under compat/, platform sha-1 implementations, and
     xdelta code are exempt from the following rules;

 (2) the first #include must be "git-compat-util.h" or one of
     our own header file that includes it first (e.g. config.h,
     builtin.h, pkt-line.h);

 (3) system headers that are included in "git-compat-util.h"
     need not be included in individual C source files.

 (4) "git-compat-util.h" does not have to include subsystem
     specific header files (e.g. expat.h).

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-20 09:51:35 -08:00
Jonas Fonseca 2d7320d0b0 Use xmalloc instead of malloc
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-31 16:24:39 -07:00
David Rientjes 96f1e58f52 remove unnecessary initializations
[jc: I needed to hand merge the changes to the updated codebase,
 so the result needs to be checked.]

Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-15 21:22:20 -07:00
Junio C Hamano bb266cb118 Merge branch 'mk/rename' 2006-08-12 19:13:31 -07:00
Junio C Hamano 44e1d764d0 Merge branch 'master' into mk/rename
* master:
  git-verify-pack: no need to count errors
  git-verify-pack: buffer overrun paranoia
  git-verify-pack: free pack after use and a cleanup
  git-verify-pack: get rid of while loop
  git-verify-pack: insist on .idx extension
  git-verify-pack: more careful path handling
  git-verify-pack: show usage when no pack was specified
  Add has_extension()
  builtin-apply: remove unused increment
  Fix git-diff A...B
  combine-diff: use color
  git-apply: applying a patch to make a symlink shorter.
  allow diff.renamelimit to be set regardless of -M/-C
  make --find-copies-harder imply -C
  find_unique_abbrev() with len=0 should not abbreviate
  check return value from diff_setup_done()
  Fix tutorial-2.html
  Documentation: git-status takes the same options as git-commit
  Update git-init-db(1) and documentation of core.sharedRepository
2006-08-10 14:17:49 -07:00
Junio C Hamano f754fa9c54 builtins: Makefile clean-up
This cleans up the build procedure for built-in commands by:

 - generating mostly redundant definition of BUILT_INS from
   BUILTIN_OBJS in the Makefile,
 - renaming a few files to make the above possible, and
 - sorting the built-in command table in git.c.

It might be a good idea to binary search (or perfect hash) the built-in
command table, but that can be done later when somebody feels like.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-04 01:51:04 -07:00