remote: add a test for extra arguments, according to docs

This adds one test or comment for each subcommand of git-remote
according to its current documentation.  All but 'set-branches' and
'update' are listed as taking only a fixed number of arguments; for
those we can write a test with one more (bogus) argument, and see if
the command notices that.

They fail on several counts: 'add' does not check for extra arguments,
and 'show' and 'prune' actually iterate over remotes (i.e., take any
number of args).  We'll fix them in the next two patches.

The -f machinery is only there to make the tests readable while still
ensuring they pass as a whole, and will be removed in the final patch.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote: check for superfluous arguments in 'git remote add'

The 'git remote add' subcommand did not check for superfluous command
line arguments.  Make it so.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote: 'show' and 'prune' can take more than one remote

The 'git remote show' and 'prune' subcommands are documented as taking
only a single remote name argument, but that is not the case; they
will simply iterate the action over all remotes given.  Update the
documentation and tests to match.

With the last user of the -f flag gone, we also remove the code
supporting it.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bash-prompt.sh: show where rebase is at when stopped

When a rebase stops (e.g. interrupted by a merge conflict), it could
be useful to know how far a rebase has progressed and how many
commits in total this rebase will apply. Teach the __git_ps1()
command to display the number of commits so far applied and the
total number of commits to be applied, like this:

  ((3ec0a6a...)|REBASE 2/5)

In the example above the rebase has stopped at the second commit due to
a merge conflict and there are a total number of five commits to be
applied by this rebase.

This information can be already obtained from the following files which are
being generated during the rebase:

    GIT_DIR/.git/rebase-merge/msgnum (git-rebase--merge.sh)
    GIT_DIR/.git/rebase-merge/end    (git-rebase--merge.sh)
    GIT_DIR/.git/rebase-apply/next   (git-am.sh)
    GIT_DIR/.git/rebase-apply/last   (git-am.sh)

but "rebase -i" does not leave necessary clues.

Implement this feature by doing these three things:

  1) Modify git-rebase--interactive.sh to also create

	GIT_DIR/.git/rebase-merge/msgnum
	GIT_DIR/.git/rebase-merge/end

     files for the number of commits so far applied and the total
     number of commits to be applied.

  2) Modify git-prompt.sh to read and display info from the above
     files.

  3) Update test t9903-bash-prompt.sh to reflect changes introduced
     by this patch.

Signed-off-by: Zoltan Klinger <zoltan.klinger@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pretty: simplify input line length calculation in pp_user_info()

Instead of searching for LF and NUL with two strchr() calls use a single
strchrnul() call.  We don't need to check if the returned pointer is NULL
because either we'll find the NUL at the end of line, or the caller
forgot to NUL-terminate the string and we'll overrun the buffer in any
case.  Also we don't need to pass LF or NUL to split_ident_line() as it
ignores it anyway.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pretty: simplify output line length calculation in pp_user_info()

Keep namelen unchanged and don't use it to hold a value that we're not
interested in anyway -- we can use maillen and the constant part
directly instead.  This simplifies the code slightly and prepares for
the next patch that makes use of the original value of namelen.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pretty: remove intermediate strbufs from pp_user_info()

Use namebuf/namelen and mailbuf/maillen directly instead of copying
their contents into strbufs first.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Git.pm: call tempfile from File::Temp as a regular function

We call File::Temp's "tempfile" function as a class method, but it was
never designed to be called this way. Older versions seemed to
tolerate it, but as of File::Temp 0.23, it blows up like this:

  $ git svn fetch
  'tempfile' can't be called as a method at .../Git.pm line 1117.

Fix it by calling it as a regular function, just inside the File::Temp
namespace.

Signed-off-by: H. Merijn Brand <h.m.brand@xs4all.nl>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-completion.bash: lexical sorting for diff.statGraphWidth

