{"thread":{"id":"43712","subject":"[PATCH] Get rid of the dependency on RCS' merge program","startedAt":"2006-12-12T23:01:41Z","lastAt":"2006-12-12T23:01:41Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"297206","messageId":"Pine.LNX.4.63.0612130000450.2807@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43712","inReplyTo":null,"subject":"[PATCH] Get rid of the dependency on RCS' merge program","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-12T23:01:41Z","receivedAt":"2006-12-12T23:01:41Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nNow that we have git-merge-file, an RCS merge lookalike, we no longer\nneed it. So long, merge, and thanks for all the fish!\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\n\tI only ran the test suite, which passed fine...\n\n .gitignore                        |    1 +\n Documentation/git-merge-index.txt |    4 +-\n INSTALL                           |    9 ----\n git-cvsserver.perl                |    2 +-\n git-rerere.perl                   |    2 +-\n git.spec.in                       |    2 +-\n merge-file.c                      |   75 ++++++------------------------------\n t/t0000-basic.sh                  |   14 +------\n 8 files changed, 20 insertions(+), 89 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex 6b8caa0..2e8f17e 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -61,6 +61,7 @@ git-mailsplit\n git-merge\n git-merge-base\n git-merge-index\n+git-merge-file\n git-merge-tree\n git-merge-octopus\n git-merge-one-file\ndiff --git a/Documentation/git-merge-index.txt b/Documentation/git-merge-index.txt\nindex 6cd0601..0cf505e 100644\n--- a/Documentation/git-merge-index.txt\n+++ b/Documentation/git-merge-index.txt\n@@ -40,8 +40,8 @@ If \"git-merge-index\" is called with multiple <file>s (or -a) then it\n processes them in turn only stopping if merge returns a non-zero exit\n code.\n \n-Typically this is run with the a script calling the merge command from\n-the RCS package.\n+Typically this is run with the a script calling git's imitation of\n+the merge command from the RCS package.\n \n A sample script called \"git-merge-one-file\" is included in the\n distribution.\ndiff --git a/INSTALL b/INSTALL\nindex 8f69039..b5dd9f0 100644\n--- a/INSTALL\n+++ b/INSTALL\n@@ -82,15 +82,6 @@ Issues of note:\n \t  do that even if it wasn't for git.  There's no point in living\n \t  in the dark ages any more. \n \n-\t- \"merge\", the standard UNIX three-way merge program.  It usually\n-\t  comes with the \"rcs\" package on most Linux distributions, so if\n-\t  you have a developer install you probably have it already, but a\n-\t  \"graphical user desktop\" install might have left it out.\n-\n-\t  You'll only need the merge program if you do development using\n-\t  git, and if you only use git to track other peoples work you'll\n-\t  never notice the lack of it. \n-\n         - \"wish\", the Tcl/Tk windowing shell is used in gitk to show the\n           history graphically\n \ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex bf4e228..740f2fa 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -948,7 +948,7 @@ sub req_update\n \n             $log->debug(\"Temporary directory for merge is $dir\");\n \n-            my $return = system(\"merge\", $file_local, $file_old, $file_new);\n+            my $return = system(\"git merge-file\", $file_local, $file_old, $file_new);\n             $return >>= 8;\n \n             if ( $return == 0 )\ndiff --git a/git-rerere.perl b/git-rerere.perl\nindex 61eef57..fdd6854 100755\n--- a/git-rerere.perl\n+++ b/git-rerere.perl\n@@ -154,7 +154,7 @@ sub find_conflict {\n sub merge {\n \tmy ($name, $path) = @_;\n \trecord_preimage($path, \"$rr_dir/$name/thisimage\");\n-\tunless (system('merge', map { \"$rr_dir/$name/${_}image\" }\n+\tunless (system('git merge-file', map { \"$rr_dir/$name/${_}image\" }\n \t\t       qw(this pre post))) {\n \t\tmy $in;\n \t\topen $in, \"<$rr_dir/$name/thisimage\" or\ndiff --git a/git.spec.in b/git.spec.in\nindex f2374b7..fb95e37 100644\n--- a/git.spec.in\n+++ b/git.spec.in\n@@ -24,7 +24,7 @@ This is a dummy package which brings in all subpackages.\n %package core\n Summary:\tCore git tools\n Group:\t\tDevelopment/Tools\n-Requires:\tzlib >= 1.2, rsync, rcs, curl, less, openssh-clients, expat\n+Requires:\tzlib >= 1.2, rsync, curl, less, openssh-clients, expat\n %description core\n This is a stupid (but extremely fast) directory content manager.  It\n doesn't do a whole lot, but what it _does_ do is track directory\ndiff --git a/merge-file.c b/merge-file.c\nindex fc9b148..69dc1eb 100644\n--- a/merge-file.c\n+++ b/merge-file.c\n@@ -3,52 +3,6 @@\n #include \"xdiff-interface.h\"\n #include \"blob.h\"\n \n-static void rm_temp_file(const char *filename)\n-{\n-\tunlink(filename);\n-\tfree((void *)filename);\n-}\n-\n-static const char *write_temp_file(mmfile_t *f)\n-{\n-\tint fd;\n-\tconst char *tmp = getenv(\"TMPDIR\");\n-\tchar *filename;\n-\n-\tif (!tmp)\n-\t\ttmp = \"/tmp\";\n-\tfilename = mkpath(\"%s/%s\", tmp, \"git-tmp-XXXXXX\");\n-\tfd = mkstemp(filename);\n-\tif (fd < 0)\n-\t\treturn NULL;\n-\tfilename = xstrdup(filename);\n-\tif (f->size != xwrite(fd, f->ptr, f->size)) {\n-\t\trm_temp_file(filename);\n-\t\treturn NULL;\n-\t}\n-\tclose(fd);\n-\treturn filename;\n-}\n-\n-static void *read_temp_file(const char *filename, unsigned long *size)\n-{\n-\tstruct stat st;\n-\tchar *buf = NULL;\n-\tint fd = open(filename, O_RDONLY);\n-\tif (fd < 0)\n-\t\treturn NULL;\n-\tif (!fstat(fd, &st)) {\n-\t\t*size = st.st_size;\n-\t\tbuf = xmalloc(st.st_size);\n-\t\tif (st.st_size != xread(fd, buf, st.st_size)) {\n-\t\t\tfree(buf);\n-\t\t\tbuf = NULL;\n-\t\t}\n-\t}\n-\tclose(fd);\n-\treturn buf;\n-}\n-\n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\n \tvoid *buf;\n@@ -72,22 +26,19 @@ static void free_mmfile(mmfile_t *f)\n \n static void *three_way_filemerge(mmfile_t *base, mmfile_t *our, mmfile_t *their, unsigned long *size)\n {\n-\tvoid *res;\n-\tconst char *t1, *t2, *t3;\n-\n-\tt1 = write_temp_file(base);\n-\tt2 = write_temp_file(our);\n-\tt3 = write_temp_file(their);\n-\tres = NULL;\n-\tif (t1 && t2 && t3) {\n-\t\tint code = run_command(\"merge\", t2, t1, t3, NULL);\n-\t\tif (!code || code == -1)\n-\t\t\tres = read_temp_file(t2, size);\n-\t}\n-\trm_temp_file(t1);\n-\trm_temp_file(t2);\n-\trm_temp_file(t3);\n-\treturn res;\n+\tmmbuffer_t res;\n+\txpparam_t xpp;\n+\tint merge_status;\n+\n+\tmemset(&xpp, 0, sizeof(xpp));\n+\tmerge_status = xdl_merge(base, our, \".our\", their, \".their\",\n+\t\t&xpp, XDL_MERGE_ZEALOUS, &res);\n+\n+\tif (merge_status < 0)\n+\t\treturn NULL;\n+\n+\t*size = res.size;\n+\treturn res.ptr;\n }\n \n static int common_outf(void *priv_, mmbuffer_t *mb, int nbuf)\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 81f3bed..3260d1d 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -19,11 +19,7 @@ modification *should* take notice and update the test vectors here.\n '\n \n ################################################################\n-# It appears that people are getting bitten by not installing\n-# 'merge' (usually part of RCS package in binary distributions).\n-# Check this and error out before running any tests.  Also catch\n-# the bogosity of trying to run tests without building while we\n-# are at it.\n+# It appears that people try to run tests without building...\n \n ../git >/dev/null\n if test $? != 1\n@@ -32,14 +28,6 @@ then\n \texit 1\n fi\n \n-merge >/dev/null 2>/dev/null\n-if test $? = 127\n-then\n-\techo >&2 'You do not seem to have \"merge\" installed.\n-Please check INSTALL document.'\n-\texit 1\n-fi\n-\n . ./test-lib.sh\n \n ################################################################\n-- \n1.4.4.2.g473fa0-dirty\n"}]}