Merge branch 'jc/blame-boundary' into next

* jc/blame-boundary:
  git-blame: show lines attributed to boundary commits differently.
  branch --color: change default color selection.
  send-pack: tighten checks for remote names
  git-push: accept tag <tag> as advertised.
  spurious .sp in manpages
  git merge: reword failure message.
  Remove uncontested renamed files during merge.
This commit is contained in:
Junio C Hamano
2006-12-13 11:16:59 -08:00
9 changed files with 188 additions and 11 deletions

View File

@@ -13,4 +13,18 @@
<xsl:apply-templates/>
<xsl:text>.br&#10;</xsl:text>
</xsl:template>
<!-- sorry, this is not about callouts, but attempts to work around
spurious .sp at the tail of the line docbook stylesheets seem to add -->
<xsl:template match="simpara">
<xsl:variable name="content">
<xsl:apply-templates/>
</xsl:variable>
<xsl:value-of select="normalize-space($content)"/>
<xsl:if test="not(ancestor::authorblurb) and
not(ancestor::personblurb)">
<xsl:text>&#10;&#10;</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@@ -1090,6 +1090,11 @@ static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
if (!(commit->object.flags & UNINTERESTING) &&
!(revs->max_age != -1 && commit->date < revs->max_age))
pass_blame(sb, suspect, opt);
else {
commit->object.flags |= UNINTERESTING;
if (commit->object.parsed)
mark_parents_uninteresting(commit);
}
/* Take responsibility for the remaining entries */
for (ent = sb->ent; ent; ent = ent->next)
@@ -1273,6 +1278,8 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
printf("committer-tz %s\n", ci.committer_tz);
printf("filename %s\n", suspect->path);
printf("summary %s\n", ci.summary);
if (suspect->commit->object.flags & UNINTERESTING)
printf("boundary\n");
}
else if (suspect->commit->object.flags & MORE_THAN_ONE_PATH)
printf("filename %s\n", suspect->path);
@@ -1308,8 +1315,14 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
cp = nth_line(sb, ent->lno);
for (cnt = 0; cnt < ent->num_lines; cnt++) {
char ch;
int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : 8;
printf("%.*s", (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : 8, hex);
if (suspect->commit->object.flags & UNINTERESTING) {
length--;
putchar('^');
}
printf("%.*s", length, hex);
if (opt & OUTPUT_ANNOTATE_COMPAT)
printf("\t(%10s\t%10s\t%d)", ci.author,
format_time(ci.author_time, ci.author_tz,

View File

@@ -23,8 +23,8 @@ static char branch_colors[][COLOR_MAXLEN] = {
"\033[m", /* reset */
"", /* PLAIN (normal) */
"\033[31m", /* REMOTE (red) */
"\033[32m", /* LOCAL (green) */
"\033[1;32m", /* CURRENT (boldgreen) */
"", /* LOCAL (normal) */
"\033[32m", /* CURRENT (green) */
};
enum color_branch {
COLOR_BRANCH_RESET = 0,

View File

@@ -57,11 +57,36 @@ static void expand_refspecs(void)
static void set_refspecs(const char **refs, int nr)
{
if (nr) {
size_t bytes = nr * sizeof(char *);
refspec = xrealloc(refspec, bytes);
memcpy(refspec, refs, bytes);
refspec_nr = nr;
int pass;
for (pass = 0; pass < 2; pass++) {
/* pass 0 counts and allocates, pass 1 fills */
int i, cnt;
for (i = cnt = 0; i < nr; i++) {
if (!strcmp("tag", refs[i])) {
int len;
char *tag;
if (nr <= ++i)
die("tag <tag> shorthand without <tag>");
if (pass) {
len = strlen(refs[i]) + 11;
tag = xmalloc(len);
strcpy(tag, "refs/tags/");
strcat(tag, refs[i]);
refspec[cnt] = tag;
}
cnt++;
continue;
}
if (pass)
refspec[cnt] = refs[i];
cnt++;
}
if (!pass) {
size_t bytes = cnt * sizeof(char *);
refspec_nr = cnt;
refspec = xrealloc(refspec, bytes);
}
}
}
expand_refspecs();
}

View File

@@ -445,7 +445,14 @@ fi
case "$best_strategy" in
'')
restorestate
echo >&2 "No merge strategy handled the merge."
case "$use_strategies" in
?*' '?*)
echo >&2 "No merge strategy handled the merge."
;;
*)
echo >&2 "Merge with strategy $use_strategies failed."
;;
esac
exit 2
;;
"$wt_strategy")

View File

@@ -879,7 +879,7 @@ static int process_renames(struct path_list *a_renames,
struct diff_filespec src_other, dst_other;
int try_merge, stage = a_renames == renames1 ? 3: 2;
remove_file(1, ren1_src, 1);
remove_file(1, ren1_src, index_only);
hashcpy(src_other.sha1, ren1->src_entry->stages[stage].sha);
src_other.mode = ren1->src_entry->stages[stage].mode;

2
refs.c
View File

@@ -534,7 +534,7 @@ int check_ref_format(const char *ref)
level++;
if (!ch) {
if (level < 2)
return -1; /* at least of form "heads/blah" */
return -2; /* at least of form "heads/blah" */
return 0;
}
}

View File

@@ -406,6 +406,25 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
return ret;
}
static void verify_remote_names(int nr_heads, char **heads)
{
int i;
for (i = 0; i < nr_heads; i++) {
const char *remote = strchr(heads[i], ':');
remote = remote ? (remote + 1) : heads[i];
switch (check_ref_format(remote)) {
case 0: /* ok */
case -2: /* ok but a single level -- that is fine for
* a match pattern.
*/
continue;
}
die("remote part of refspec is not a valid name in %s",
heads[i]);
}
}
int main(int argc, char **argv)
{
@@ -457,6 +476,8 @@ int main(int argc, char **argv)
usage(send_pack_usage);
if (heads && send_all)
usage(send_pack_usage);
verify_remote_names(nr_heads, heads);
pid = git_connect(fd, dest, exec);
if (pid < 0)
return 1;

97
t/t6023-merge-rename-nocruft.sh Executable file
View File

@@ -0,0 +1,97 @@
#!/bin/sh
test_description='Merge-recursive merging renames'
. ./test-lib.sh
test_expect_success setup \
'
cat >A <<\EOF &&
a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
c cccccccccccccccccccccccccccccccccccccccccccccccc
d dddddddddddddddddddddddddddddddddddddddddddddddd
e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
f ffffffffffffffffffffffffffffffffffffffffffffffff
g gggggggggggggggggggggggggggggggggggggggggggggggg
h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
i iiiiiiii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OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
EOF
git add A M &&
git commit -m "initial has A and M" &&
git branch white &&
git branch red &&
git checkout white &&
sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
rm -f A M &&
git update-index --add --remove A B M N &&
git commit -m "white renames A->B, M->N" &&
git checkout red &&
echo created by red >R &&
git update-index --add R &&
git commit -m "red creates R" &&
git checkout master'
# This test broke in 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae
test_expect_success 'merge white into red (A->B,M->N)' \
'
git checkout -b red-white red &&
git merge white &&
git write-tree >/dev/null || {
echo "BAD: merge did not complete"
return 1
}
test -f B || {
echo "BAD: B does not exist in working directory"
return 1
}
test -f N || {
echo "BAD: N does not exist in working directory"
return 1
}
test -f R || {
echo "BAD: R does not exist in working directory"
return 1
}
test -f A && {
echo "BAD: A still exists in working directory"
return 1
}
test -f M && {
echo "BAD: M still exists in working directory"
return 1
}
return 0
'
test_done