Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Documentation/CodingGuidelines
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ For C programs:
*/
_("Here is a translatable string explained by the above.");

We do not use // comments.

- Double negation is often harder to understand than no negation
at all.

Expand Down
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.54.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Performance, Internal Implementation, Development Support etc.

* Code clean-up to use the commit_stack API.

* "git diff --anchored=<text>" has been optimized.


Fixes since v2.53
-----------------
Expand Down Expand Up @@ -101,6 +103,10 @@ Fixes since v2.53
"synopsis" style.
(merge a34d1d53a6 ja/doc-synopsis-style-even-more later to maint).

* Small clean-up of xdiff library to remove unnecessary data
duplication.
(merge 5086213bd2 pw/xdiff-cleanups later to maint).

* Other code cleanup, docfix, build fix, etc.
(merge d79fff4a11 jk/remote-tracking-ref-leakfix later to maint).
(merge 7a747f972d dd/t5403-modernise later to maint).
Expand All @@ -120,3 +126,4 @@ Fixes since v2.53
(merge 6bfef81c9a kh/doc-rerere-options-xref later to maint).
(merge aaf3cc3d8d sd/t7003-test-path-is-helpers later to maint).
(merge 2668b6bdc4 jc/doc-rerere-update later to maint).
(merge 2f99f50f2d jc/doc-cg-c-comment later to maint).
8 changes: 4 additions & 4 deletions t/t9812-git-p4-wildcards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ test_expect_success 'wildcard files git p4 clone' '
test_when_finished cleanup_git &&
(
cd "$git" &&
test -f file-wild#hash &&
test_path_is_file file-wild#hash &&
if test_have_prereq !MINGW,!CYGWIN
then
test -f file-wild\*star
test_path_is_file file-wild\*star
fi &&
test -f file-wild@at &&
test -f file-wild%percent
test_path_is_file file-wild@at &&
test_path_is_file file-wild%percent
)
'

Expand Down
18 changes: 6 additions & 12 deletions xdiff/xpatience.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ struct hashmap {
* initially, "next" reflects only the order in file1.
*/
struct entry *next, *previous;

/*
* If 1, this entry can serve as an anchor. See
* Documentation/diff-options.adoc for more information.
*/
unsigned anchor : 1;
} *entries, *first, *last;
/* were common records found? */
unsigned long has_matches;
Expand All @@ -85,8 +79,7 @@ static int is_anchor(xpparam_t const *xpp, const char *line)
}

/* The argument "pass" is 1 for the first file, 2 for the second. */
static void insert_record(xpparam_t const *xpp, int line, struct hashmap *map,
int pass)
static void insert_record(int line, struct hashmap *map, int pass)
{
xrecord_t *records = pass == 1 ?
map->env->xdf1.recs : map->env->xdf2.recs;
Expand Down Expand Up @@ -121,7 +114,6 @@ static void insert_record(xpparam_t const *xpp, int line, struct hashmap *map,
return;
map->entries[index].line1 = line;
map->entries[index].minimal_perfect_hash = record->minimal_perfect_hash;
map->entries[index].anchor = is_anchor(xpp, (const char *)map->env->xdf1.recs[line - 1].ptr);
if (!map->first)
map->first = map->entries + index;
if (map->last) {
Expand Down Expand Up @@ -153,11 +145,11 @@ static int fill_hashmap(xpparam_t const *xpp, xdfenv_t *env,

/* First, fill with entries from the first file */
while (count1--)
insert_record(xpp, line1++, result, 1);
insert_record(line1++, result, 1);

/* Then search for matches in the second file */
while (count2--)
insert_record(xpp, line2++, result, 2);
insert_record(line2++, result, 2);

return 0;
}
Expand Down Expand Up @@ -194,6 +186,8 @@ static int binary_search(struct entry **sequence, int longest,
*/
static int find_longest_common_sequence(struct hashmap *map, struct entry **res)
{
xpparam_t const *xpp = map->xpp;
xrecord_t const *recs = map->env->xdf2.recs;
struct entry **sequence;
int longest = 0, i;
struct entry *entry;
Expand All @@ -220,7 +214,7 @@ static int find_longest_common_sequence(struct hashmap *map, struct entry **res)
if (i <= anchor_i)
continue;
sequence[i] = entry;
if (entry->anchor) {
if (is_anchor(xpp, (const char*)recs[entry->line2 - 1].ptr)) {
anchor_i = i;
longest = anchor_i + 1;
} else if (i == longest) {
Expand Down
20 changes: 12 additions & 8 deletions xdiff/xprepare.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
#define INVESTIGATE 2

typedef struct s_xdlclass {
uint64_t line_hash;
struct s_xdlclass *next;
xrecord_t rec;
const uint8_t *ptr;
size_t size;
long idx;
long len1, len2;
} xdlclass_t;
Expand Down Expand Up @@ -92,14 +94,15 @@ static void xdl_free_classifier(xdlclassifier_t *cf) {
}


static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t *rec) {
static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t *rec,
uint64_t line_hash) {
size_t hi;
xdlclass_t *rcrec;

hi = XDL_HASHLONG(rec->line_hash, cf->hbits);
hi = XDL_HASHLONG(line_hash, cf->hbits);
for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next)
if (rcrec->rec.line_hash == rec->line_hash &&
xdl_recmatch((const char *)rcrec->rec.ptr, (long)rcrec->rec.size,
if (rcrec->line_hash == line_hash &&
xdl_recmatch((const char *)rcrec->ptr, (long)rcrec->size,
(const char *)rec->ptr, (long)rec->size, cf->flags))
break;

Expand All @@ -112,7 +115,9 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
if (XDL_ALLOC_GROW(cf->rcrecs, cf->count, cf->alloc))
return -1;
cf->rcrecs[rcrec->idx] = rcrec;
rcrec->rec = *rec;
rcrec->line_hash = line_hash;
rcrec->ptr = rec->ptr;
rcrec->size = rec->size;
rcrec->len1 = rcrec->len2 = 0;
rcrec->next = cf->rchash[hi];
cf->rchash[hi] = rcrec;
Expand Down Expand Up @@ -158,8 +163,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
crec = &xdf->recs[xdf->nrec++];
crec->ptr = prev;
crec->size = cur - prev;
crec->line_hash = hav;
if (xdl_classify_record(pass, cf, crec) < 0)
if (xdl_classify_record(pass, cf, crec, hav) < 0)
goto abort;
}
}
Expand Down
1 change: 0 additions & 1 deletion xdiff/xtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ typedef struct s_chastore {
typedef struct s_xrecord {
uint8_t const *ptr;
size_t size;
uint64_t line_hash;
size_t minimal_perfect_hash;
} xrecord_t;

Expand Down