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
19 changes: 19 additions & 0 deletions Documentation/RelNotes/2.55.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ UI, Workflows & Features
* Misspelt proxy URL (e.g., httt://...) did not trigger any warning
or failure, which has been corrected.

* Document the fact that .git/info/exclude is shared across worktrees
linked to the same repository.

* The command line parser for "git diff" learned a few options take
only non-negative integers.


Performance, Internal Implementation, Development Support etc.
--------------------------------------------------------------
Expand All @@ -56,6 +62,8 @@ Performance, Internal Implementation, Development Support etc.
integration branches closer to their origin in the contributor PR
builds.

* "git merge-base" optimization.


Fixes since v2.54
-----------------
Expand Down Expand Up @@ -153,6 +161,17 @@ Fixes since v2.54
time, which has been corrected.
(merge 29364f1624 ps/maintenance-daemonize-lockfix later to maint).

* Remove ineffective strbuf presizing that would have computed an
allocation that would not have fit in the available memory anyway,
or too small due to integer wraparound to cause immediate automatic
growing.
(merge a9ce8526dc jk/pretty-no-strbuf-presizing later to maint).

* The HTTP walker misinterpreted the alternates file that gives an
absolute path when the server URL does not have the final slash
(i.e., "https://example.com" not "https://example.com/").
(merge b92387cd55 jk/dumb-http-alternate-fix later to maint).

* Other code cleanup, docfix, build fix, etc.
(merge 80f4b802e9 ja/doc-difftool-synopsis-style later to maint).
(merge b96490241e jc/doc-timestamps-in-stat later to maint).
Expand Down
2 changes: 1 addition & 1 deletion Documentation/git-ls-files.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ can give `--exclude-per-directory=.gitignore`, and then specify:
1. The file specified by the `core.excludesfile` configuration
variable, if exists, or the `$XDG_CONFIG_HOME/git/ignore` file.

2. The `$GIT_DIR/info/exclude` file.
2. The `$GIT_COMMON_DIR/info/exclude` file.

via the `--exclude-from=` option.

Expand Down
2 changes: 1 addition & 1 deletion Documentation/git-svn.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Any other arguments are passed directly to 'git log'
'show-ignore'::
Recursively finds and lists the svn:ignore and svn:global-ignores
properties on directories. The output is suitable for appending to
the $GIT_DIR/info/exclude file.
the $GIT_COMMON_DIR/info/exclude file.

'mkdirs'::
Attempts to recreate empty directories that core Git cannot track
Expand Down
4 changes: 2 additions & 2 deletions Documentation/gitformat-index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,14 @@ Git index format
sequence in variable width encoding. Each string describes the
environment where the cache can be used.

- Stat data of $GIT_DIR/info/exclude. See "Index entry" section from
- Stat data of $GIT_COMMON_DIR/info/exclude. See "Index entry" section from
ctime field until "file size".

- Stat data of core.excludesFile

- 32-bit dir_flags (see struct dir_struct)

- Hash of $GIT_DIR/info/exclude. A null hash means the file
- Hash of $GIT_COMMON_DIR/info/exclude. A null hash means the file
does not exist.

- Hash of core.excludesFile. A null hash means the file does
Expand Down
12 changes: 6 additions & 6 deletions Documentation/gitignore.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gitignore - Specifies intentionally untracked files to ignore

SYNOPSIS
--------
$XDG_CONFIG_HOME/git/ignore, $GIT_DIR/info/exclude, .gitignore
$XDG_CONFIG_HOME/git/ignore, $GIT_COMMON_DIR/info/exclude, .gitignore

DESCRIPTION
-----------
Expand All @@ -34,7 +34,7 @@ precedence, the last matching pattern decides the outcome):
includes such `.gitignore` files in its repository, containing patterns for
files generated as part of the project build.

* Patterns read from `$GIT_DIR/info/exclude`.
* Patterns read from `$GIT_COMMON_DIR/info/exclude`.

