Browse Source
* sb/fetch: (41 commits) merge and resolve: Output short hashes and .. in "Updating ..." fetch: Misc output cleanup gitweb: tree view: hash_base and hash are now context sensitive fetch: Reset remote refs list each time fetch_main is called Fix approxidate() to understand 12:34 AM/PM are 00:34 and 12:34 git-diff -B output fix. Make cvsexportcommit remove files. diff --stat: ensure at least one '-' for deletions, and one '+' for additions diff --stat=width[,name-width]: allow custom diffstat output width. gitweb: History: blob and tree are first, then commitdiff, etc gitweb: Remove redundant "commit" from history http/ftp: optionally ask curl to not use EPSV command gitweb: Don't use quotemeta on internally generated strings gitweb: Add snapshot to shortlog gitweb: Factor out gitweb_have_snapshot() gitweb: Remove redundant "commit" link from shortlog gitweb: "alternate" starts with shade (i.e. 1) git-format-patch: fix bug using -o in subdirectories do not discard constness in interp_set_entry value argument Fix approxidate() to understand more extended numbers ...maint
Junio C Hamano
18 years ago
22 changed files with 1202 additions and 255 deletions
@ -0,0 +1,220 @@
@@ -0,0 +1,220 @@
|
||||
/* |
||||
* Copyright (C) 1996-2001 Internet Software Consortium. |
||||
* |
||||
* Permission to use, copy, modify, and distribute this software for any |
||||
* purpose with or without fee is hereby granted, provided that the above |
||||
* copyright notice and this permission notice appear in all copies. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM |
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL |
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, |
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING |
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
*/ |
||||
|
||||
#include <errno.h> |
||||
#include <sys/types.h> |
||||
#include <sys/socket.h> |
||||
#include <sys/socket.h> |
||||
#include <netinet/in.h> |
||||
#include <arpa/inet.h> |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
|
||||
#ifndef NS_INT16SZ |
||||
#define NS_INT16SZ 2 |
||||
#endif |
||||
|
||||
#ifndef NS_INADDRSZ |
||||
#define NS_INADDRSZ 4 |
||||
#endif |
||||
|
||||
#ifndef NS_IN6ADDRSZ |
||||
#define NS_IN6ADDRSZ 16 |
||||
#endif |
||||
|
||||
/* |
||||
* WARNING: Don't even consider trying to compile this on a system where |
||||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. |
||||
*/ |
||||
|
||||
static int inet_pton4(const char *src, unsigned char *dst); |
||||
static int inet_pton6(const char *src, unsigned char *dst); |
||||
|
||||
/* int |
||||
* inet_pton4(src, dst) |
||||
* like inet_aton() but without all the hexadecimal and shorthand. |
||||
* return: |
||||
* 1 if `src' is a valid dotted quad, else 0. |
||||
* notice: |
||||
* does not touch `dst' unless it's returning 1. |
||||
* author: |
||||
* Paul Vixie, 1996. |
||||
*/ |
||||
static int |
||||
inet_pton4(const char *src, unsigned char *dst) |
||||
{ |
||||
static const char digits[] = "0123456789"; |
||||
int saw_digit, octets, ch; |
||||
unsigned char tmp[NS_INADDRSZ], *tp; |
||||
|
||||
saw_digit = 0; |
||||
octets = 0; |
||||
*(tp = tmp) = 0; |
||||
while ((ch = *src++) != '\0') { |
||||
const char *pch; |
||||
|
||||
if ((pch = strchr(digits, ch)) != NULL) { |
||||
unsigned int new = *tp * 10 + (pch - digits); |
||||
|
||||
if (new > 255) |
||||
return (0); |
||||
*tp = new; |
||||
if (! saw_digit) { |
||||
if (++octets > 4) |
||||
return (0); |
||||
saw_digit = 1; |
||||
} |
||||
} else if (ch == '.' && saw_digit) { |
||||
if (octets == 4) |
||||
return (0); |
||||
*++tp = 0; |
||||
saw_digit = 0; |
||||
} else |
||||
return (0); |
||||
} |
||||
if (octets < 4) |
||||
return (0); |
||||
memcpy(dst, tmp, NS_INADDRSZ); |
||||
return (1); |
||||
} |
||||
|
||||
/* int |
||||
* inet_pton6(src, dst) |
||||
* convert presentation level address to network order binary form. |
||||
* return: |
||||
* 1 if `src' is a valid [RFC1884 2.2] address, else 0. |
||||
* notice: |
||||
* (1) does not touch `dst' unless it's returning 1. |
||||
* (2) :: in a full address is silently ignored. |
||||
* credit: |
||||
* inspired by Mark Andrews. |
||||
* author: |
||||
* Paul Vixie, 1996. |
||||
*/ |
||||
|
||||
#ifndef NO_IPV6 |
||||
static int |
||||
inet_pton6(const char *src, unsigned char *dst) |
||||
{ |
||||
static const char xdigits_l[] = "0123456789abcdef", |
||||
xdigits_u[] = "0123456789ABCDEF"; |
||||
unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; |
||||
const char *xdigits, *curtok; |
||||
int ch, saw_xdigit; |
||||
unsigned int val; |
||||
|
||||
memset((tp = tmp), '\0', NS_IN6ADDRSZ); |
||||
endp = tp + NS_IN6ADDRSZ; |
||||
colonp = NULL; |
||||
/* Leading :: requires some special handling. */ |
||||
if (*src == ':') |
||||
if (*++src != ':') |
||||
return (0); |
||||
curtok = src; |
||||
saw_xdigit = 0; |
||||
val = 0; |
||||
while ((ch = *src++) != '\0') { |
||||
const char *pch; |
||||
|
||||
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) |
||||
pch = strchr((xdigits = xdigits_u), ch); |
||||
if (pch != NULL) { |
||||
val <<= 4; |
||||
val |= (pch - xdigits); |
||||
if (val > 0xffff) |
||||
return (0); |
||||
saw_xdigit = 1; |
||||
continue; |
||||
} |
||||
if (ch == ':') { |
||||
curtok = src; |
||||
if (!saw_xdigit) { |
||||
if (colonp) |
||||
return (0); |
||||
colonp = tp; |
||||
continue; |
||||
} |
||||
if (tp + NS_INT16SZ > endp) |
||||
return (0); |
||||
*tp++ = (unsigned char) (val >> 8) & 0xff; |
||||
*tp++ = (unsigned char) val & 0xff; |
||||
saw_xdigit = 0; |
||||
val = 0; |
||||
continue; |
||||
} |
||||
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && |
||||
inet_pton4(curtok, tp) > 0) { |
||||
tp += NS_INADDRSZ; |
||||
saw_xdigit = 0; |
||||
break; /* '\0' was seen by inet_pton4(). */ |
||||
} |
||||
return (0); |
||||
} |
||||
if (saw_xdigit) { |
||||
if (tp + NS_INT16SZ > endp) |
||||
return (0); |
||||
*tp++ = (unsigned char) (val >> 8) & 0xff; |
||||
*tp++ = (unsigned char) val & 0xff; |
||||
} |
||||
if (colonp != NULL) { |
||||
/* |
||||
* Since some memmove()'s erroneously fail to handle |
||||
* overlapping regions, we'll do the shift by hand. |
||||
*/ |
||||
const int n = tp - colonp; |
||||
int i; |
||||
|
||||
for (i = 1; i <= n; i++) { |
||||
endp[- i] = colonp[n - i]; |
||||
colonp[n - i] = 0; |
||||
} |
||||
tp = endp; |
||||
} |
||||
if (tp != endp) |
||||
return (0); |
||||
memcpy(dst, tmp, NS_IN6ADDRSZ); |
||||
return (1); |
||||
} |
||||
#endif |
||||
|
||||
/* int |
||||
* isc_net_pton(af, src, dst) |
||||
* convert from presentation format (which usually means ASCII printable) |
||||
* to network format (which is usually some kind of binary format). |
||||
* return: |
||||
* 1 if the address was valid for the specified address family |
||||
* 0 if the address wasn't valid (`dst' is untouched in this case) |
||||
* -1 if some other error occurred (`dst' is untouched in this case, too) |
||||
* author: |
||||
* Paul Vixie, 1996. |
||||
*/ |
||||
int |
||||
inet_pton(int af, const char *src, void *dst) |
||||
{ |
||||
switch (af) { |
||||
case AF_INET: |
||||
return (inet_pton4(src, dst)); |
||||
#ifndef NO_IPV6 |
||||
case AF_INET6: |
||||
return (inet_pton6(src, dst)); |
||||
#endif |
||||
default: |
||||
errno = EAFNOSUPPORT; |
||||
return (-1); |
||||
} |
||||
/* NOTREACHED */ |
||||
} |
@ -0,0 +1,324 @@
@@ -0,0 +1,324 @@
|
||||
# |
||||
# bash completion support for core Git. |
||||
# |
||||
# Copyright (C) 2006 Shawn Pearce |
||||
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). |
||||
# |
||||
# The contained completion routines provide support for completing: |
||||
# |
||||
# *) local and remote branch names |
||||
# *) local and remote tag names |
||||
# *) .git/remotes file names |
||||
# *) git 'subcommands' |
||||
# *) tree paths within 'ref:path/to/file' expressions |
||||
# |
||||
# To use these routines: |
||||
# |
||||
# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh). |
||||
# 2) Added the following line to your .bashrc: |
||||
# source ~/.git-completion.sh |
||||
# |
||||
|
||||
__git_refs () |
||||
{ |
||||
local cmd i is_hash=y |
||||
if [ -d "$1" ]; then |
||||
cmd=git-peek-remote |
||||
else |
||||
cmd=git-ls-remote |
||||
fi |
||||
for i in $($cmd "$1" 2>/dev/null); do |
||||
case "$is_hash,$i" in |
||||
y,*) is_hash=n ;; |
||||
n,*^{}) is_hash=y ;; |
||||
n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; |
||||
n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; |
||||
n,*) is_hash=y; echo "$i" ;; |
||||
esac |
||||
done |
||||
} |
||||
|
||||
__git_refs2 () |
||||
{ |
||||
local cmd i is_hash=y |
||||
if [ -d "$1" ]; then |
||||
cmd=git-peek-remote |
||||
else |
||||
cmd=git-ls-remote |
||||
fi |
||||
for i in $($cmd "$1" 2>/dev/null); do |
||||
case "$is_hash,$i" in |
||||
y,*) is_hash=n ;; |
||||
n,*^{}) is_hash=y ;; |
||||
n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}:${i#refs/tags/}" ;; |
||||
n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}:${i#refs/heads/}" ;; |
||||
n,*) is_hash=y; echo "$i:$i" ;; |
||||
esac |
||||
done |
||||
} |
||||
|
||||
__git_remotes () |
||||
{ |
||||
local i REVERTGLOB=$(shopt -p nullglob) |
||||
shopt -s nullglob |
||||
for i in .git/remotes/*; do |
||||
echo ${i#.git/remotes/} |
||||
done |
||||
$REVERTGLOB |
||||
} |
||||
|
||||
__git_complete_file () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
case "$cur" in |
||||
?*:*) |
||||
local pfx ls ref="$(echo "$cur" | sed 's,:.*$,,')" |
||||
cur="$(echo "$cur" | sed 's,^.*:,,')" |
||||
case "$cur" in |
||||
?*/*) |
||||
pfx="$(echo "$cur" | sed 's,/[^/]*$,,')" |
||||
cur="$(echo "$cur" | sed 's,^.*/,,')" |
||||
ls="$ref:$pfx" |
||||
pfx="$pfx/" |
||||
;; |
||||
*) |
||||
ls="$ref" |
||||
;; |
||||
esac |
||||
COMPREPLY=($(compgen -P "$pfx" \ |
||||
-W "$(git-ls-tree "$ls" \ |
||||
| sed '/^100... blob /s,^.* ,, |
||||
/^040000 tree /{ |
||||
s,^.* ,, |
||||
s,$,/, |
||||
} |
||||
s/^.* //')" \ |
||||
-- "$cur")) |
||||
;; |
||||
*) |
||||
COMPREPLY=($(compgen -W "$(__git_refs .)" -- "$cur")) |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
_git_branch () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
COMPREPLY=($(compgen -W "-l -f -d -D $(__git_refs .)" -- "$cur")) |
||||
} |
||||
|
||||
_git_cat_file () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
case "${COMP_WORDS[0]},$COMP_CWORD" in |
||||
git-cat-file*,1) |
||||
COMPREPLY=($(compgen -W "-p -t blob tree commit tag" -- "$cur")) |
||||
;; |
||||
git,2) |
||||
COMPREPLY=($(compgen -W "-p -t blob tree commit tag" -- "$cur")) |
||||
;; |
||||
*) |
||||
__git_complete_file |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
_git_checkout () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
COMPREPLY=($(compgen -W "-l -b $(__git_refs .)" -- "$cur")) |
||||
} |
||||
|
||||
_git_diff () |
||||
{ |
||||
__git_complete_file |
||||
} |
||||
|
||||
_git_diff_tree () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
COMPREPLY=($(compgen -W "-r -p -M $(__git_refs .)" -- "$cur")) |
||||
} |
||||
|
||||
_git_fetch () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
|
||||
case "${COMP_WORDS[0]},$COMP_CWORD" in |
||||
git-fetch*,1) |
||||
COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur")) |
||||
;; |
||||
git,2) |
||||
COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur")) |
||||
;; |
||||
*) |
||||
case "$cur" in |
||||
*:*) |
||||
cur=$(echo "$cur" | sed 's/^.*://') |
||||
COMPREPLY=($(compgen -W "$(__git_refs .)" -- "$cur")) |
||||
;; |
||||
*) |
||||
local remote |
||||
case "${COMP_WORDS[0]}" in |
||||
git-fetch) remote="${COMP_WORDS[1]}" ;; |
||||
git) remote="${COMP_WORDS[2]}" ;; |
||||
esac |
||||
COMPREPLY=($(compgen -W "$(__git_refs2 "$remote")" -- "$cur")) |
||||
;; |
||||
esac |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
_git_ls_remote () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur")) |
||||
} |
||||
|
||||
_git_ls_tree () |
||||
{ |
||||
__git_complete_file |
||||
} |
||||
|
||||
_git_log () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
case "$cur" in |
||||
*..*) |
||||
local pfx=$(echo "$cur" | sed 's/\.\..*$/../') |
||||
cur=$(echo "$cur" | sed 's/^.*\.\.//') |
||||
COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs .)" -- "$cur")) |
||||
;; |
||||
*) |
||||
COMPREPLY=($(compgen -W "$(__git_refs .)" -- "$cur")) |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
_git_merge_base () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
COMPREPLY=($(compgen -W "$(__git_refs .)" -- "$cur")) |
||||
} |
||||
|
||||
_git_pull () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
|
||||
case "${COMP_WORDS[0]},$COMP_CWORD" in |
||||
git-pull*,1) |
||||
COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur")) |
||||
;; |
||||
git,2) |
||||
COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur")) |
||||
;; |
||||
*) |
||||
local remote |
||||
case "${COMP_WORDS[0]}" in |
||||
git-pull) remote="${COMP_WORDS[1]}" ;; |
||||
git) remote="${COMP_WORDS[2]}" ;; |
||||
esac |
||||
COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur")) |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
_git_push () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
|
||||
case "${COMP_WORDS[0]},$COMP_CWORD" in |
||||
git-push*,1) |
||||
COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur")) |
||||
;; |
||||
git,2) |
||||
COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur")) |
||||
;; |
||||
*) |
||||
case "$cur" in |
||||
*:*) |
||||
local remote |
||||
case "${COMP_WORDS[0]}" in |
||||
git-push) remote="${COMP_WORDS[1]}" ;; |
||||
git) remote="${COMP_WORDS[2]}" ;; |
||||
esac |
||||
cur=$(echo "$cur" | sed 's/^.*://') |
||||
COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur")) |
||||
;; |
||||
*) |
||||
COMPREPLY=($(compgen -W "$(__git_refs2 .)" -- "$cur")) |
||||
;; |
||||
esac |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
_git_show () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
COMPREPLY=($(compgen -W "$(__git_refs .)" -- "$cur")) |
||||
} |
||||
|
||||
_git () |
||||
{ |
||||
if [ $COMP_CWORD = 1 ]; then |
||||
COMPREPLY=($(compgen \ |
||||
-W "--version $(git help -a|egrep '^ ')" \ |
||||
-- "${COMP_WORDS[COMP_CWORD]}")) |
||||
else |
||||
case "${COMP_WORDS[1]}" in |
||||
branch) _git_branch ;; |
||||
cat-file) _git_cat_file ;; |
||||
checkout) _git_checkout ;; |
||||
diff) _git_diff ;; |
||||
diff-tree) _git_diff_tree ;; |
||||
fetch) _git_fetch ;; |
||||
log) _git_log ;; |
||||
ls-remote) _git_ls_remote ;; |
||||
ls-tree) _git_ls_tree ;; |
||||
pull) _git_pull ;; |
||||
push) _git_push ;; |
||||
show) _git_show ;; |
||||
show-branch) _git_log ;; |
||||
whatchanged) _git_log ;; |
||||
*) COMPREPLY=() ;; |
||||
esac |
||||
fi |
||||
} |
||||
|
||||
_gitk () |
||||
{ |
||||
local cur="${COMP_WORDS[COMP_CWORD]}" |
||||
COMPREPLY=($(compgen -W "--all $(__git_refs .)" -- "$cur")) |
||||
} |
||||
|
||||
complete -o default -o nospace -F _git git |
||||
complete -o default -F _gitk gitk |
||||
complete -o default -F _git_branch git-branch |
||||
complete -o default -o nospace -F _git_cat_file git-cat-file |
||||
complete -o default -F _git_checkout git-checkout |
||||
complete -o default -o nospace -F _git_diff git-diff |
||||
complete -o default -F _git_diff_tree git-diff-tree |
||||
complete -o default -o nospace -F _git_fetch git-fetch |
||||
complete -o default -o nospace -F _git_log git-log |
||||
complete -o default -F _git_ls_remote git-ls-remote |
||||
complete -o default -o nospace -F _git_ls_tree git-ls-tree |
||||
complete -o default -F _git_merge_base git-merge-base |
||||
complete -o default -o nospace -F _git_pull git-pull |
||||
complete -o default -o nospace -F _git_push git-push |
||||
complete -o default -F _git_show git-show |
||||
complete -o default -o nospace -F _git_log git-whatchanged |
||||
|
||||
# The following are necessary only for Cygwin, and only are needed |
||||
# when the user has tab-completed the executable name and consequently |
||||
# included the '.exe' suffix. |
||||
# |
||||
complete -o default -o nospace -F _git_cat_file git-cat-file.exe |
||||
complete -o default -o nospace -F _git_diff git-diff.exe |
||||
complete -o default -o nospace -F _git_diff_tree git-diff-tree.exe |
||||
complete -o default -o nospace -F _git_log git-log.exe |
||||
complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe |
||||
complete -o default -F _git_merge_base git-merge-base.exe |
||||
complete -o default -o nospace -F _git_push git-push.exe |
||||
complete -o default -o nospace -F _git_log git-whatchanged.exe |
Loading…
Reference in new issue