Commit graph

696 commits

Author SHA1 Message Date
Junio C Hamano fc9dfda1be Merge branch 'sg/config-name-only'
"git config --list" output was hard to parse when values consist of
multiple lines.  "--name-only" option is added to help this.

* sg/config-name-only:
  get_urlmatch: avoid useless strbuf write
  format_config: simplify buffer handling
  format_config: don't init strbuf
  config: restructure format_config() for better control flow
  completion: list variable names reliably with 'git config --name-only'
  config: add '--name-only' option to list only variable names
2015-08-31 15:38:50 -07:00
Junio C Hamano ed070a4007 Merge branch 'ep/http-configure-ssl-version'
A new configuration variable http.sslVersion can be used to specify
what specific version of SSL/TLS to use to make a connection.

* ep/http-configure-ssl-version:
  http: add support for specifying the SSL version
2015-08-26 15:45:31 -07:00
Junio C Hamano 011710a315 Merge branch 'tb/complete-rebase-i-edit-todo'
The command-line completion script (in contrib/) has been updated.

* tb/complete-rebase-i-edit-todo:
  completion: offer '--edit-todo' during interactive rebase
2015-08-19 14:48:56 -07:00
Elia Pinto 01861cb7a2 http: add support for specifying the SSL version
Teach git about a new option, "http.sslVersion", which permits one
to specify the SSL version to use when negotiating SSL connections.
The setting can be overridden by the GIT_SSL_VERSION environment
variable.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-17 10:16:34 -07:00
SZEDER Gábor 905f2036d0 completion: list variable names reliably with 'git config --name-only'
Recenty I created a multi-line branch description with '.' and '='
characters on one of the lines, and noticed that fragments of that line
show up when completing set variable names for 'git config', e.g.:

  $ git config --get branch.b.description
  Branch description to fool the completion script with a
  second line containing dot . and equals = characters.
  $ git config --unset <TAB>
  ...
  second line containing dot . and equals
  ...

The completion script runs 'git config --list' and processes its output
to strip the values and keep only the variable names.  It does so by
looking for lines containing '.' and '=' and outputting everything
before the '=', which was fooled by my multi-line branch description.

A similar issue exists with aliases and pretty format aliases with
multi-line values, but in that case 'git config --get-regexp' is run and
lines in its output are simply stripped after the first space, so
subsequent lines don't even have to contain '.' and '=' to fool the
completion script.

Use the new '--name-only' option added in the previous commit to list
config variable names reliably in both cases, without error-prone post
processing.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-10 10:34:40 -07:00
SZEDER Gábor 578625fa91 config: add '--name-only' option to list only variable names
'git config' can only show values or name-value pairs, so if a shell
script needs the names of set config variables it has to run 'git config
--list' or '--get-regexp' and parse the output to separate config
variable names from their values.  However, such a parsing can't cope
with multi-line values.  Though 'git config' can produce null-terminated
output for newline-safe parsing, that's of no use in such a case, becase
shells can't cope with null characters.

Even our own bash completion script suffers from these issues.

Help the completion script, and shell scripts in general, by introducing
the '--name-only' option to modify the output of '--list' and
'--get-regexp' to list only the names of config variables, so they don't
have to perform error-prone post processing to separate variable names
from their values anymore.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-10 10:33:58 -07:00
Thomas Braun 09bb6520d4 completion: offer '--edit-todo' during interactive rebase
Helped-by: John Keeping <john@keeping.me.uk>
Helped-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-05 13:35:36 -07:00
Junio C Hamano 461c119739 Merge branch 'sg/bash-prompt-untracked-optim'
Optimize computation of untracked status indicator by bash prompt
script (in contrib/).

* sg/bash-prompt-untracked-optim:
  bash prompt: faster untracked status indicator with untracked directories
  bash prompt: test untracked files status indicator with untracked dirs
