Merge branch 'rs/cherry' into next

* rs/cherry:
  Built-in cherry
  gitweb: Fix setting $/ in parse_commit()
  daemon: do not die on older clients.
  xdiff/xemit.c (xdl_find_func): Elide trailing white space in a context header.
  git-clone: honor --quiet
  Documentation for the [remote] config
  prune-packed: Fix uninitialized variable.
  ignore-errors requires cl
  git-send-email: do not pass custom Date: header
This commit is contained in:
Junio C Hamano
2006-10-23 20:47:00 -07:00
14 changed files with 143 additions and 100 deletions

View File

@@ -234,6 +234,18 @@ pull.octopus::
pull.twohead::
The default merge strategy to use when pulling a single branch.
remote.<name>.url::
The URL of a remote repository. See gitlink:git-fetch[1] or
gitlink:git-push[1].
remote.<name>.fetch::
The default set of "refspec" for gitlink:git-fetch[1]. See
gitlink:git-fetch[1].
remote.<name>.push::
The default set of "refspec" for gitlink:git-push[1]. See
gitlink:git-push[1].
repack.usedeltabaseoffset::
Allow gitlink:git-repack[1] to create packs that uses
delta-base offset. Defaults to false.

View File

@@ -51,6 +51,14 @@ lines are used for `git-push` and `git-fetch`/`git-pull`,
respectively. Multiple `Push:` and `Pull:` lines may
be specified for additional branch mappings.
Or, equivalently, in the `$GIT_DIR/config` (note the use
of `fetch` instead of `Pull:`):
[remote "<remote>"]
url = <url>
push = <refspec>
fetch = <refspec>
The name of a file in `$GIT_DIR/branches` directory can be
specified as an older notation short-hand; the named
file should contain a single line, a URL in one of the

View File

@@ -159,7 +159,7 @@ BASIC_LDFLAGS =
SCRIPT_SH = \
git-bisect.sh git-branch.sh git-checkout.sh \
git-cherry.sh git-clean.sh git-clone.sh git-commit.sh \
git-clean.sh git-clone.sh git-commit.sh \
git-fetch.sh \
git-ls-remote.sh \
git-merge-one-file.sh git-parse-remote.sh \
@@ -212,7 +212,7 @@ PROGRAMS = \
EXTRA_PROGRAMS =
BUILT_INS = \
git-format-patch$X git-show$X git-whatchanged$X \
git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \
git-get-tar-commit-id$X \
$(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))

View File

@@ -437,3 +437,109 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
return 0;
}
static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
{
unsigned char sha1[20];
if (get_sha1(arg, sha1) == 0) {
struct commit *commit = lookup_commit_reference(sha1);
if (commit) {
commit->object.flags |= flags;
add_pending_object(revs, &commit->object, arg);
return 0;
}
}
return -1;
}
static const char cherry_usage[] =
"git-cherry [-v] <upstream> [<head>] [<limit>]";
int cmd_cherry(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
struct diff_options patch_id_opts;
struct commit *commit;
struct commit_list *list = NULL;
const char *upstream;
const char *head = "HEAD";
const char *limit = NULL;
int verbose = 0;
if (argc > 1 && !strcmp(argv[1], "-v")) {
verbose = 1;
argc--;
argv++;
}
switch (argc) {
case 4:
limit = argv[3];
/* FALLTHROUGH */
case 3:
head = argv[2];
/* FALLTHROUGH */
case 2:
upstream = argv[1];
break;
default:
usage(cherry_usage);
}
init_revisions(&revs, prefix);
revs.diff = 1;
revs.combine_merges = 0;
revs.ignore_merges = 1;
revs.diffopt.recursive = 1;
if (add_pending_commit(head, &revs, 0))
die("Unknown commit %s", head);
if (add_pending_commit(upstream, &revs, UNINTERESTING))
die("Unknown commit %s", upstream);
/* Don't say anything if head and upstream are the same. */
if (revs.pending.nr == 2) {
struct object_array_entry *o = revs.pending.objects;
if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
return 0;
}
get_patch_ids(&revs, &patch_id_opts, prefix);
if (limit && add_pending_commit(limit, &revs, UNINTERESTING))
die("Unknown commit %s", limit);
/* reverse the list of commits */
prepare_revision_walk(&revs);
while ((commit = get_revision(&revs)) != NULL) {
/* ignore merges */
if (commit->parents && commit->parents->next)
continue;
commit_list_insert(commit, &list);
}
while (list) {
unsigned char sha1[20];
char sign = '+';
commit = list->item;
if (!get_patch_id(commit, &patch_id_opts, sha1) &&
lookup_object(sha1))
sign = '-';
if (verbose) {
static char buf[16384];
pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
buf, sizeof(buf), 0, NULL, NULL, 0);
printf("%c %s %s\n", sign,
sha1_to_hex(commit->object.sha1), buf);
}
else {
printf("%c %s\n", sign,
sha1_to_hex(commit->object.sha1));
}
list = list->next;
}
return 0;
}

View File

@@ -56,7 +56,7 @@ void prune_packed_objects(int dryrun)
int cmd_prune_packed(int argc, const char **argv, const char *prefix)
{
int i;
int dryrun;
int dryrun = 0;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];

View File

@@ -20,6 +20,7 @@ extern int cmd_archive(int argc, const char **argv, const char *prefix);
extern int cmd_cat_file(int argc, const char **argv, const char *prefix);
extern int cmd_checkout_index(int argc, const char **argv, const char *prefix);
extern int cmd_check_ref_format(int argc, const char **argv, const char *prefix);
extern int cmd_cherry(int argc, const char **argv, const char *prefix);
extern int cmd_commit_tree(int argc, const char **argv, const char *prefix);
extern int cmd_count_objects(int argc, const char **argv, const char *prefix);
extern int cmd_diff_files(int argc, const char **argv, const char *prefix);

