Merge branch 'jc/clone' into next

* jc/clone:
  git-clone: lose the traditional 'no-separate-remote' layout
  git-clone: lose the artificial "first" fetch refspec
  git-pull: refuse default merge without branch.*.merge
  git-clone: use wildcard specification for tracking branches
  merge: give a bit prettier merge message to "merge branch~$n"
  Document git-merge-file
  git-clone documentation
  git-status always says what branch it's on

Conflicts:

	git-clone.sh
	git-merge.sh
This commit is contained in:
Junio C Hamano
2006-12-16 13:20:37 -08:00
7 changed files with 136 additions and 66 deletions

View File

@@ -11,8 +11,7 @@ SYNOPSIS
[verse]
'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
[-o <name>] [-u <upload-pack>] [--reference <repository>]
[--use-separate-remote | --no-separate-remote] <repository>
[<directory>]
<repository> [<directory>]
DESCRIPTION
-----------
@@ -99,18 +98,6 @@ OPTIONS
if unset the templates are taken from the installation
defined default, typically `/usr/share/git-core/templates`.
--use-separate-remote::
Save remotes heads under `$GIT_DIR/remotes/origin/` instead
of `$GIT_DIR/refs/heads/`. Only the local master branch is
saved in the latter. This is the default.
--no-separate-remote::
Save remotes heads in the same namespace as the local
heads, `$GIT_DIR/refs/heads/'. In regular repositories,
this is a legacy setup git-clone created by default in
older Git versions, and will be removed before the next
major release.
<repository>::
The (possibly remote) repository to clone from. It can
be any URL git-fetch supports.

View File

@@ -0,0 +1,92 @@
git-merge-file(1)
============
NAME
----
git-merge-file - threeway file merge
SYNOPSIS
--------
[verse]
'git-merge-file' [-L <current-name> [-L <base-name> [-L <other-name>]]]
[-p|--stdout] [-q|--quiet] <current-file> <base-file> <other-file>
DESCRIPTION
-----------
git-file-merge incorporates all changes that lead from the `<base-file>`
to `<other-file>` into `<current-file>`. The result ordinarily goes into
`<current-file>`. git-merge-file is useful for combining separate changes
to an original. Suppose `<base-file>` is the original, and both
`<current-file>` and `<other-file>` are modifications of `<base-file>`.
Then git-merge-file combines both changes.
A conflict occurs if both `<current-file>` and `<other-file>` have changes
in a common segment of lines. If a conflict is found, git-merge-file
normally outputs a warning and brackets the conflict with <<<<<<< and
>>>>>>> lines. A typical conflict will look like this:
<<<<<<< A
lines in file A
=======
lines in file B
>>>>>>> B
If there are conflicts, the user should edit the result and delete one of
the alternatives.
The exit value of this program is negative on error, and the number of
conflicts otherwise. If the merge was clean, the exit value is 0.
git-merge-file is designed to be a minimal clone of RCS merge, that is, it
implements all of RCS merge's functionality which is needed by
gitlink:git[1].
OPTIONS
-------
-L <label>::
This option may be given up to three times, and
specifies labels to be used in place of the
corresponding file names in conflict reports. That is,
`git-merge-file -L x -L y -L z a b c` generates output that
looks like it came from files x, y and z instead of
from files a, b and c.
-p::
Send results to standard output instead of overwriting
`<current-file>`.
-q::
Quiet; do not warn about conflicts.
EXAMPLES
--------
git merge-file README.my README README.upstream::
combines the changes of README.my and README.upstream since README,
tries to merge them and writes the result into README.my.
git merge-file -L a -L b -L c tmp/a123 tmp/b234 tmp/c345::
merges tmp/a123 and tmp/c345 with the base tmp/b234, but uses labels
`a` and `c` instead of `tmp/a123` and `tmp/c345`.
Author
------
Written by Johannes Schindelin <johannes.schindelin@gmx.de>
Documentation
--------------
Documentation by Johannes Schindelin and the git-list <git@vger.kernel.org>,
with parts copied from the original documentation of RCS merge.
GIT
---
Part of the gitlink:git[7] suite

View File

@@ -351,6 +351,9 @@ gitlink:git-init-db[1]::
Creates an empty git object database, or reinitialize an
existing one.
gitlink:git-merge-file[1]::
Runs a threeway merge.
gitlink:git-merge-index[1]::
Runs a merge for files needing merging.

View File

@@ -14,7 +14,7 @@ die() {
}
usage() {
die "Usage: $0 [--template=<template_directory>] [--no-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [--depth <n>] [-n] <repo> [<dir>]"
die "Usage: $0 [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [--depth <n>] [-n] <repo> [<dir>]"
}
get_repo_base() {
@@ -138,11 +138,9 @@ while
*,--template=*)
template="$1" ;;
*,-q|*,--quiet) quiet=-q ;;
*,--use-separate-remote)
# default
use_separate_remote=t ;;
*,--use-separate-remote) ;;
*,--no-separate-remote)
use_separate_remote= ;;
die "clones are always made with separate-remote layout" ;;
1,--reference) usage ;;
*,--reference)
shift; reference="$1" ;;
@@ -340,12 +338,8 @@ cd "$D" || exit
if test -z "$bare" && test -f "$GIT_DIR/REMOTE_HEAD"
then
# Figure out which remote branch HEAD points at.
case "$use_separate_remote" in
'') remote_top=refs/heads ;;
*) remote_top="refs/remotes/$origin" ;;
esac
# a non-bare repository is always in separate-remote layout
remote_top="refs/remotes/$origin"
head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
case "$head_sha1" in
'ref: refs/'*)
@@ -379,41 +373,26 @@ then
)
)
# Write out remotes/$origin file, and update our "$head_points_at".
# Write out remote.$origin config, and update our "$head_points_at".
case "$head_points_at" in
?*)
mkdir -p "$GIT_DIR/remotes" &&
# Local default branch
git-symbolic-ref HEAD "refs/heads/$head_points_at" &&
case "$use_separate_remote" in
t) origin_track="$remote_top/$head_points_at"
git-update-ref HEAD "$head_sha1" ;;
*) origin_track="$remote_top/$origin"
git-update-ref "refs/heads/$origin" "$head_sha1" ;;
esac &&
# Tracking branch for the primary branch at the remote.
origin_track="$remote_top/$head_points_at" &&
git-update-ref HEAD "$head_sha1" &&
# Upstream URL
git-repo-config remote."$origin".url "$repo" &&
# Set up the mappings to track the remote branches.
git-repo-config remote."$origin".fetch \
"refs/heads/$head_points_at:$origin_track" &&
(cd "$GIT_DIR/$remote_top" && find . -type f -print) |
while read dotslref
do
name=`expr "$dotslref" : './\(.*\)'`
if test "z$head_points_at" = "z$name"
then
continue
fi
if test "$use_separate_remote" = '' &&
test "z$origin" = "z$name"
then
continue
fi
git-repo-config remote."$origin".fetch "refs/heads/${name}:$remote_top/${name}" '^$'
done &&
case "$use_separate_remote" in
t)
rm -f "refs/remotes/$origin/HEAD"
git-symbolic-ref "refs/remotes/$origin/HEAD" \
"refs/remotes/$origin/$head_points_at"
esac &&
"refs/heads/*:$remote_top/*" '^$' &&
rm -f "refs/remotes/$origin/HEAD"
git-symbolic-ref "refs/remotes/$origin/HEAD" \
"refs/remotes/$origin/$head_points_at" &&
git-repo-config branch."$head_points_at".remote "$origin" &&
git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at"
esac

View File

@@ -136,6 +136,22 @@ merge_local_changes () {
)
}
merge_name () {
remote="$1"
rh=$(git-rev-parse --verify "$remote^0" 2>/dev/null) || return
bh=$(git-show-ref -s --verify "refs/heads/$remote" 2>/dev/null)
if test "$rh" = "$bh"
then
echo "$rh branch '$remote' of ."
elif truname=$(expr "$remote" : '\(.*\)~[1-9][0-9]*$') &&
git-show-ref -q --verify "refs/heads/$truname" 2>/dev/null
then
echo "$rh branch '$truname' (early part) of ."
else
echo "$rh commit '$remote'"
fi
}
case "$#" in 0) usage ;; esac
rloga= have_message=
@@ -233,15 +249,7 @@ else
# in this loop.
merge_name=$(for remote
do
rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) ||
continue ;# not something we can merge
bh=$(git show-ref -s --verify "refs/heads/$remote" 2>/dev/null)
if test "$rh" = "$bh"
then
echo "$rh branch '$remote' of ."
else
echo "$rh commit '$remote'"
fi
merge_name "$remote"
done | git-fmt-merge-msg
)
merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name"

View File

@@ -144,7 +144,8 @@ canon_refs_list_for_fetch () {
curr_branch=$(git-symbolic-ref HEAD | \
sed -e 's|^refs/heads/||')
merge_branches=$(git-repo-config \
--get-all "branch.${curr_branch}.merge")
--get-all "branch.${curr_branch}.merge") ||
merge_branches=.this.would.never.match.any.ref.
fi
set x $(expand_refs_wildcard "$@")
shift

View File

@@ -271,7 +271,7 @@ static void wt_status_print_verbose(struct wt_status *s)
void wt_status_print(struct wt_status *s)
{
if (s->branch && strcmp(s->branch, "refs/heads/master"))
if (s->branch)
color_printf_ln(color(WT_STATUS_HEADER),
"# On branch %s", s->branch);