Merge branch 'jc/leftright' into next

* jc/leftright:
  Make left-right automatic.
  Teach all of log family --left-right output.
  rev-list --left-right
  markup fix in svnimport documentation.
  Documentation: new option -P for git-svnimport
  Fix mis-mark-up in git-merge-file.txt documentation
  Default GIT_COMMITTER_NAME to login name in recieve-pack.
  Fix check_file_directory_conflict().
  git-add: remove conflicting entry when adding.
  update-index: make D/F conflict error a bit more verbose.
This commit is contained in:
Junio C Hamano
2006-12-17 10:36:25 -08:00
12 changed files with 95 additions and 18 deletions

View File

@@ -1,9 +1,9 @@
git-merge-file(1)
============
=================
NAME
----
git-merge-file - threeway file merge
git-merge-file - three-way file merge
SYNOPSIS

View File

@@ -15,6 +15,7 @@ SYNOPSIS
[ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
[ -s start_chg ] [ -m ] [ -r ] [ -M regex ]
[ -I <ignorefile_name> ] [ -A <author_file> ]
[ -P <path_from_trunk> ]
<SVN_repository_URL> [ <path> ]
@@ -103,9 +104,17 @@ repository without -A.
-l <max_rev>::
Specify a maximum revision number to pull.
+
Formerly, this option controlled how many revisions to pull,
due to SVN memory leaks. (These have been worked around.)
Formerly, this option controlled how many revisions to pull,
due to SVN memory leaks. (These have been worked around.)
-P <path_from_trunk>::
Partial import of the SVN tree.
+
By default, the whole tree on the SVN trunk (/trunk) is imported.
'-P my/proj' will import starting only from '/trunk/my/proj'.
This option is useful when you want to import one project from a
svn repo which hosts multiple projects under the same trunk.
-v::
Verbosity: let 'svnimport' report what it is doing.

View File

@@ -54,6 +54,12 @@ static void show_commit(struct commit *commit)
fputs(header_prefix, stdout);
if (commit->object.flags & BOUNDARY)
putchar('-');
else if (revs.left_right) {
if (commit->object.flags & SYMMETRIC_LEFT)
putchar('<');
else
putchar('>');
}
if (revs.abbrev_commit && revs.abbrev)
fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
stdout);

View File

@@ -309,6 +309,7 @@ void datestamp(char *buf, int bufsize);
unsigned long approxidate(const char *);
extern int setup_ident(void);
extern void ignore_missing_committer_name();
extern const char *git_author_info(int);
extern const char *git_committer_info(int);

View File

@@ -902,11 +902,11 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo,
/* merge-rebase stuff */
/* bits #0..7 in revision.h */
#define PARENT1 (1u<< 8)
#define PARENT2 (1u<< 9)
#define STALE (1u<<10)
#define RESULT (1u<<11)
/* bits #0..15 in revision.h */
#define PARENT1 (1u<<16)
#define PARENT2 (1u<<17)
#define STALE (1u<<18)
#define RESULT (1u<<19)
static struct commit *interesting(struct commit_list *list)
{

15
ident.c
View File

@@ -221,3 +221,18 @@ const char *git_committer_info(int error_on_no_name)
getenv("GIT_COMMITTER_DATE"),
error_on_no_name);
}
void ignore_missing_committer_name()
{
/* If we did not get a name from the user's gecos entry then
* git_default_name is empty; so instead load the username
* into it as a 'good enough for now' approximation of who
* this user is.
*/
if (!*git_default_name) {
struct passwd *pw = getpwuid(getuid());
if (!pw)
die("You don't exist. Go away!");
strlcpy(git_default_name, pw->pw_name, sizeof(git_default_name));
}
}

View File

@@ -114,6 +114,14 @@ void show_log(struct rev_info *opt, const char *sep)
opt->loginfo = NULL;
if (!opt->verbose_header) {
if (opt->left_right) {
if (commit->object.flags & BOUNDARY)
putchar('-');
else if (commit->object.flags & SYMMETRIC_LEFT)
putchar('<');
else
putchar('>');
}
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
if (opt->parents)
show_parents(commit, abbrev_commit);
@@ -192,10 +200,20 @@ void show_log(struct rev_info *opt, const char *sep)
opt->diffopt.stat_sep = buffer;
}
} else {
printf("%s%s%s",
diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ",
diff_unique_abbrev(commit->object.sha1, abbrev_commit));
fputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
stdout);
if (opt->commit_format != CMIT_FMT_ONELINE)
fputs("commit ", stdout);
if (opt->left_right) {
if (commit->object.flags & BOUNDARY)
putchar('-');
else if (commit->object.flags & SYMMETRIC_LEFT)
putchar('<');
else
putchar('>');
}
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
stdout);
if (opt->parents)
show_parents(commit, abbrev_commit);
if (parent)

