Commit Graph

1436 Commits

Author SHA1 Message Date
Junio C Hamano
ee02c2ab37 Merge branch 'mm/credential-plumbing'
Expose the credential API to scripted Porcelain writers.

* mm/credential-plumbing:
  git-remote-mediawiki: update comments to reflect credential support
  git-remote-mediawiki: add credential support
  git credential fill: output the whole 'struct credential'
  add 'git credential' plumbing command
2012-07-09 09:01:45 -07:00
Matthieu Moy
2da7830d5c git-remote-mediawiki: update comments to reflect credential support
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-08 18:44:43 -07:00
Junio C Hamano
e90020cdb3 Merge branch 'fc/git-prompt-script'
Split a rather heavy-ish "git completion" script out to create a
separate "git prompting" script, to help lazy-autoloading of the
completion part while making prompting part always available.
2012-06-28 15:21:00 -07:00
Matthieu Moy
a7271ad1dc git-remote-mediawiki: add credential support
The previous version implemented the possibility to log in a wiki, but
the username and password had to be provided as configuration variables.
We add the possibility to use the Git credential system to prompt
the password.

The support if implemented with generic functions that mimic the C API,
designed to be usable from other contexts in the future (i.e. they may
migrate to Git.pm if someone is interested).

While we're there, do a bit of refactoring in mw_connect_maybe.

Based on patch by: Javier Roucher Iglesias <Javier.Roucher-Iglesias@ensimag.imag.fr>

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-25 11:56:24 -07:00
Junio C Hamano
6a7f2b2396 Merge branch 'lm/git-blame-el'
eLisp fixes for a contrib/ script.

* lm/git-blame-el:
  git-blame.el: Do not use bare 0 to mean (point-min)
  git-blame.el: Use with-current-buffer where appropriate
  git-blame.el: Do not use goto-line in lisp code
2012-06-25 11:25:12 -07:00
Junio C Hamano
d692d34653 Merge branch 'rs/git-blame-mapcar-mapc'
* rs/git-blame-mapcar-mapc:
  git-blame.el: use mapc instead of mapcar
2012-06-25 11:24:53 -07:00
SZEDER Gábor
b7be4366ea completion: respect $GIT_DIR
The __gitdir() helper function finds out the path of the git
repository by running 'git rev-parse --git-dir'.  However, it has a
shortcut first to avoid the overhead of running a git command in a
subshell when the current directory is at the top of the work tree,
i.e. when it contains a '.git' subdirectory.

If the 'GIT_DIR' environment variable is set then it specifies the
path to the git repository, and the autodetection of the '.git'
directory is not necessary.  However, $GIT_DIR is only taken into
acocunt by 'git rev-parse --git-dir', and the check for the '.git'
subdirectory is performed first, so it wins over the path given in
$GIT_DIR.

There are several completion (helper) functions that depend on
__gitdir(), and when the above case triggers the completion script
will do weird things, like offering refs, aliases, or stashes from a
different repository, or displaying wrong or broken prompt, etc.

So check first whether $GIT_DIR is set, and only proceed with checking
the '.git' directory in the current directory if it isn't.  'git
rev-parse' would also check whether the path in $GIT_DIR is a proper
'.git' directory, i.e. 'HEAD', 'refs/', and 'objects/' are present and
accessible, but we don't have to be that thorough for the bash prompt.
And we've lived with an equally permissive check for '.git' in the
current working directory for years anyway.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-19 15:48:12 -07:00
Lawrence Mitchell
32663b2241 git-blame.el: Do not use bare 0 to mean (point-min)
Signed-off-by: Lawrence Mitchell <wence@gmx.li>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-14 10:59:16 -07:00
Lawrence Mitchell
0e59a6f601 git-blame.el: Use with-current-buffer where appropriate
In git-blame-filter and git-blame-create-overlay we want to save
(along with the values of point and mark) the current-buffer in scope
when calling the functions.  The idiom

    (save-excursion
      (set-buffer buf)
      ...)