* Patterns read from the file specified by the configuration
variable `core.excludesFile`.
Expand All @@ -50,7 +50,7 @@ be used.
specific to a particular repository but which do not need to be shared
with other related repositories (e.g., auxiliary files that live inside
the repository but are specific to one user's workflow) should go into
the `$GIT_DIR/info/exclude` file.
the `$GIT_COMMON_DIR/info/exclude` file.

* Patterns which a user wants Git to
ignore in all situations (e.g., backup or temporary files generated by
Expand Down Expand Up @@ -97,7 +97,7 @@ PATTERN FORMAT
match at any level below the `.gitignore` level.

- Patterns read from exclude sources that are outside the working tree,
such as $GIT_DIR/info/exclude and core.excludesFile, are treated as if
such as $GIT_COMMON_DIR/info/exclude and core.excludesFile, are treated as if
they are specified at the root of the working tree, i.e. a leading "/"
in such patterns anchors the match at the root of the repository.

Expand Down Expand Up @@ -146,8 +146,8 @@ CONFIGURATION

The optional configuration variable `core.excludesFile` indicates a path to a
file containing patterns of file names to exclude, similar to
`$GIT_DIR/info/exclude`. Patterns in the exclude file are used in addition to
those in `$GIT_DIR/info/exclude`.
`$GIT_COMMON_DIR/info/exclude`. Patterns in the exclude file are used in
addition to those in `$GIT_COMMON_DIR/info/exclude`.

NOTES
-----
Expand Down
4 changes: 3 additions & 1 deletion builtin/merge-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

static int show_merge_base(struct commit **rev, size_t rev_nr, int show_all)
{
enum merge_base_flags flags = show_all ? MERGE_BASE_FIND_ALL : 0;
struct commit_list *result = NULL, *r;

if (repo_get_merge_bases_many_dirty(the_repository, rev[0],
rev_nr - 1, rev + 1, &result) < 0) {
rev_nr - 1, rev + 1,
flags, &result) < 0) {
commit_list_free(result);
return -1;
}
Expand Down
36 changes: 27 additions & 9 deletions commit-reach.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static int paint_down_to_common(struct repository *r,
struct commit *one, int n,
struct commit **twos,
timestamp_t min_generation,
int ignore_missing_commits,
enum merge_base_flags mb_flags,
struct commit_list **result)
{
struct prio_queue queue = { compare_commits_by_gen_then_commit_date };
Expand Down Expand Up @@ -97,6 +97,14 @@ static int paint_down_to_common(struct repository *r,
if (!(commit->object.flags & RESULT)) {
commit->object.flags |= RESULT;
tail = commit_list_append(commit, tail);
/*
* The queue is generation-ordered; no
* remaining common ancestor can be a
* descendant of this one.
*/
if (!(mb_flags & MERGE_BASE_FIND_ALL) &&
generation < GENERATION_NUMBER_INFINITY)
break;
}
/* Mark parents of a found merge stale */
flags |= STALE;
Expand All @@ -118,7 +126,7 @@ static int paint_down_to_common(struct repository *r,
* corrupt commits would already have been
* dispatched with a `die()`.
*/
if (ignore_missing_commits)
if (mb_flags & MERGE_BASE_IGNORE_MISSING_COMMITS)
return 0;
return error(_("could not parse commit %s"),
oid_to_hex(&p->object.oid));
Expand All @@ -136,6 +144,7 @@ static int paint_down_to_common(struct repository *r,
static int merge_bases_many(struct repository *r,
struct commit *one, int n,
struct commit **twos,
enum merge_base_flags mb_flags,
struct commit_list **result)
{
struct commit_list *list = NULL, **tail = result;
Expand Down Expand Up @@ -165,7 +174,7 @@ static int merge_bases_many(struct repository *r,
oid_to_hex(&twos[i]->object.oid));
}

if (paint_down_to_common(r, one, n, twos, 0, 0, &list)) {
if (paint_down_to_common(r, one, n, twos, 0, mb_flags, &list)) {
commit_list_free(list);
return -1;
}
Expand Down Expand Up @@ -246,7 +255,8 @@ static int remove_redundant_no_gen(struct repository *r,
min_generation = curr_generation;
}
if (paint_down_to_common(r, array[i], filled,
work, min_generation, 0, &common)) {
work, min_generation,
MERGE_BASE_FIND_ALL, &common)) {
clear_commit_marks(array[i], all_flags);
clear_commit_marks_many(filled, work, all_flags);
commit_list_free(common);
Expand Down Expand Up @@ -425,14 +435,15 @@ static int get_merge_bases_many_0(struct repository *r,
size_t n,
struct commit **twos,
int cleanup,
enum merge_base_flags mb_flags,
struct commit_list **result)
{
struct commit_list *list, **tail = result;
struct commit **rslt;
size_t cnt, i;
int ret;

if (merge_bases_many(r, one, n, twos, result) < 0)
if (merge_bases_many(r, one, n, twos, mb_flags, result) < 0)
return -1;
for (i = 0; i < n; i++) {
if (one == twos[i])
Expand Down Expand Up @@ -475,24 +486,27 @@ int repo_get_merge_bases_many(struct repository *r,
struct commit **twos,
struct commit_list **result)
{
return get_merge_bases_many_0(r, one, n, twos, 1, result);
return get_merge_bases_many_0(r, one, n, twos, 1,
MERGE_BASE_FIND_ALL, result);
}

int repo_get_merge_bases_many_dirty(struct repository *r,
struct commit *one,
size_t n,
struct commit **twos,
enum merge_base_flags mb_flags,
struct commit_list **result)
{
return get_merge_bases_many_0(r, one, n, twos, 0, result);
return get_merge_bases_many_0(r, one, n, twos, 0, mb_flags, result);
}

int repo_get_merge_bases(struct repository *r,
struct commit *one,
struct commit *two,
struct commit_list **result)
{
return get_merge_bases_many_0(r, one, 1, &two, 1, result);
return get_merge_bases_many_0(r, one, 1, &two, 1,
MERGE_BASE_FIND_ALL, result);
}

/*
Expand Down Expand Up @@ -537,6 +551,10 @@ int repo_in_merge_bases_many(struct repository *r, struct commit *commit,
struct commit_list *bases = NULL;
int ret = 0, i;
timestamp_t generation, max_generation = GENERATION_NUMBER_ZERO;
enum merge_base_flags mb_flags = MERGE_BASE_FIND_ALL;

if (ignore_missing_commits)
mb_flags |= MERGE_BASE_IGNORE_MISSING_COMMITS;

if (repo_parse_commit(r, commit))
return ignore_missing_commits ? 0 : -1;
Expand All @@ -555,7 +573,7 @@ int repo_in_merge_bases_many(struct repository *r, struct commit *commit,

if (paint_down_to_common(r, commit,
nr_reference, reference,
generation, ignore_missing_commits, &bases))
generation, mb_flags, &bases))
ret = -1;
else if (commit->object.flags & PARENT2)
ret = 1;
Expand Down
12 changes: 11 additions & 1 deletion commit-reach.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@ int repo_get_merge_bases_many(struct repository *r,
struct commit *one, size_t n,
struct commit **twos,
struct commit_list **result);
/* To be used only when object flags after this call no longer matter */
enum merge_base_flags {
MERGE_BASE_IGNORE_MISSING_COMMITS = (1 << 0),
MERGE_BASE_FIND_ALL = (1 << 1),
};

/*
* To be used only when object flags after this call no longer matter.
* Without MERGE_BASE_FIND_ALL and with generation numbers available,
* returns after finding the first merge-base, skipping the STALE drain.
*/
int repo_get_merge_bases_many_dirty(struct repository *r,
struct commit *one, size_t n,
struct commit **twos,
enum merge_base_flags mb_flags,
struct commit_list **result);

int get_octopus_merge_bases(struct commit_list *in, struct commit_list **result);
Expand Down
25 changes: 14 additions & 11 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ static int diff_suppress_blank_empty;
static enum git_colorbool diff_use_color_default = GIT_COLOR_UNKNOWN;
static int diff_color_moved_default;
static int diff_color_moved_ws_default;
static int diff_context_default = 3;
static int diff_interhunk_context_default;
static unsigned int diff_context_default = 3;
static unsigned int diff_interhunk_context_default;
static char *diff_word_regex_cfg;
static struct external_diff external_diff_cfg;
static char *diff_order_file_cfg;
Expand Down Expand Up @@ -382,16 +382,17 @@ int git_diff_ui_config(const char *var, const char *value,
return 0;
}
if (!strcmp(var, "diff.context")) {
diff_context_default = git_config_int(var, value, ctx->kvi);
if (diff_context_default < 0)
int val = git_config_int(var, value, ctx->kvi);
if (val < 0)
return -1;
diff_context_default = val;
return 0;
}
if (!strcmp(var, "diff.interhunkcontext")) {
diff_interhunk_context_default = git_config_int(var, value,
ctx->kvi);
if (diff_interhunk_context_default < 0)
int val = git_config_int(var, value, ctx->kvi);
if (val < 0)
return -1;
diff_interhunk_context_default = val;
return 0;
}
if (!strcmp(var, "diff.renames")) {
Expand Down Expand Up @@ -5946,9 +5947,12 @@ static int diff_opt_unified(const struct option *opt,
BUG_ON_OPT_NEG(unset);

if (arg) {
options->context = strtol(arg, &s, 10);
long val = strtol(arg, &s, 10);
if (*s)
return error(_("%s expects a numerical value"), "--unified");
if (val < 0)
return error(_("%s expects a non-negative integer"), "--unified");
options->context = val;
}
enable_patch_output(&options->output_format);

Expand Down Expand Up @@ -6133,9 +6137,8 @@ struct option *add_diff_options(const struct option *opts,
OPT_CALLBACK_F(0, "default-prefix", options, NULL,
N_("use default prefixes a/ and b/"),
PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_default_prefix),
OPT_INTEGER_F(0, "inter-hunk-context", &options->interhunkcontext,
N_("show context between diff hunks up to the specified number of lines"),
PARSE_OPT_NONEG),
OPT_UNSIGNED(0, "inter-hunk-context", &options->interhunkcontext,
N_("show context between diff hunks up to the specified number of lines")),
OPT_CALLBACK_F(0, "output-indicator-new",
&options->output_indicators[OUTPUT_INDICATOR_NEW],
N_("<char>"),
Expand Down
4 changes: 2 additions & 2 deletions diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ struct diff_options {
enum git_colorbool use_color;

/* Number of context lines to generate in patch output. */
int context;
unsigned int context;

int interhunkcontext;
unsigned int interhunkcontext;

/* Affects the way detection logic for complete rewrites, renames and
* copies.
Expand Down
4 changes: 2 additions & 2 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -2985,7 +2985,7 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
return NULL;

/*
* We only support $GIT_DIR/info/exclude and core.excludesfile
* We only support $GIT_COMMON_DIR/info/exclude and core.excludesfile
* as the global ignore rule files. Any other additions
* (e.g. from command line) invalidate the cache. This
* condition also catches running setup_standard_excludes()
Expand Down Expand Up @@ -3078,7 +3078,7 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
istate->cache_changed |= UNTRACKED_CHANGED;
}

/* Validate $GIT_DIR/info/exclude and core.excludesfile */
/* Validate $GIT_COMMON_DIR/info/exclude and core.excludesfile */
root = dir->untracked->root;
if (!oideq(&dir->internal.ss_info_exclude.oid,
&dir->untracked->ss_info_exclude.oid)) {
Expand Down
2 changes: 1 addition & 1 deletion dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ struct oid_stat {
* - The list of files and directories of the directory in question
* - The $GIT_DIR/index
* - dir_struct flags
* - The content of $GIT_DIR/info/exclude
* - The content of $GIT_COMMON_DIR/info/exclude
* - The content of core.excludesfile
* - The content (or the lack) of .gitignore of all parent directories
* from $GIT_WORK_TREE
Expand Down
2 changes: 1 addition & 1 deletion http-walker.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static void process_alternates_response(void *callback_data)
*/
const char *colon_ss = strstr(base,"://");
if (colon_ss) {
serverlen = (strchr(colon_ss + 3, '/')
serverlen = (strchrnul(colon_ss + 3, '/')
- base);
okay = 1;
}
Expand Down
Loading