Skip to content

Commit fe61935

Browse files
committed
Merge branch 'maint'
* maint: Remove a couple of duplicated include grep with unmerged index git-daemon: fix remote port number in log entry git-svn: t9114: verify merge commit message in test git-svn: fix dcommit clobbering when committing a series of diffs
2 parents a1f611d + d8e21ba commit fe61935

File tree

7 files changed

+108
-9
lines changed

7 files changed

+108
-9
lines changed

builtin-grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
343343
memcpy(name + 2, ce->name, len + 1);
344344
}
345345
argv[argc++] = name;
346-
if (argc < MAXARGS && !ce_stage(ce))
346+
if (argc < MAXARGS)
347347
continue;
348348
status = flush_grep(opt, argc, nr, argv, &kept);
349349
if (0 < status)

compat/inet_ntop.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <errno.h>
1919
#include <sys/types.h>
2020
#include <sys/socket.h>
21-
#include <sys/socket.h>
2221
#include <netinet/in.h>
2322
#include <arpa/inet.h>
2423
#include <stdio.h>

compat/inet_pton.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <errno.h>
1919
#include <sys/types.h>
2020
#include <sys/socket.h>
21-
#include <sys/socket.h>
2221
#include <netinet/in.h>
2322
#include <arpa/inet.h>
2423
#include <stdio.h>

daemon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ static int execute(struct sockaddr *addr)
540540
if (addr->sa_family == AF_INET) {
541541
struct sockaddr_in *sin_addr = (void *) addr;
542542
inet_ntop(addr->sa_family, &sin_addr->sin_addr, addrbuf, sizeof(addrbuf));
543-
port = sin_addr->sin_port;
543+
port = ntohs(sin_addr->sin_port);
544544
#ifndef NO_IPV6
545545
} else if (addr && addr->sa_family == AF_INET6) {
546546
struct sockaddr_in6 *sin6_addr = (void *) addr;
@@ -550,7 +550,7 @@ static int execute(struct sockaddr *addr)
550550
inet_ntop(AF_INET6, &sin6_addr->sin6_addr, buf, sizeof(addrbuf) - 1);
551551
strcat(buf, "]");
552552

553-
port = sin6_addr->sin6_port;
553+
port = ntohs(sin6_addr->sin6_port);
554554
#endif
555555
}
556556
loginfo("Connection from %s:%d", addrbuf, port);