will correctly restore the correct buffer, but will not save the
values of point and mark in buf (only in the buffer current when the
save-excursion call is executed).  The intention of these functions is
to save the current buffer from the calling scope and the values of
point and mark in the buffer they are modifying.  The correct idiom
for this is

    (with-current-buffer buf
      (save-excursion
        ...))

Signed-off-by: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
Signed-off-by: Lawrence Mitchell <wence@gmx.li>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-14 10:59:15 -07:00
Rüdiger Sonderfeld
5d7da9a944 git-blame.el: Do not use goto-line in lisp code
goto-line is a user-level command, instead use the lisp-level
construct recommended in Emacs documentation.

Signed-off-by: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
Signed-off-by: Lawrence Mitchell <wence@gmx.li>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-14 10:59:09 -07:00
Junio C Hamano
2cf4cfa7e9 Merge branch 'fc/git-complete-helper-fix'
* fc/git-complete-helper-fix:
  completion: put main git and gitk completion functions back into git namespace
2012-06-13 11:47:11 -07:00
SZEDER Gábor
1dad5c14f9 completion: remove credential helpers from porcelain commands
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-13 10:24:46 -07:00
SZEDER Gábor
93b291e071 completion: put main git and gitk completion functions back into git namespace
Commit 7f02f3d7 (completion: rename internal helpers _git and _gitk,
2012-05-19) renamed said functions to _main_git() and _main_gitk(),
respectively.  By convention the name of our git-completion-specific
functions start with '_git' or '__git' prefix, so rename those
functions once again to put them back into our "namespace".  Use the
two underscore prefix, because _git_main() could be mistaken for the
completion function of the (not yet existing) 'git main' command.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-13 10:23:54 -07:00
Rüdiger Sonderfeld
cbbc935ce0 git-blame.el: use mapc instead of mapcar
Using mapcar here is a waste of memory because the mapped result
is not used.

Noticed by emacs ("Warning: `mapcar' called for effect").

[jn: split from a larger patch, with new description]

Signed-off-by: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-10 00:49:00 -07:00
Junio C Hamano
ac3eb1c384 completion: warn people about duplicated function
The __gitdir function is duplicated between completion and prompt
scripts, and these definitions should not diverge; otherwise one of
them can be subtly broken depending on the order the user's shell
dot-sources them.

Leave a note to people who may want to touch one copy to make sure
they update the other one in sync.  Hopefully this line would also
appear in the context of the patch to allow reviewers to notice a
patch that attempts to update only one of them.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-10 00:34:38 -07:00
Junio C Hamano
ecde699a47 Merge branch 'cr/persistent-https'
A remote helper that acts as a proxy and caches ssl session for the
https:// transport is added to the contrib/ area.

By Colby Ranger
* cr/persistent-https:
  Add persistent-https to contrib
2012-06-07 09:06:39 -07:00
Colby Ranger
fe0435011c Add persistent-https to contrib
Git over HTTPS has a high request startup latency, since the SSL
negotiation can take up to a second. In order to reduce this latency,
connections should be left open to the Git server across requests
(or invocations of the git commandline).

Reduce SSL startup latency by running a daemon job that keeps
connections open to a Git server. The daemon job
(git-remote-persistent-https--proxy) is started on the first request
through the client binary (git-remote-persistent-https) and remains
running for 24 hours after the last request, or until a new daemon
binary is placed in the PATH. The client determines the daemon's
HTTP address by communicating over a UNIX socket with the daemon.
From there, the rest of the Git protocol work is delegated to the
"git-remote-http" binary, with the environment's http_proxy set to
the daemon.

Accessing /pub/scm/linux/kernel/git/torvalds/linux repository hosted
at kernel.googlesource.com with "git ls-remote" over https:// and
persistent-https:// 5 times shows that the first request takes about
the same time (0.193s vs 0.208s---there is a slight set-up cost for
the local proxy); as expected, the other four requests are much
faster (~0.18s vs ~0.08s).