View File

@@ -33,6 +33,8 @@
;; - working with revisions other than HEAD
;;
(eval-when-compile (require 'cl))
(defvar git-commits-coding-system 'utf-8
"Default coding system for git commits.")

View File

@@ -450,6 +450,8 @@ void fill_in_extra_table_entries(struct interp *itable)
* Replace literal host with lowercase-ized hostname.
*/
hp = interp_table[INTERP_SLOT_HOST].value;
if (!hp)
return;
for ( ; *hp; hp++)
*hp = tolower(*hp);
@@ -544,8 +546,10 @@ static int execute(struct sockaddr *addr)
loginfo("Extended attributes (%d bytes) exist <%.*s>",
(int) pktlen - len,
(int) pktlen - len, line + len + 1);
if (len && line[len-1] == '\n')
if (len && line[len-1] == '\n') {
line[--len] = 0;
pktlen--;
}
/*
* Initialize the path interpolation table for this connection.

View File

@@ -1,91 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2005 Junio C Hamano.
#
USAGE='[-v] <upstream> [<head>] [<limit>]'
LONG_USAGE=' __*__*__*__*__> <upstream>
/
fork-point
\__+__+__+__+__+__+__+__> <head>
Each commit between the fork-point (or <limit> if given) and <head> is
examined, and compared against the change each commit between the
fork-point and <upstream> introduces. If the change seems to be in
the upstream, it is shown on the standard output with prefix "+".
Otherwise it is shown with prefix "-".'
. git-sh-setup
case "$1" in -v) verbose=t; shift ;; esac
case "$#,$1" in
1,*..*)
upstream=$(expr "z$1" : 'z\(.*\)\.\.') ours=$(expr "z$1" : '.*\.\.\(.*\)$')
set x "$upstream" "$ours"
shift ;;
esac
case "$#" in
1) upstream=`git-rev-parse --verify "$1"` &&
ours=`git-rev-parse --verify HEAD` || exit
limit="$upstream"
;;
2) upstream=`git-rev-parse --verify "$1"` &&
ours=`git-rev-parse --verify "$2"` || exit
limit="$upstream"
;;
3) upstream=`git-rev-parse --verify "$1"` &&
ours=`git-rev-parse --verify "$2"` &&
limit=`git-rev-parse --verify "$3"` || exit
;;
*) usage ;;
esac
# Note that these list commits in reverse order;
# not that the order in inup matters...
inup=`git-rev-list ^$ours $upstream` &&
ours=`git-rev-list $ours ^$limit` || exit
tmp=.cherry-tmp$$
patch=$tmp-patch
mkdir $patch
trap "rm -rf $tmp-*" 0 1 2 3 15
for c in $inup
do
git-diff-tree -p $c
done | git-patch-id |
while read id name
do
echo $name >>$patch/$id
done
LF='
'
O=
for c in $ours
do
set x `git-diff-tree -p $c | git-patch-id`
if test "$2" != ""
then
if test -f "$patch/$2"
then
sign=-
else
sign=+
fi
case "$verbose" in
t)
c=$(git-rev-list --pretty=oneline --max-count=1 $c)
esac
case "$O" in
'') O="$sign $c" ;;
*) O="$sign $c$LF$O" ;;
esac
fi
done
case "$O" in
'') ;;
*) echo "$O" ;;
esac

View File

@@ -401,7 +401,8 @@ Pull: refs/heads/$head_points_at:$origin_track" &&
case "$no_checkout" in
'')
git-read-tree -m -u -v HEAD HEAD
test "z$quiet" = z && v=-v || v=
git-read-tree -m -u $v HEAD HEAD
esac
fi
rm -f "$GIT_DIR/CLONE_HEAD" "$GIT_DIR/REMOTE_HEAD"

View File

@@ -514,7 +514,7 @@ foreach my $t (@files) {
$2, $_) unless $quiet;
push @cc, $2;
}
elsif (/^[-A-Za-z]+:\s+\S/) {
elsif (!/^Date:\s/ && /^[-A-Za-z]+:\s+\S/) {
push @xh, $_;
}

1
git.c
View File

@@ -225,6 +225,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{ "cat-file", cmd_cat_file, RUN_SETUP },
{ "checkout-index", cmd_checkout_index, RUN_SETUP },
{ "check-ref-format", cmd_check_ref_format },
{ "cherry", cmd_cherry, RUN_SETUP },
{ "commit-tree", cmd_commit_tree, RUN_SETUP },
{ "count-objects", cmd_count_objects, RUN_SETUP },
{ "diff", cmd_diff, RUN_SETUP | USE_PAGER },

View File

@@ -1104,12 +1104,11 @@ sub parse_commit {
if (defined $commit_text) {
@commit_lines = @$commit_text;
} else {
$/ = "\0";
local $/ = "\0";
open my $fd, "-|", git_cmd(), "rev-list", "--header", "--parents", "--max-count=1", $commit_id
or return;
@commit_lines = split '\n', <$fd>;
close $fd or return;
$/ = "\n";
pop @commit_lines;
}
my $header = shift @commit_lines;

View File

@@ -90,7 +90,7 @@ static void xdl_find_func(xdfile_t *xf, long i, char *buf, long sz, long *ll) {
*rec == '#')) { /* #define? */
if (len > sz)
len = sz;
if (len && rec[len - 1] == '\n')
while (0 < len && isspace((unsigned char)rec[len - 1]))
len--;
memcpy(buf, rec, len);
*ll = len;