git-svn.perl

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ sub cmd_dcommit {
406406
"If these changes depend on each other, re-running ",
407407
"without --no-rebase will be required."
408408
}
409-
foreach my $d (@$linear_refs) {
409+
while (1) {
410+
my $d = shift @$linear_refs or last;
410411
unless (defined $last_rev) {
411412
(undef, $last_rev, undef) = cmt_metadata("$d~1");
412413
unless (defined $last_rev) {
@@ -439,14 +440,14 @@ sub cmd_dcommit {
439440

440441
# we always want to rebase against the current HEAD,
441442
# not any head that was passed to us
442-
my @diff = command('diff-tree', 'HEAD',
443+
my @diff = command('diff-tree', $d,
443444
$gs->refname, '--');
444445
my @finish;
445446
if (@diff) {
446447
@finish = rebase_cmd();
447-
print STDERR "W: HEAD and ", $gs->refname,
448+
print STDERR "W: $d and ", $gs->refname,
448449
" differ, using @finish:\n",
449-
"@diff";
450+
join("\n", @diff), "\n";
450451
} else {
451452
print "No changes between current HEAD and ",
452453
$gs->refname,
@@ -455,6 +456,45 @@ sub cmd_dcommit {
455456
@finish = qw/reset --mixed/;
456457
}
457458
command_noisy(@finish, $gs->refname);
459+
if (@diff) {
460+
@refs = ();
461+
my ($url_, $rev_, $uuid_, $gs_) =
462+
working_head_info($head, \@refs);
463+
my ($linear_refs_, $parents_) =
464+
linearize_history($gs_, \@refs);
465+
if (scalar(@$linear_refs) !=
466+
scalar(@$linear_refs_)) {
467+
fatal "# of revisions changed ",
468+
"\nbefore:\n",
469+
join("\n", @$linear_refs),
470+
"\n\nafter:\n",
471+
join("\n", @$linear_refs_), "\n",
472+
'If you are attempting to commit ',
473+
"merges, try running:\n\t",
474+
'git rebase --interactive',
475+
'--preserve-merges ',
476+
$gs->refname,
477+
"\nBefore dcommitting";
478+
}
479+
if ($url_ ne $url) {
480+
fatal "URL mismatch after rebase: ",
481+
"$url_ != $url";
482+
}
483+
if ($uuid_ ne $uuid) {
484+
fatal "uuid mismatch after rebase: ",
485+
"$uuid_ != $uuid";
486+
}
487+
# remap parents
488+
my (%p, @l, $i);
489+
for ($i = 0; $i < scalar @$linear_refs; $i++) {
490+
my $new = $linear_refs_->[$i] or next;
491+
$p{$new} =
492+
$parents->{$linear_refs->[$i]};
493+
push @l, $new;
494+
}
495+
$parents = \%p;
496+
$linear_refs = \@l;
497+
}
458498
$last_rev = $cmt_rev;
459499
}
460500
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2007 Eric Wong
4+
test_description='git-svn dcommit clobber series'
5+
. ./lib-git-svn.sh
6+
7+
test_expect_success 'initialize repo' "
8+
mkdir import &&
9+
cd import &&
10+
awk 'BEGIN { for (i = 1; i < 64; i++) { print i } }' > file
11+
svn import -m 'initial' . $svnrepo &&
12+
cd .. &&
13+
git svn init $svnrepo &&
14+
git svn fetch &&
15+
test -e file
16+
"
17+
18+
test_expect_success '(supposedly) non-conflicting change from SVN' "
19+
test x\"\`sed -n -e 58p < file\`\" = x58 &&
20+
test x\"\`sed -n -e 61p < file\`\" = x61 &&
21+
svn co $svnrepo tmp &&
22+
cd tmp &&
23+
perl -i -p -e 's/^58\$/5588/' file &&
24+
perl -i -p -e 's/^61\$/6611/' file &&
25+
test x\"\`sed -n -e 58p < file\`\" = x5588 &&
26+
test x\"\`sed -n -e 61p < file\`\" = x6611 &&
27+
svn commit -m '58 => 5588, 61 => 6611' &&
28+
cd ..
29+
"
30+
31+
test_expect_success 'some unrelated changes to git' "
32+
echo hi > life &&
33+
git update-index --add life &&
34+
git commit -m hi-life &&
35+
echo bye >> life &&
36+
git commit -m bye-life life
37+
"
38+
39+
test_expect_success 'change file but in unrelated area' "
40+
test x\"\`sed -n -e 4p < file\`\" = x4 &&
41+
test x\"\`sed -n -e 7p < file\`\" = x7 &&
42+
perl -i -p -e 's/^4\$/4444/' file &&
43+
perl -i -p -e 's/^7\$/7777/' file &&
44+
test x\"\`sed -n -e 4p < file\`\" = x4444 &&
45+
test x\"\`sed -n -e 7p < file\`\" = x7777 &&
46+
git commit -m '4 => 4444, 7 => 7777' file &&
47+
git svn dcommit &&
48+
svn up tmp &&
49+
cd tmp &&
50+
test x\"\`sed -n -e 4p < file\`\" = x4444 &&
51+
test x\"\`sed -n -e 7p < file\`\" = x7777 &&
52+
test x\"\`sed -n -e 58p < file\`\" = x5588 &&
53+
test x\"\`sed -n -e 61p < file\`\" = x6611
54+
"
55+
56+
test_done

t/t9114-git-svn-dcommit-merge.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,9 @@ test_expect_success 'verify post-merge ancestry' "
8686
git cat-file commit refs/heads/svn^ | grep '^friend$'
8787
"
8888

89+
test_expect_success 'verify merge commit message' "
90+
git rev-list --pretty=raw -1 refs/heads/svn | \
91+
grep \" Merge branch 'merge' into svn\"
92+
"
93+
8994
test_done

0 commit comments

Comments
 (0)