2018-10-17 22:13:26 +00:00
|
|
|
#ifndef COMMIT_REACH_H
|
|
|
|
#define COMMIT_REACH_H
|
2018-07-20 16:33:02 +00:00
|
|
|
|
commit-reach.h: add missing declarations (hdr-check)
Add the necessary #includes and forward declarations to allow the header
file to pass the 'hdr-check' target.
Note that, since this header includes the commit-slab implementation
header file (indirectly via commit-slab.h), some of the commit-slab
inline functions (e.g contains_cache_at_peek()) will not compile without
the complete type of 'struct commit'. Hence, we replace the forward
declaration of 'struct commit' with the an #include of the 'commit.h'
header file.
It is possible, using the 'commit-slab-{decl,impl}.h' files, to avoid
this inclusion of the 'commit.h' header. Commit a9f1f1f9f8 ("commit-slab.h:
code split", 2018-05-19) separated the commit-slab interface from its
implementation, to allow for the definition of a public commit-slab data
structure. This enabled us to avoid including the commit-slab implementation
in a header file, which could result in the replication of the commit-slab
functions in each compilation unit in which it was included.
Indeed, if you compile with optimizations disabled, then run this script:
$ cat -n dup-static.sh
1 #!/bin/sh
2
3 nm $1 | grep ' t ' | cut -d' ' -f3 | sort | uniq -c |
4 sort -rn | grep -v ' 1'
$
$ ./dup-static.sh git | grep contains
24 init_contains_cache_with_stride
24 init_contains_cache
24 contains_cache_peek
24 contains_cache_at_peek
24 contains_cache_at
24 clear_contains_cache
$
you will find 24 copies of the commit-slab routines for the contains_cache.
Of course, when you enable optimizations again, these duplicate static
functions (mostly) disappear. Compiling with gcc at -O2, leaves two static
functions, thus:
$ nm commit-reach.o | grep contains_cache
0000000000000870 t contains_cache_at_peek.isra.1.constprop.6
$ nm ref-filter.o | grep contains_cache
00000000000002b0 t clear_contains_cache.isra.14
$
However, using a shared 'contains_cache' would result in all six of the
above functions as external public functions in the git binary. At present,
only three of these functions are actually called, so the trade-off
seems to favour letting the compiler inline the commit-slab functions.
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-10-27 01:53:57 +00:00
|
|
|
#include "commit.h"
|
2018-07-20 16:33:08 +00:00
|
|
|
#include "commit-slab.h"
|
|
|
|
|
2018-07-20 16:33:02 +00:00
|
|
|
struct commit_list;
|
2018-07-20 16:33:08 +00:00
|
|
|
struct ref_filter;
|
commit-reach.h: add missing declarations (hdr-check)
Add the necessary #includes and forward declarations to allow the header
file to pass the 'hdr-check' target.
Note that, since this header includes the commit-slab implementation
header file (indirectly via commit-slab.h), some of the commit-slab
inline functions (e.g contains_cache_at_peek()) will not compile without
the complete type of 'struct commit'. Hence, we replace the forward
declaration of 'struct commit' with the an #include of the 'commit.h'
header file.
It is possible, using the 'commit-slab-{decl,impl}.h' files, to avoid
this inclusion of the 'commit.h' header. Commit a9f1f1f9f8 ("commit-slab.h:
code split", 2018-05-19) separated the commit-slab interface from its
implementation, to allow for the definition of a public commit-slab data
structure. This enabled us to avoid including the commit-slab implementation
in a header file, which could result in the replication of the commit-slab
functions in each compilation unit in which it was included.
Indeed, if you compile with optimizations disabled, then run this script:
$ cat -n dup-static.sh
1 #!/bin/sh
2
3 nm $1 | grep ' t ' | cut -d' ' -f3 | sort | uniq -c |
4 sort -rn | grep -v ' 1'
$
$ ./dup-static.sh git | grep contains
24 init_contains_cache_with_stride
24 init_contains_cache
24 contains_cache_peek
24 contains_cache_at_peek
24 contains_cache_at
24 clear_contains_cache
$
you will find 24 copies of the commit-slab routines for the contains_cache.
Of course, when you enable optimizations again, these duplicate static
functions (mostly) disappear. Compiling with gcc at -O2, leaves two static
functions, thus:
$ nm commit-reach.o | grep contains_cache
0000000000000870 t contains_cache_at_peek.isra.1.constprop.6
$ nm ref-filter.o | grep contains_cache
00000000000002b0 t clear_contains_cache.isra.14
$
However, using a shared 'contains_cache' would result in all six of the
above functions as external public functions in the git binary. At present,
only three of these functions are actually called, so the trade-off
seems to favour letting the compiler inline the commit-slab functions.
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-10-27 01:53:57 +00:00
|
|
|
struct object_id;
|
|
|
|
struct object_array;
|
2018-07-20 16:33:02 +00:00
|
|
|
|
|
|
|
struct commit_list *get_merge_bases_many(struct commit *one,
|
|
|
|
int n,
|
|
|
|
struct commit **twos);
|
|
|
|
struct commit_list *get_merge_bases_many_dirty(struct commit *one,
|
|
|
|
int n,
|
|
|
|
struct commit **twos);
|
|
|
|
struct commit_list *get_merge_bases(struct commit *one, struct commit *two);
|
|
|
|
struct commit_list *get_octopus_merge_bases(struct commit_list *in);
|
|
|
|
|
|
|
|
/* To be used only when object flags after this call no longer matter */
|
|
|
|
struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos);
|
|
|
|
|
|
|
|
int is_descendant_of(struct commit *commit, struct commit_list *with_commit);
|
|
|
|
int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference);
|
|
|
|
int in_merge_bases(struct commit *commit, struct commit *reference);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Takes a list of commits and returns a new list where those
|
|
|
|
* have been removed that can be reached from other commits in
|
|
|
|
* the list. It is useful for, e.g., reducing the commits
|
|
|
|
* randomly thrown at the git-merge command and removing
|
|
|
|
* redundant commits that the user shouldn't have given to it.
|
|
|
|
*
|
|
|
|
* This function destroys the STALE bit of the commit objects'
|
|
|
|
* flags.
|
|
|
|
*/
|
|
|
|
struct commit_list *reduce_heads(struct commit_list *heads);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Like `reduce_heads()`, except it replaces the list. Use this
|
|
|
|
* instead of `foo = reduce_heads(foo);` to avoid memory leaks.
|
|
|
|
*/
|
|
|
|
void reduce_heads_replace(struct commit_list **heads);
|
|
|
|
|
2018-07-20 16:33:06 +00:00
|
|
|
int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
|
|
|
|
|
2018-07-20 16:33:08 +00:00
|
|
|
/*
|
|
|
|
* Unknown has to be "0" here, because that's the default value for
|
|
|
|
* contains_cache slab entries that have not yet been assigned.
|
|
|
|
*/
|
|
|
|
enum contains_result {
|
|
|
|
CONTAINS_UNKNOWN = 0,
|
|
|
|
CONTAINS_NO,
|
|
|
|
CONTAINS_YES
|
|
|
|
};
|
|
|
|
|
|
|
|
define_commit_slab(contains_cache, enum contains_result);
|
|
|
|
|
|
|
|
int commit_contains(struct ref_filter *filter, struct commit *commit,
|
|
|
|
struct commit_list *list, struct contains_cache *cache);
|
|
|
|
|
2018-07-20 16:33:13 +00:00
|
|
|
/*
|
|
|
|
* Determine if every commit in 'from' can reach at least one commit
|
|
|
|
* that is marked with 'with_flag'. As we traverse, use 'assign_flag'
|
|
|
|
* as a marker for commits that are already visited. Do not walk
|
2018-07-20 16:33:28 +00:00
|
|
|
* commits with date below 'min_commit_date' or generation below
|
|
|
|
* 'min_generation'.
|
2018-07-20 16:33:13 +00:00
|
|
|
*/
|
|
|
|
int can_all_from_reach_with_flag(struct object_array *from,
|
|
|
|
unsigned int with_flag,
|
|
|
|
unsigned int assign_flag,
|
2018-07-20 16:33:28 +00:00
|
|
|
time_t min_commit_date,
|
|
|
|
uint32_t min_generation);
|
2018-07-20 16:33:23 +00:00
|
|
|
int can_all_from_reach(struct commit_list *from, struct commit_list *to,
|
|
|
|
int commit_date_cutoff);
|
2018-07-20 16:33:13 +00:00
|
|
|
|
2018-11-02 13:14:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return a list of commits containing the commits in the 'to' array
|
|
|
|
* that are reachable from at least one commit in the 'from' array.
|
|
|
|
* Also add the given 'flag' to each of the commits in the returned list.
|
|
|
|
*
|
|
|
|
* This method uses the PARENT1 and PARENT2 flags during its operation,
|
|
|
|
* so be sure these flags are not set before calling the method.
|
|
|
|
*/
|
|
|
|
struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
|
|
|
|
struct commit **to, int nr_to,
|
|
|
|
unsigned int reachable_flag);
|
|
|
|
|
2018-07-20 16:33:02 +00:00
|
|
|
#endif
|