Skip to content

Commit

Permalink
Status update on merge-recursive in C
Browse files Browse the repository at this point in the history
This is just an update for people being interested. Alex and me were
busy with that project for a few days now. While it has progressed nicely,
there are quite a couple TODOs in merge-recursive.c, just search for "TODO".

For impatient people: yes, it passes all the tests, and yes, according
to the evil test Alex did, it is faster than the Python script.

But no, it is not yet finished. Biggest points are:

- there are still three external calls
- in the end, it should not be necessary to write the index more than once
  (just before exiting)
- a lot of things can be refactored to make the code easier and shorter

BTW we cannot just plug in git-merge-tree yet, because git-merge-tree
does not handle renames at all.

This patch is meant for testing, and as such,

- it compile the program to git-merge-recur
- it adjusts the scripts and tests to use git-merge-recur instead of
  git-merge-recursive
- it provides "TEST", a script to execute the tests regarding -recursive
- it inlines the changes to read-cache.c (read_cache_from(), discard_cache()
  and refresh_cache_entry())

Brought to you by Alex Riesen and Dscho

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Jul 14, 2006
1 parent 4b7ce6e commit 6d297f8
Show file tree
Hide file tree
Showing 10 changed files with 1,773 additions and 52 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ PROGRAMS = \
git-upload-pack$X git-verify-pack$X \
git-symbolic-ref$X \
git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
git-describe$X git-merge-tree$X git-blame$X git-imap-send$X \
git-merge-recur$X

BUILT_INS = git-log$X git-whatchanged$X git-show$X git-update-ref$X \
git-count-objects$X git-diff$X git-push$X git-mailsplit$X \
Expand Down Expand Up @@ -615,6 +616,11 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)

merge-recursive.o path-list.o: path-list.h
git-merge-recur$X: merge-recursive.o path-list.o $(LIB_FILE)
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIBS)

$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
$(DIFF_OBJS): diffcore.h
Expand Down
10 changes: 10 additions & 0 deletions TEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh -x
cd t || exit
./t3400-rebase.sh "$@" && \
./t6020-merge-df.sh "$@" && \
./t3401-rebase-partial.sh "$@" && \
./t6021-merge-criss-cross.sh "$@" && \
./t3402-rebase-merge.sh "$@" && \
./t6022-merge-rename.sh "$@" && \
./t6010-merge-base.sh "$@" && \
:
4 changes: 4 additions & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static inline unsigned int create_ce_mode(unsigned int mode)
extern struct cache_entry **active_cache;
extern unsigned int active_nr, active_alloc, active_cache_changed;
extern struct cache_tree *active_cache_tree;
extern int cache_errno;

#define GIT_DIR_ENVIRONMENT "GIT_DIR"
#define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
Expand Down Expand Up @@ -142,13 +143,16 @@ extern void verify_non_filename(const char *prefix, const char *name);

/* Initialize and use the cache information */
extern int read_cache(void);
extern int read_cache_from(const char *path);
extern int write_cache(int newfd, struct cache_entry **cache, int entries);
extern int discard_cache(void);
extern int verify_path(const char *path);
extern int cache_name_pos(const char *name, int namelen);
#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */
extern int add_cache_entry(struct cache_entry *ce, int option);
extern struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really);
extern int remove_cache_entry_at(int pos);
extern int remove_file_from_cache(const char *path);
extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
Expand Down
6 changes: 3 additions & 3 deletions git-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ USAGE='[-n] [--no-commit] [--squash] [-s <strategy>]... <merge-message> <head> <
LF='
'

all_strategies='recursive octopus resolve stupid ours'
default_twohead_strategies='recursive'
all_strategies='recur recur octopus resolve stupid ours'
default_twohead_strategies='recur'
default_octopus_strategies='octopus'
no_trivial_merge_strategies='ours'
use_strategies=

index_merge=t
if test "@@NO_PYTHON@@"; then
all_strategies='resolve octopus stupid ours'
all_strategies='recur resolve octopus stupid ours'
default_twohead_strategies='resolve'
fi

Expand Down
4 changes: 2 additions & 2 deletions git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\".
To restore the original branch and stop rebasing run \"git rebase --abort\".
"
unset newbase
strategy=recursive
strategy=recur
do_merge=
dotest=$GIT_DIR/.dotest-merge
prec=4
Expand Down Expand Up @@ -292,7 +292,7 @@ then
exit $?
fi

if test "@@NO_PYTHON@@" && test "$strategy" = "recursive"
if test "@@NO_PYTHON@@" && test "$strategy" = "recur"
then
die 'The recursive merge strategy currently relies on Python,
which this installation of git was not configured with. Please consider
Expand Down
Loading

0 comments on commit 6d297f8

Please sign in to comment.