2015-08-03 11:01:26 -07:00
SZEDER Gábor dd160d794f bash prompt: faster untracked status indicator with untracked directories
If the untracked status indicator is enabled, __git_ps1() looks for
untracked files by running 'git ls-files'.  This can be perceptibly slow
in case of an untracked directory containing lot of files, because it
lists all files found in the untracked directory only to be redirected
into /dev/null right away (this is the actual command run by __git_ps1()):

  $ ls untracked-dir/ |wc -l
  100000
  $ time git ls-files --others --exclude-standard --error-unmatch \
    -- ':/*' >/dev/null 2>/dev/null

  real	0m0.955s
  user	0m0.936s
  sys	0m0.016s

Eliminate this delay by additionally passing the '--directory
--no-empty-directory' options to 'git ls-files' to show only the name of
non-empty untracked directories instead of all their content:

  $ time git ls-files --others --exclude-standard --directory \
    --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null

  real	0m0.010s
  user	0m0.008s
  sys	0m0.000s

This follows suit of ea95c7b8f5 (completion: improve untracked directory
filtering for filename completion, 2013-09-18).

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-20 13:08:56 -07:00
Junio C Hamano 51d5980ea0 Merge branch 'jc/prompt-document-ps1-state-separator' into maint
Docfix.

* jc/prompt-document-ps1-state-separator:
  git-prompt.sh: document GIT_PS1_STATESEPARATOR
2015-07-15 11:41:26 -07:00
Junio C Hamano ada9ecd989 Merge branch 'af/tcsh-completion-noclobber' into maint
The tcsh completion writes a bash scriptlet but that would have
failed for users with noclobber set.

* af/tcsh-completion-noclobber:
  git-completion.tcsh: fix redirect with noclobber
2015-07-15 11:41:18 -07:00
Junio C Hamano d70bc3b97a Merge branch 'jc/prompt-document-ps1-state-separator'
Docfix.

* jc/prompt-document-ps1-state-separator:
  git-prompt.sh: document GIT_PS1_STATESEPARATOR
2015-07-01 14:02:32 -07:00
Junio C Hamano c595cb9c4f Merge branch 'af/tcsh-completion-noclobber'
The tcsh completion writes a bash scriptlet but that would have
failed for users with noclobber set.

* af/tcsh-completion-noclobber:
  git-completion.tcsh: fix redirect with noclobber
2015-06-24 12:21:53 -07:00
Junio C Hamano 54a17cdb9c Merge branch 'sg/completion-commit-cleanup'
* sg/completion-commit-cleanup:
  completion: teach 'scissors' mode to 'git commit --cleanup='
2015-06-24 12:21:51 -07:00
Junio C Hamano e356158b4a Merge branch 'tb/complete-sequencing'
The bash completion script (in contrib/) learned a few options that
"git revert" takes.

* tb/complete-sequencing:
  completion: suggest sequencer commands for revert
2015-06-11 09:29:59 -07:00
Joe Cridge ab7fade919 git-prompt.sh: document GIT_PS1_STATESEPARATOR
The environment variable GIT_PS1_STATESEPARATOR can be used to set the
separator between the branch name and the state symbols in the prompt.

At present the variable is not mentioned in the inline documentation which
makes it difficult for the casual user to identify.

Signed-off-by: Joe Cridge <joe.cridge@me.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-06-10 14:53:14 -07:00
Ariel Faigon 0b1f688bf4 git-completion.tcsh: fix redirect with noclobber
tcsh users who happen to have 'set noclobber' elsewhere in their
~/.tcshrc or ~/.cshrc startup files get a 'File exist' error, and
the tcsh completion file doesn't get generated/updated.

Adding a `!` in the redirect works correctly for both clobber (default)
and 'set noclobber' users.

