Skip to content

Commit e2b7008

Browse files
dschoJunio C Hamano
authored andcommitted
Get rid of the dependency on RCS' merge program
Now that we have git-merge-file, an RCS merge lookalike, we no longer need it. So long, merge, and thanks for all the fish! Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent fbe0b24 commit e2b7008

File tree

8 files changed

+20
-89
lines changed

8 files changed

+20
-89
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ git-mailsplit
6060
git-merge
6161
git-merge-base
6262
git-merge-index
63+
git-merge-file
6364
git-merge-tree
6465
git-merge-octopus
6566
git-merge-one-file

Documentation/git-merge-index.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ If "git-merge-index" is called with multiple <file>s (or -a) then it
4040
processes them in turn only stopping if merge returns a non-zero exit
4141
code.
4242

43-
Typically this is run with the a script calling the merge command from
44-
the RCS package.
43+
Typically this is run with the a script calling git's imitation of
44+
the merge command from the RCS package.
4545

4646
A sample script called "git-merge-one-file" is included in the
4747
distribution.

INSTALL

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ Issues of note:
8282
do that even if it wasn't for git. There's no point in living
8383
in the dark ages any more.
8484

85-
- "merge", the standard UNIX three-way merge program. It usually
86-
comes with the "rcs" package on most Linux distributions, so if
87-
you have a developer install you probably have it already, but a
88-
"graphical user desktop" install might have left it out.
89-
90-
You'll only need the merge program if you do development using
91-
git, and if you only use git to track other peoples work you'll
92-
never notice the lack of it.
93-
9485
- "wish", the Tcl/Tk windowing shell is used in gitk to show the
9586
history graphically
9687

git-cvsserver.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ sub req_update
945945

946946
$log->debug("Temporary directory for merge is $dir");
947947

948-
my $return = system("merge", $file_local, $file_old, $file_new);
948+
my $return = system("git merge-file", $file_local, $file_old, $file_new);
949949
$return >>= 8;
950950

951951
if ( $return == 0 )

git-rerere.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ sub find_conflict {
154154
sub merge {
155155
my ($name, $path) = @_;
156156
record_preimage($path, "$rr_dir/$name/thisimage");
157-
unless (system('merge', map { "$rr_dir/$name/${_}image" }
157+
unless (system('git merge-file', map { "$rr_dir/$name/${_}image" }
158158
qw(this pre post))) {
159159
my $in;
160160
open $in, "<$rr_dir/$name/thisimage" or

git.spec.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This is a dummy package which brings in all subpackages.
2424
%package core
2525
Summary: Core git tools
2626
Group: Development/Tools
27-
Requires: zlib >= 1.2, rsync, rcs, curl, less, openssh-clients, expat
27+
Requires: zlib >= 1.2, rsync, curl, less, openssh-clients, expat
2828
%description core
2929
This is a stupid (but extremely fast) directory content manager. It
3030
doesn't do a whole lot, but what it _does_ do is track directory

merge-file.c

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,6 @@
33
#include "xdiff-interface.h"
44
#include "blob.h"
55

6-
static void rm_temp_file(const char *filename)
7-
{
8-
unlink(filename);
9-
free((void *)filename);
10-
}
11-
12-
static const char *write_temp_file(mmfile_t *f)
13-
{
14-
int fd;
15-
const char *tmp = getenv("TMPDIR");
16-
char *filename;
17-
18-
if (!tmp)
19-
tmp = "/tmp";
20-
filename = mkpath("%s/%s", tmp, "git-tmp-XXXXXX");
21-
fd = mkstemp(filename);
22-
if (fd < 0)
23-
return NULL;
24-
filename = xstrdup(filename);
25-
if (f->size != xwrite(fd, f->ptr, f->size)) {
26-
rm_temp_file(filename);
27-
return NULL;
28-
}
29-
close(fd);
30-
return filename;
31-
}
32-
33-
static void *read_temp_file(const char *filename, unsigned long *size)
34-
{
35-
struct stat st;
36-
char *buf = NULL;
37-
int fd = open(filename, O_RDONLY);
38-
if (fd < 0)
39-
return NULL;
40-
if (!fstat(fd, &st)) {
41-
*size = st.st_size;
42-
buf = xmalloc(st.st_size);
43-
if (st.st_size != xread(fd, buf, st.st_size)) {
44-
free(buf);
45-
buf = NULL;
46-
}
47-
}
48-
close(fd);
49-
return buf;
50-
}
51-
526
static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
537
{
548
void *buf;
@@ -72,22 +26,19 @@ static void free_mmfile(mmfile_t *f)
7226

7327
static void *three_way_filemerge(mmfile_t *base, mmfile_t *our, mmfile_t *their, unsigned long *size)
7428
{
75-
void *res;
76-
const char *t1, *t2, *t3;
77-
78-
t1 = write_temp_file(base);
79-
t2 = write_temp_file(our);
80-
t3 = write_temp_file(their);
81-
res = NULL;
82-
if (t1 && t2 && t3) {
83-
int code = run_command("merge", t2, t1, t3, NULL);
84-
if (!code || code == -1)
85-
res = read_temp_file(t2, size);
86-
}
87-
rm_temp_file(t1);
88-
rm_temp_file(t2);
89-
rm_temp_file(t3);
90-
return res;
29+
mmbuffer_t res;
30+
xpparam_t xpp;
31+
int merge_status;
32+
33+
memset(&xpp, 0, sizeof(xpp));
34+
merge_status = xdl_merge(base, our, ".our", their, ".their",
35+
&xpp, XDL_MERGE_ZEALOUS, &res);
36+
37+
if (merge_status < 0)
38+
return NULL;
39+
40+
*size = res.size;
41+
return res.ptr;
9142
}
9243

9344
static int common_outf(void *priv_, mmbuffer_t *mb, int nbuf)

t/t0000-basic.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ modification *should* take notice and update the test vectors here.
1919
'
2020

2121
################################################################
22-
# It appears that people are getting bitten by not installing
23-
# 'merge' (usually part of RCS package in binary distributions).
24-
# Check this and error out before running any tests. Also catch
25-
# the bogosity of trying to run tests without building while we
26-
# are at it.
22+
# It appears that people try to run tests without building...
2723

2824
../git >/dev/null
2925
if test $? != 1
@@ -32,14 +28,6 @@ then
3228
exit 1
3329
fi
3430

35-
merge >/dev/null 2>/dev/null
36-
if test $? = 127
37-
then
38-
echo >&2 'You do not seem to have "merge" installed.
39-
Please check INSTALL document.'
40-
exit 1
41-
fi
42-
4331
. ./test-lib.sh
4432

4533
################################################################

0 commit comments

Comments
 (0)