Incidentally, this also has the benefit of HTTP keep-alive working
across Git command invocations. Its common for servers to use a 5
minute keep-alive on an HTTP 1.1 connection. Git-over-HTTP commonly
uses Transfer-Encoding: chunked on replies, so keep-alive will
generally just work, even though a pack stream's length isn't known
in advance. Because the helper is an external process holding that
connection open, we also benefit from being able to reuse an
existing TCP connection to the server.  The same "git ls-remote"
test against http:// vs persistent-https:// URL shows that the
former takes ~0.09s while the first request for the latter is about
0.134s with set-up cost, and subsequent requests are ~0.065s,
shaving around one RTT to the server.

Signed-off-by: Colby Ranger <cranger@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-30 13:50:45 -07:00
Junio C Hamano
b19ea23473 Merge branch 'fc/git-complete-helper-fix'
Resurrects old behaviour of _git/_gitk for external users.
2012-05-25 12:07:09 -07:00
Junio C Hamano
5bc2dc29d4 Sync with maint
By Jeff King (1) and Junio C Hamano (1)
* maint:
  Update draft release notes to 1.7.10.3
  osxkeychain: pull make config from top-level directory
2012-05-24 17:37:40 -07:00
Jeff King
17a9ac7d6b osxkeychain: pull make config from top-level directory
The default compiler and cflags were mostly "works for me"
when I built the original version. We need to be much less
careful here than usual, because we know we are building
only on OS X.  But it's only polite to at least respect the
CFLAGS and CC definitions that the user may have provided
earlier.

While we're at it, let's update our definitions and rules to
be more like the top-level Makefile; default our CFLAGS to
include -O2, and make sure we use CFLAGS and LDFLAGS when
linking.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-24 10:35:40 -07:00
Felipe Contreras
af31a456b4 completion: split __git_ps1 into a separate script
bash-completion 1.90 shipped with support to load completions
dynamically[1], which means the git completion script wouldn't be loaded
until the user types 'git <tab>'--this creates a problem to people using
__git_ps1(); that function won't be available when the shell is first
created.

For now distributions have workarounded this issue by moving the git
completion to the "compatdir"[2]; this of course is not ideal.

The solution, proposed by Kerrick Staley[3], is to split the git script
in two; the part that deals with __git_ps1() in one (i.e.
git-prompt.sh), and everything else in another (i.e.
git-completion.bash).

Another benefit of this is that zsh user that are not interested in the
bash completion can use it for their prompts, which has been tried
before[4].

The only slight issue is that __gitdir() would be duplicated, but this
is probably not a big deal.

So let's go ahead and move __git_ps1() to a new file.

While at this, I took the liberty to reformat the help text in the new
file.

 [1] http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=commitdiff;h=99c4f7f25f50a7cb2fce86055bddfe389effa559
 [2] http://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/git&id=974380fabb8f9f412990b17063bf578d98c44a82
 [3] http://mid.gmane.org/CANaWP3w9KDu57aHquRRYt8td_haSWTBKs7zUHy-xu0B61gmr9A@mail.gmail.com
 [4] http://mid.gmane.org/1303824288-15591-1-git-send-email-mstormo@gmail.com

Cc: Kerrick Staley <mail@kerrickstaley.com>
Cc: Marius Storm-Olsen <mstormo@gmail.com>
Cc: Ville Skyttä <ville.skytta@iki.fi>
Cc: Dan McGee <dan@archlinux.org>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-22 15:35:02 -07:00
Felipe Contreras
1098ff5a21 completion: remove executable mode
No reason to have it executable. Every way this script is intended to be
used includes the 'source' command.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-22 15:35:00 -07:00
Felipe Contreras
b0a4b2d257 completion: add support for backwards compatibility
Some people might be relying on _git and _gitk to define custom aliases,
unfortunately, commit 6b179ad (completion: add new __git_complete
helper) broke that support.

  "bash: [: 1: unary operator expected"

This can be easily fixed by using __git_complete, but it's not meant to
be public.

Although _git and _gitk are probably not meant to be public, it's easy
to keep having support for them by having a wrapper to the proper
new function that is fully functional.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-20 14:48:28 -07:00
Felipe Contreras
7f02f3d7ec completion: rename internal helpers _git and _gitk
Would be useful to provide backwards compatibility for _git. Also, zsh
completion uses _git, and it cannot be changed.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-20 14:47:54 -07:00
Junio C Hamano
8be441ea1f Merge branch 'fc/git-complete-helper'
By Felipe Contreras
* fc/git-complete-helper:
  completion: add new __git_complete helper