Reviewed-by: Christian Couder <christian.couder@gmail.com>
Signed-off-by: Ariel Faigon <github.2009@yendor.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-06-09 11:21:15 -07:00
SZEDER Gábor 72dbb36554 completion: teach 'scissors' mode to 'git commit --cleanup='
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-06-08 08:46:47 -07:00
Thomas Braun 956352b67e completion: suggest sequencer commands for revert
Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>
Acked-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-06-01 08:41:47 -07:00
Junio C Hamano 23903b9e29 Merge branch 'sg/complete-decorate-full-not-long' into maint
The completion for "log --decorate=" parameter value was incorrect.

* sg/complete-decorate-full-not-long:
  completion: fix and update 'git log --decorate=' options
2015-05-26 13:49:22 -07:00
Junio C Hamano 935d937644 Merge branch 'sg/completion-config'
Code clean-up for completion script (in contrib/).

* sg/completion-config:
  completion: simplify query for config variables
  completion: add a helper function to get config variables
2015-05-22 12:41:54 -07:00
Junio C Hamano 39fa79178f Merge branch 'ls/http-ssl-cipher-list'
Introduce http.<url>.SSLCipherList configuration variable to tweak
the list of cipher suite to be used with libcURL when talking with
https:// sites.

* ls/http-ssl-cipher-list:
  http: add support for specifying an SSL cipher list
2015-05-22 12:41:45 -07:00
Junio C Hamano 823ac2b633 Merge branch 'sg/completion-omit-credential-helpers'
The Git subcommand completion (in contrib/) listed credential
helpers among candidates, which is not something the end user would
invoke interatively.

* sg/completion-omit-credential-helpers:
  completion: remove credential helpers from porcelain commands
2015-05-22 12:41:42 -07:00
SZEDER Gábor 12bdc880c7 completion: simplify query for config variables
To get the name of all config variables in a given section we perform a
'git config --get-regex' query for all config variables containing the
name of that section, and then filter its output through a case statement
to throw away those that though contain but don't start with the given
section.

Modify the regex to match only at the beginning, so the case statement
becomes unnecessary and we can get rid of it.  Add a test to check that a
match in the middle doesn't fool us.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-12 15:16:46 -07:00
SZEDER Gábor e8f9e42829 completion: add a helper function to get config variables
Currently there are a few completion functions that perform similar 'git
config' queries and filtering to get config variable names: the completion
of pretty aliases, aliases, and remote groups for 'git remote update'.

Unify those 'git config' queries in a helper function to eliminate code
duplication.

Though the helper functions to get pretty aliases and alieses are reduced
to mere one-liner wrappers around the newly added function, keep these
helpers still, because users' completion functions out there might depend
on them.  And they keep their callers a tad easier to read, too.

Add tests for the pretty alias and alias helper to show that they work
as before; not for the remote groups query, though, because that's not
extracted into a helper function and it's not worth the effort to do so
for a sole callsite.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-12 15:12:19 -07:00
Junio C Hamano 5c38a1fad7 Merge branch 'sg/completion-no-redundant-all-command-list'
Code simplification.

* sg/completion-no-redundant-all-command-list:
  completion: remove redundant __git_compute_all_commands() call
2015-05-11 14:23:57 -07:00
Junio C Hamano 465868a225 Merge branch 'sg/complete-decorate-full-not-long'
The completion for "log --decorate=" parameter value was incorrect.

* sg/complete-decorate-full-not-long:
  completion: fix and update 'git log --decorate=' options
2015-05-11 14:23:56 -07:00
Lars Kellogg-Stedman f6f2a9e42d http: add support for specifying an SSL cipher list
Teach git about a new option, "http.sslCipherList", which permits one to
specify a list of ciphers to use when negotiating SSL connections.  The
setting can be overwridden by the GIT_SSL_CIPHER_LIST environment
variable.