df44483a (diff --stat: add config option to limit graph width,
2012-03-01) added the option diff.startGraphWidth to the list of
configuration variables in git-completion.bash, but failed to notice
that the list is sorted alphabetically.  Move it to its rightful place
in the list.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-completion.bash: add diff.submodule to config list

c47ef57 (diff: introduce diff.submodule configuration variable,
2012-11-13) introduced the diff.submodule configuration variable, but
forgot to teach git-completion.bash about it.  Fix this.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-completion.bash: complete branch.*.rebase as boolean

6fac1b83 (completion: add missing config variables, 2009-06-29) added
"rebase" to the list of completions for "branch.*.*", but forgot to
specify completions for the values that this configuration variable
can take (namely "false" and "true").  Fix this.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
complete: zsh: trivial simplification

There should be no functional changes.

The only reason I wrapped this code around a sub-function is because zsh
did the same in it's bashcompinit script in order to declare the special
variable 'words' as hidden, but only in this context.

There's no need for that any more since we access __git_main directly,
so 'words' is not modified, so there's no need for the sub-function.

In zsh mode the array indexes are different though.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
complete: zsh: use zsh completion for the main cmd

So that we can have a nice zsh completion output:

% git <tab>
add       -- add file contents to the index
bisect    -- find by binary search the change that introduced a bug
branch    -- list, create, or delete branches
checkout  -- checkout a branch or paths to the working tree
clone     -- clone a repository into a new directory
commit    -- record changes to the repository
diff      -- show changes between commits, commit and working tree, etc
fetch     -- download objects and refs from another repository
grep      -- print lines matching a pattern
init      -- create an empty Git repository or reinitialize an existing one
log       -- show commit logs
merge     -- join two or more development histories together
mv        -- move or rename a file, a directory, or a symlink
pull      -- fetch from and merge with another repository or a local branch
push      -- update remote refs along with associated objects
rebase    -- forward-port local commits to the updated upstream head
reset     -- reset current HEAD to the specified state
rm        -- remove files from the working tree and from the index
show      -- show various types of objects
status    -- show the working tree status
tag       -- create, list, delete or verify a tag object signed with GPG

And other niceties, like 'git --git-dir=<tab>' showing only directories.

For the rest, the bash completion stuff is still used.

Also, add my copyright, since this more than a thin wrapper.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'fc/zsh-completion' into maint

* fc/zsh-completion:
  complete: zsh: use zsh completion for the main cmd
  complete: zsh: trivial simplification
Merge branch 'maint'

* maint:
  complete: zsh: use zsh completion for the main cmd
  complete: zsh: trivial simplification
  git-completion.bash: complete branch.*.rebase as boolean
  git-completion.bash: add diff.submodule to config list
  git-completion.bash: lexical sorting for diff.statGraphWidth
git-completion.bash: add branch.*.pushremote to config list

9f765ce (remote.c: introduce branch.<name>.pushremote, 2013-04-02)
introduced the configuration variable branch.*.pushremote, but forgot
to teach git-completion.bash about it.  Fix this.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-completion.bash: add remote.pushdefault to config list

224c2171 (remote.c: introduce remote.pushdefault, 2013-04-02)
introduced the remote.pushdefault configuration variable, but forgot
to teach git-completion.bash about it.  Fix this.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'zk/prompt-rebase-step'

* zk/prompt-rebase-step:
  bash-prompt.sh: show where rebase is at when stopped
Merge branch 'tr/remote-tighten-commandline-parsing'

* tr/remote-tighten-commandline-parsing:
  remote: 'show' and 'prune' can take more than one remote
  remote: check for superfluous arguments in 'git remote add'
  remote: add a test for extra arguments, according to docs
Merge branch 'rs/pp-user-info-without-extra-allocation'

* rs/pp-user-info-without-extra-allocation:
  pretty: remove intermediate strbufs from pp_user_info()
  pretty: simplify output line length calculation in pp_user_info()
  pretty: simplify input line length calculation in pp_user_info()