2012-05-17 15:21:55 -07:00
Junio C Hamano
fca9249b86 Merge branch 'fc/simplify-complete-revlist-file'
By Felipe Contreras
* fc/simplify-complete-revlist-file:
  completion: simplify __git_complete_revlist_file
2012-05-14 11:50:57 -07:00
Felipe Contreras
6b179adfe9 completion: add new __git_complete helper
This simplifies the completions, and would make it easier to define
aliases in the future.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-14 10:33:33 -07:00
Felipe Contreras
41e6229db4 completion: simplify __git_complete_revlist_file
Use new __gitcomp_nl; this is the last place that uses COMPREPLY and
compgen directly outside __gitcomp* functions.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Acked-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-07 10:15:41 -07:00
Junio C Hamano
2fa4fff4b9 Merge branch 'pw/message-cleanup'
Many error/warning messages had extra trailing newlines that are
unnecessary.

By Pete Wyckoff
* pw/message-cleanup:
  remove blank filename in error message
  remove superfluous newlines in error messages
2012-05-02 13:53:35 -07:00
Junio C Hamano
7b871c53db Merge branch 'jc/rerere-train'
A script written long time ago proved to be useful this week for me ;-)
with a minor tweak.

* jc/rerere-train:
  contrib/rerere-train: use installed git-sh-setup
2012-05-02 13:53:15 -07:00
Pete Wyckoff
82247e9bd5 remove superfluous newlines in error messages
The error handling routines add a newline.  Remove
the duplicate ones in error messages.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-30 15:45:51 -07:00
Junio C Hamano
53876fcf3f contrib/rerere-train: use installed git-sh-setup
Instead of sourcing git-sh-setup from random place that is on the $PATH,
explicitly source $(git --exec-path)/git-sh-setup.  As I do not personally
have any libexec/git-core directory on my $PATH like many other people, the
script will fail without this update.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-30 12:50:38 -07:00
Junio C Hamano
745ef0625b Merge branch 'fc/completion-tests'
By Felipe Contreras (4) and others
* fc/completion-tests:
  completion: fix completion after 'git --option <TAB>'
  completion: avoid trailing space for --exec-path
  completion: add missing general options
  completion: simplify by using $prev
  completion: simplify __gitcomp_1
  tests: add tests for the __gitcomp() completion helper function
  tests: add initial bash completion tests
2012-04-24 14:41:22 -07:00
Junio C Hamano
4c9d7bc4a6 Merge branch 'pw/git-p4'
By Pete Wyckoff
* pw/git-p4:
  git p4: use "git p4" directly in tests
  git p4: update name in script
  git-p4: move to toplevel
2012-04-23 12:40:03 -07:00
SZEDER Gábor
911d5da6f2 completion: fix completion after 'git --option <TAB>'
The bash completion doesn't work when certain options to git itself are
specified, e.g. 'git --no-pager <TAB>' errors out with

    error: invalid key: alias.--no-pager

The main _git() completion function finds out the git command name by
looping through all the words on the command line and searching for
the first word that is not a known option for the git command.

Unfortunately the list of known git options was not updated in a long
time, and newer options are not skipped but mistaken for a git command.
Such a misrecognized "command" is then passed to __git_aliased_command(),
which in turn passes it to a 'git config' query, hence the error.

Currently the following options are misrecognized for a git command:

  -c --no-pager --exec-path --html-path --man-path --info-path
  --no-replace-objects --work-tree= --namespace=

To fix this we could just update the list of options to be skipped,
but the same issue will likely arise, if the git command learns a new
option in the future.  Therefore, to make it more future proof against
new options, this patch changes that loop to skip all option-looking
words, i.e. words starting with a dash.

We also have to handle the '-c' option specially, because it takes a
configutation parameter in a separate word, which must be skipped,
too.

