Browse Source
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>maint
Johannes Schindelin
19 years ago
committed by
Junio C Hamano
10 changed files with 1773 additions and 52 deletions
@ -0,0 +1,10 @@
@@ -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 "$@" && \ |
||||
: |
@ -0,0 +1,105 @@
@@ -0,0 +1,105 @@
|
||||
#include <stdio.h> |
||||
#include "cache.h" |
||||
#include "path-list.h" |
||||
|
||||
/* if there is no exact match, point to the index where the entry could be |
||||
* inserted */ |
||||
static int get_entry_index(const struct path_list *list, const char *path, |
||||
int *exact_match) |
||||
{ |
||||
int left = -1, right = list->nr; |
||||
|
||||
while (left + 1 < right) { |
||||
int middle = (left + right) / 2; |
||||
int compare = strcmp(path, list->items[middle].path); |
||||
if (compare < 0) |
||||
right = middle; |
||||
else if (compare > 0) |
||||
left = middle; |
||||
else { |
||||
*exact_match = 1; |
||||
return middle; |
||||
} |
||||
} |
||||
|
||||
*exact_match = 0; |
||||
return right; |
||||
} |
||||
|
||||
/* returns -1-index if already exists */ |
||||
static int add_entry(struct path_list *list, const char *path) |
||||
{ |
||||
int exact_match; |
||||
int index = get_entry_index(list, path, &exact_match); |
||||
|
||||
if (exact_match) |
||||
return -1 - index; |
||||
|
||||
if (list->nr + 1 >= list->alloc) { |
||||
list->alloc += 32; |
||||
list->items = xrealloc(list->items, list->alloc |
||||
* sizeof(struct path_list_item)); |
||||
} |
||||
if (index < list->nr) |
||||
memmove(list->items + index + 1, list->items + index, |
||||
(list->nr - index) |
||||
* sizeof(struct path_list_item)); |
||||
list->items[index].path = list->strdup_paths ? |
||||
strdup(path) : (char *)path; |
||||
list->items[index].util = NULL; |
||||
list->nr++; |
||||
|
||||
return index; |
||||
} |
||||
|
||||
struct path_list_item *path_list_insert(const char *path, struct path_list *list) |
||||
{ |
||||
int index = add_entry(list, path); |
||||
|
||||
if (index < 0) |
||||
index = 1 - index; |
||||
|
||||
return list->items + index; |
||||
} |
||||
|
||||
int path_list_has_path(const struct path_list *list, const char *path) |
||||
{ |
||||
int exact_match; |
||||
get_entry_index(list, path, &exact_match); |
||||
return exact_match; |
||||
} |
||||
|
||||
struct path_list_item *path_list_lookup(const char *path, struct path_list *list) |
||||
{ |
||||
int exact_match, i = get_entry_index(list, path, &exact_match); |
||||
if (!exact_match) |
||||
return NULL; |
||||
return list->items + i; |
||||
} |
||||
|
||||
void path_list_clear(struct path_list *list, int free_items) |
||||
{ |
||||
if (list->items) { |
||||
int i; |
||||
if (free_items) |
||||
for (i = 0; i < list->nr; i++) { |
||||
if (list->strdup_paths) |
||||
free(list->items[i].path); |
||||
if (list->items[i].util) |
||||
free(list->items[i].util); |
||||
} |
||||
free(list->items); |
||||
} |
||||
list->items = NULL; |
||||
list->nr = list->alloc = 0; |
||||
} |
||||
|
||||
void print_path_list(const char *text, const struct path_list *p) |
||||
{ |
||||
int i; |
||||
if ( text ) |
||||
printf("%s\n", text); |
||||
for (i = 0; i < p->nr; i++) |
||||
printf("%s:%p\n", p->items[i].path, p->items[i].util); |
||||
} |
||||
|
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
#ifndef _PATH_LIST_H_ |
||||
#define _PATH_LIST_H_ |
||||
|
||||
struct path_list_item { |
||||
char *path; |
||||
void *util; |
||||
}; |
||||
struct path_list |
||||
{ |
||||
struct path_list_item *items; |
||||
unsigned int nr, alloc; |
||||
unsigned int strdup_paths:1; |
||||
}; |
||||
|
||||
void print_path_list(const char *text, const struct path_list *p); |
||||
|
||||
int path_list_has_path(const struct path_list *list, const char *path); |
||||
void path_list_clear(struct path_list *list, int free_items); |
||||
struct path_list_item *path_list_insert(const char *path, struct path_list *list); |
||||
struct path_list_item *path_list_lookup(const char *path, struct path_list *list); |
||||
|
||||
#endif /* _PATH_LIST_H_ */ |
Loading…
Reference in new issue