Skip to content

Commit 68fb465

Browse files
committed
Merge branch 'maint'
* maint: config: Change output of --get-regexp for valueless keys config: Complete documentation of --get-regexp cleanup merge-base test script Fix zero-object version-2 packs Ignore submodule commits when fetching over dumb protocols
2 parents b658d50 + b69ba46 commit 68fb465

File tree

6 files changed

+39
-15
lines changed

6 files changed

+39
-15
lines changed

Documentation/git-config.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ SYNOPSIS
1414
'git-config' [--system | --global] --replace-all name [value [value_regex]]
1515
'git-config' [--system | --global] [type] --get name [value_regex]
1616
'git-config' [--system | --global] [type] --get-all name [value_regex]
17+
'git-config' [--system | --global] [type] --get-regexp name_regex [value_regex]
1718
'git-config' [--system | --global] --unset name [value_regex]
1819
'git-config' [--system | --global] --unset-all name [value_regex]
1920
'git-config' [--system | --global] --rename-section old_name new_name
@@ -73,6 +74,7 @@ OPTIONS
7374

7475
--get-regexp::
7576
Like --get-all, but interprets the name as a regular expression.
77+
Also outputs the key names.
7678

7779
--global::
7880
For writing options: write to global ~/.gitconfig file rather than

builtin-config.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ static int show_config(const char* key_, const char* value_)
3838
regexec(regexp, (value_?value_:""), 0, NULL, 0)))
3939
return 0;
4040

41-
if (show_keys)
42-
printf("%s ", key_);
41+
if (show_keys) {
42+
if (value_)
43+
printf("%s ", key_);
44+
else
45+
printf("%s", key_);
46+
}
4347
if (seen && !do_all)
4448
dup_error = 1;
4549
if (type == T_INT)

fetch.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static int process_tree(struct tree *tree)
4646
while (tree_entry(&desc, &entry)) {
4747
struct object *obj = NULL;
4848

49+
/* submodule commits are not stored in the superproject */
50+
if (S_ISGITLINK(entry.mode))
51+
continue;
4952
if (S_ISDIR(entry.mode)) {
5053
struct tree *tree = lookup_tree(entry.sha1);
5154
if (tree)

sha1_file.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,10 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)
510510
* for offsets larger than 2^31.
511511
*/
512512
unsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;
513-
if (idx_size < min_size || idx_size > min_size + (nr - 1)*8) {
513+
unsigned long max_size = min_size;
514+
if (nr)
515+
max_size += (nr - 1)*8;
516+
if (idx_size < min_size || idx_size > max_size) {
514517
munmap(idx_map, idx_size);
515518
return error("wrong index file size in %s", path);
516519
}

t/t1300-repo-config.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ EOF
283283
test_expect_success 'get variable with no value' \
284284
'git-config --get novalue.variable ^$'
285285

286+
echo novalue.variable > expect
287+
288+
test_expect_success 'get-regexp variable with no value' \
289+
'git-config --get-regexp novalue > output &&
290+
cmp output expect'
291+
286292
git-config > output 2>&1
287293

288294
test_expect_success 'no arguments, but no crash' \

t/t6010-merge-base.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ doit() {
3434
echo $commit
3535
}
3636

37+
# E---D---C---B---A
38+
# \'-_ \ \
39+
# \ `---------G \
40+
# \ \
41+
# F----------------H
42+
3743
# Setup...
3844
E=$(doit 5 E)
3945
D=$(doit 4 D $E)
@@ -44,6 +50,18 @@ A=$(doit 1 A $B)
4450
G=$(doit 7 G $B $E)
4551
H=$(doit 8 H $A $F)
4652

53+
test_expect_success 'compute merge-base (single)' \
54+
'MB=$(git-merge-base G H) &&
55+
expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
56+
57+
test_expect_success 'compute merge-base (all)' \
58+
'MB=$(git-merge-base --all G H) &&
59+
expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
60+
61+
test_expect_success 'compute merge-base with show-branch' \
62+
'MB=$(git-show-branch --merge-base G H) &&
63+
expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
64+
4765
# Setup for second test to demonstrate that relying on timestamps in a
4866
# distributed SCM to provide a _consistent_ partial ordering of commits
4967
# leads to insanity.
@@ -81,18 +99,6 @@ R2=$(doit 3 R2 $R1)
8199
PL=$(doit 4 PL $L2 $C2)
82100
PR=$(doit 4 PR $C2 $R2)
83101

84-
test_expect_success 'compute merge-base (single)' \
85-
'MB=$(git-merge-base G H) &&
86-
expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
87-
88-
test_expect_success 'compute merge-base (all)' \
89-
'MB=$(git-merge-base --all G H) &&
90-
expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
91-
92-
test_expect_success 'compute merge-base with show-branch' \
93-
'MB=$(git-show-branch --merge-base G H) &&
94-
expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
95-
96102
test_expect_success 'compute merge-base (single)' \
97103
'MB=$(git-merge-base PL PR) &&
98104
expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/C2"'

0 commit comments

Comments
 (0)