Signed-off-by: Lars Kellogg-Stedman <lars@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-08 10:56:26 -07:00
SZEDER Gábor a074aa90a8 completion: remove credential helpers from porcelain commands
Don't offer the "main" 'git credential' command or any of the credential
helpers from contrib/credential/ when completing git commands.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-06 15:17:05 -07:00
SZEDER Gábor af16bdaa3f completion: fix and update 'git log --decorate=' options
'git log --decorate=' understands the 'full', 'short' and 'no' options.
From these the completion script only offered 'short' and it offered
'long' instead of 'full'.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-03 11:46:14 -07:00
SZEDER Gábor 110062a134 completion: remove redundant __git_compute_all_commands() call
During lazy-initialization of the lists of all commands and porcelain
commands the function __git_compute_all_commands() is called twice.  The
relevant part of the call sequence looks like this:

  __git_compute_porcelain_commands()
     __git_compute_all_commands()
        <finds list of all commands uninitialized>
        __git_list_all_commands()
        <initializes list of all commands>
     __git_list_porcelain_commands()
        __git_compute_all_commands()
           <finds list of all commands already initialized, does nothing>
        <filters porcelains from list of all commands>

Either one of the two calls could be removed and the initialization of
both command lists would still work as a whole, but let's remove the call
from __git_compute_porcelain_commands(), because this way
__git_list_porcelain_commands() will keep working in itself.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-03 11:44:49 -07:00
Junio C Hamano 89ba311df3 Merge branch 'ma/bash-completion-leaking-x' into maint
The completion script (in contrib/) contaminated global namespace
and clobbered on a shell variable $x.

* ma/bash-completion-leaking-x:
  completion: fix global bash variable leak on __gitcompappend
2015-04-27 12:23:51 -07:00
Junio C Hamano 6b1258b07b Merge branch 'ma/bash-completion-leaking-x'
The completion script (in contrib/) contaminated global namespace
and clobbered on a shell variable $x.

* ma/bash-completion-leaking-x:
  completion: fix global bash variable leak on __gitcompappend
2015-04-20 15:28:30 -07:00
Márcio Almada 852ff1c362 completion: fix global bash variable leak on __gitcompappend
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-12 22:35:51 -07:00
Junio C Hamano 4eea8e3fa0 Merge branch 'sg/completion-gitcomp-nl-for-refs' into maint
Code clean-up.

* sg/completion-gitcomp-nl-for-refs:
  completion: use __gitcomp_nl() for completing refs
2015-03-28 09:33:15 -07:00
Junio C Hamano 245dd15aa9 Merge branch 'ct/prompt-untracked-fix' into maint
The prompt script (in contrib/) did not show the untracked sign
when working in a subdirectory without any untracked files.

* ct/prompt-untracked-fix:
  git prompt: use toplevel to find untracked files
2015-03-28 09:33:12 -07:00
Junio C Hamano 792c57273f Merge branch 'js/completion-ctags-pattern-substitution-fix' into maint
The code that reads from the ctags file in the completion script
(in contrib/) did not spell ${param/pattern/string} substitution
correctly, which happened to work with bash but not with zsh.

* js/completion-ctags-pattern-substitution-fix:
  contrib/completion: escape the forward slash in __git_match_ctag
2015-03-27 13:00:18 -07:00
Junio C Hamano 55a3b3c26e Merge branch 'sg/completion-gitcomp-nl-for-refs'
Code clean-up.

* sg/completion-gitcomp-nl-for-refs:
  completion: use __gitcomp_nl() for completing refs
2015-03-26 11:57:13 -07:00
Junio C Hamano 5f15cba2f9 Merge branch 'ct/prompt-untracked-fix'
The prompt script (in contrib/) did not show the untracked sign
when working in a subdirectory without any untracked files.

* ct/prompt-untracked-fix:
  git prompt: use toplevel to find untracked files
2015-03-25 12:54:18 -07:00
Junio C Hamano c267a4d013 Merge branch 'js/completion-ctags-pattern-substitution-fix'
The code that reads from the ctags file in the completion script
(in contrib/) did not spell ${param/pattern/string} substitution
correctly, which happened to work with bash but not with zsh.