View File

@@ -358,7 +358,7 @@ int add_file_to_index(const char *path, int verbose)
if (index_path(ce->sha1, path, &st, 1))
die("unable to index file %s", path);
if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD))
if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE))
die("unable to add %s to index",path);
if (verbose)
printf("add '%s'\n", path);
@@ -517,7 +517,7 @@ static int has_dir_name(const struct cache_entry *ce, int pos, int ok_to_replace
pos = cache_name_pos(name, ntohs(create_ce_flags(len, stage)));
if (pos >= 0) {
retval = -1;
if (ok_to_replace)
if (!ok_to_replace)
break;
remove_cache_entry_at(pos);
continue;
@@ -609,7 +609,7 @@ int add_cache_entry(struct cache_entry *ce, int option)
if (!skip_df_check &&
check_file_directory_conflict(ce, pos, ok_to_replace)) {
if (!ok_to_replace)
return -1;
return error("'%s' appears as both a file and as a directory", ce->name);
pos = cache_name_pos(ce->name, ntohs(ce->ce_flags));
pos = -pos-1;
}

View File

@@ -420,6 +420,8 @@ int main(int argc, char **argv)
die("'%s': unable to chdir or not a git archive", dir);
setup_ident();
/* don't die if gecos is empty */
ignore_missing_committer_name();
git_config(receive_pack_config);
write_head_info();

View File

@@ -344,6 +344,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
static void add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)
{
struct commit_list *parent = commit->parents;
unsigned left_flag;
if (commit->object.flags & ADDED)
return;
@@ -388,6 +389,7 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
if (revs->no_walk)
return;
left_flag = (commit->object.flags & SYMMETRIC_LEFT);
parent = commit->parents;
while (parent) {
struct commit *p = parent->item;
@@ -395,6 +397,7 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
parent = parent->next;
parse_commit(p);
p->object.flags |= left_flag;
if (p->object.flags & SEEN)
continue;
p->object.flags |= SEEN;
@@ -640,7 +643,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
add_pending_commit_list(revs, exclude,
flags_exclude);
free_commit_list(exclude);
a->object.flags |= flags;
a->object.flags |= flags | SYMMETRIC_LEFT;
} else
a->object.flags |= flags_exclude;
b->object.flags |= flags;
@@ -850,6 +853,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
revs->boundary = 1;
continue;
}
if (!strcmp(arg, "--no-left-right")) {
revs->no_left_right = 1;
continue;
}
if (!strcmp(arg, "--objects")) {
revs->tag_objects = 1;
revs->tree_objects = 1;
@@ -1048,13 +1055,18 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
void prepare_revision_walk(struct rev_info *revs)
{
int nr = revs->pending.nr;
int has_symmetric = 0;
struct object_array_entry *list = revs->pending.objects;
revs->pending.nr = 0;
revs->pending.alloc = 0;
revs->pending.objects = NULL;
while (--nr >= 0) {
struct commit *commit = handle_commit(revs, list->item, list->name);
struct commit *commit;
if (list->item->flags & SYMMETRIC_LEFT)
has_symmetric = 1;
commit = handle_commit(revs, list->item, list->name);
if (commit) {
if (!(commit->object.flags & SEEN)) {
commit->object.flags |= SEEN;
@@ -1066,6 +1078,8 @@ void prepare_revision_walk(struct rev_info *revs)
if (revs->no_walk)
return;
if (!revs->no_left_right && has_symmetric)
revs->left_right = 1;
if (revs->limited)
limit_list(revs);
if (revs->topo_order)

View File

@@ -9,6 +9,7 @@
#define BOUNDARY (1u<<5)
#define BOUNDARY_SHOW (1u<<6)
#define ADDED (1u<<7) /* Parents already parsed and added? */
#define SYMMETRIC_LEFT (1u<<8)
struct rev_info;
struct log_info;
@@ -40,6 +41,8 @@ struct rev_info {
limited:1,
unpacked:1, /* see also ignore_packed below */
boundary:1,
no_left_right:1,
left_right:1,
parents:1;
/* Diff flags */

View File

@@ -272,4 +272,13 @@ test_expect_success \
wc -l) &&
test $numparent = 1'
test_expect_success 'update-index D/F conflict' '
mv path0 tmp &&
mv path2 path0 &&
mv tmp path2 &&
git update-index --add --replace path2 path0/file2 &&
numpath0=$(git ls-files path0 | wc -l) &&
test $numpath0 = 1
'
test_done