[fc: added tests]

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-21 22:39:07 -07:00
Jonathan Nieder
3ffcd08688 completion: avoid trailing space for --exec-path
"--exec-path" looks to the completion script like an unambiguous
successful completion, but it is wrong to emit a SP after it as if
declaring that we are done with completion; the user could be trying
to do

	git --exec-path; # print name of helper directory

or

	git --exec-path=/path/to/alternative/helper/dir <subcommand>

so the most helpful thing to do is to leave out the trailing space and
leave it to the operator to type an equal sign or carriage return
according to the situation.

[fc: added tests]

Cc: Andreas Schwab <schwab@linux-m68k.org>
Reported-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-21 22:39:07 -07:00
Felipe Contreras
69ef3c0296 completion: add missing general options
And add relevant tests.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-21 22:39:06 -07:00
Felipe Contreras
3954068128 completion: simplify by using $prev
cword-1 is the previous word ($prev).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-21 22:39:06 -07:00
Felipe Contreras
3bf421ea62 completion: simplify __gitcomp_1
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-21 22:39:06 -07:00
David A. Greene
926b1ec63e Fix git-subtree install instructions
Update the install instructions to reflect the changes for an
integrated git-subtree.

Signed-off-by: David A. Greene <greened@obbligato.org>
2012-04-09 22:26:19 -05:00
David A. Greene
311391da90 Use git-subtree test Makefile
Use the Makefile in contrib/subtree/t to run git-subtree tests.

Signed-off-by: David A. Greene <greened@obbligato.org>
2012-04-09 22:26:19 -05:00
David A. Greene
c3d884a688 Add subtree test Makefile
Add a Makefile to run subtree tests.  This is largely copied
from the standard test suite with irrelevant targets removed
and some paths altered to account for where subtree tests live.

Signed-off-by: David A. Greene <greened@obbligato.org>
2012-04-09 22:26:10 -05:00
David A. Greene
7ff8463dba Install git-subtree from contrib
Build git-subtree in its contrib directory and install from there.
The main Makefile no longer discovers subcommands build in the main
build area so we cannot count on it to install git-subtree.  The user
should make && make install in contrib/subtree to install git-subtree.

Change the rule to install the git-subtree manpage.  The main
Documentation area doesn't directly support installing documentation
from other directories so the user will have to do that from within
contrib/subtree for now.

Signed-off-by: David A. Greene <greened@obbligato.org>
2012-04-09 22:26:10 -05:00
David A. Greene
187bc2da5b Use configure settings for git-subtree
Include config.make.autogen in the git-subtree contrib area to pick up
settings for prefix and other such things.

Signed-off-by: David A. Greene <greened@obbligato.org>
2012-04-09 22:26:10 -05:00
David A. Greene
5163d476d0 Use project config files
Use project-wide files to process documentation for git-subtree.

Signed-off-by: David A. Greene <greened@obbligato.org>
2012-04-09 22:25:58 -05:00
David A. Greene
c96c5383ff Remove unnecessary git-subtree files
Remove various files that simply duplicate functionality already
provided by the main project files.

Signed-off-by: David A. Greene <greened@obbligato.org>
2012-04-09 22:11:25 -05:00
David A. Greene
603ee0f0c3 Set TEST_DIRECTORY
Set TEST_DIRECTORY to the main git test area.  This allows the
git-subtree out-of-tree tests to run correctly.

Signed-off-by: David A. Greene <greened@obbligato.org>
2012-04-09 20:23:10 -05:00
David A. Greene
634392b262 Add 'contrib/subtree/' from commit 'd3a04e06c77d57978bb5230361c64946232cc346'
git-subtree-dir: contrib/subtree
git-subtree-mainline: e8dde3e5f9
git-subtree-split: d3a04e06c7
2012-04-09 20:22:55 -05:00
Pete Wyckoff
b6f9305764 git-p4: move to toplevel
Move git-p4 out of contrib/fast-import into the main code base,
aside other foreign SCM tools.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-09 14:59:40 -07:00
Jim Meyering
a7793a7491 correct spelling: an URL -> a URL
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-28 08:47:23 -07:00