* js/completion-ctags-pattern-substitution-fix:
  contrib/completion: escape the forward slash in __git_match_ctag
2015-03-23 11:28:16 -07:00
Junio C Hamano 61ca378275 Merge branch 'jk/push-config'
Restructure "git push" codepath to make it easier to add new
configuration bits and then add push.followTags configuration that
turns --follow-tags option on by default.

* jk/push-config:
  push: allow --follow-tags to be set by config push.followTags
  cmd_push: pass "flags" pointer to config callback
  cmd_push: set "atomic" bit directly
  git_push_config: drop cargo-culted wt_status pointer
2015-03-23 11:28:14 -07:00
Junio C Hamano 7d6f6e3730 Merge branch 'sg/completion-remote' into maint
Code simplification.

* sg/completion-remote:
  completion: simplify __git_remotes()
  completion: add a test for __git_remotes() helper function
2015-03-23 11:23:33 -07:00
SZEDER Gábor 260d5850ad completion: use __gitcomp_nl() for completing refs
We do that almost everywhere, because it's faster for large number of
refs, see a31e62629 (completion: optimize refs completion, 2011-10-15).
These were the last two places where we still used __gitcomp() for
completing refs.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-22 16:41:12 -07:00
Junio C Hamano 2a39bdb9a1 Merge branch 'mg/doc-status-color-slot'
Documentation fixes.

* mg/doc-status-color-slot:
  config,completion: add color.status.unmerged
2015-03-17 16:01:34 -07:00
Junio C Hamano e5b8ce243c Merge branch 'sg/completion-remote'
Code simplification.

* sg/completion-remote:
  completion: simplify __git_remotes()
  completion: add a test for __git_remotes() helper function
2015-03-17 16:01:30 -07:00
Cody A Taylor 9bdc5173f0 git prompt: use toplevel to find untracked files
The __git_ps1() prompt function would not show an untracked state
when all the untracked files are outside the current working
directory.

Signed-off-by: Cody A Taylor <codemister99@yahoo.com>
Helped-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-15 14:23:22 -07:00
John Szakmeister db8d750876 contrib/completion: escape the forward slash in __git_match_ctag
The current definition results in an incorrect expansion of the term under zsh.
For instance "/^${1////\\/}/" under zsh with the argument "hi" results in:
    /^/\/h/\/i/

This results in an output similar to this when trying to complete `git grep
chartab` under zsh:

    :: git grep chartabawk: cmd. line:1: /^/\/c/\/h/\/a/\/r/\/t/\/a/\/b/ { print $1 }
    awk: cmd. line:1:    ^ backslash not last character on line
    awk: cmd. line:1: /^/\/c/\/h/\/a/\/r/\/t/\/a/\/b/ { print $1 }
    awk: cmd. line:1:    ^ syntax error

Leaving the prompt in a goofy state until the user hits a key.

Escaping the literal / in the parameter expansion (using "/^${1//\//\\/}/")
results in:
    /^chartab/

allowing the completion to work correctly.

This formulation also works under bash.

Signed-off-by: John Szakmeister <john@szakmeister.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-14 18:59:09 -07:00
Dave Olszewski a8bc269f11 push: allow --follow-tags to be set by config push.followTags
Signed-off-by: Dave Olszewski <cxreg@pobox.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-14 15:08:35 -07:00
Michael J Gruber 0d6accc01d config,completion: add color.status.unmerged
Reported-by: "Mladen B." <mladen074@gmail.com>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-10 15:27:59 -07:00
SZEDER Gábor 53e53c7c81 completion: simplify __git_remotes()
The __git_remotes() helper function lists the remotes from the config
file by processing the output of a 'git config' query.  A simple 'git
remote' produces the exact same output, so run that instead.

Remotes under '$GIT_DIR/remotes' are still listed by running 'ls -1',
because 'git remote' unfortunately ignores them.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-06 12:48:02 -08:00