Skip to content

Commit 065b070

Browse files
committed
Merge branch 'maint'
* maint: grep: fix word-regexp colouring completion: use git rev-parse to detect bare repos Cope better with a _lot_ of packs for-each-ref: fix segfault in copy_email
2 parents d00e364 + e701fad commit 065b070

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

builtin-for-each-ref.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,11 @@ static const char *copy_name(const char *buf)
339339
static const char *copy_email(const char *buf)
340340
{
341341
const char *email = strchr(buf, '<');
342-
const char *eoemail = strchr(email, '>');
343-
if (!email || !eoemail)
342+
const char *eoemail;
343+
if (!email)
344+
return "";
345+
eoemail = strchr(email, '>');
346+
if (!eoemail)
344347
return "";
345348
return xmemdupz(email, eoemail + 1 - email);
346349
}

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ __git_ps1 ()
132132
local c
133133

134134
if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
135-
if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
135+
if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
136136
c="BARE:"
137137
else
138138
b="GIT_DIR!"

grep.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
305305
{
306306
int hit = 0;
307307
int saved_ch = 0;
308+
const char *start = bol;
308309

309310
if ((p->token != GREP_PATTERN) &&
310311
((p->token == GREP_PATTERN_HEAD) != (ctx == GREP_CONTEXT_HEAD)))
@@ -365,6 +366,10 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
365366
}
366367
if (p->token == GREP_PATTERN_HEAD && saved_ch)
367368
*eol = saved_ch;
369+
if (hit) {
370+
pmatch[0].rm_so += bol - start;
371+
pmatch[0].rm_eo += bol - start;
372+
}
368373
return hit;
369374
}
370375

sha1_file.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ static int open_packed_git_1(struct packed_git *p)
720720
return error("packfile %s index unavailable", p->pack_name);
721721

722722
p->pack_fd = open(p->pack_name, O_RDONLY);
723+
while (p->pack_fd < 0 && errno == EMFILE && unuse_one_window(p, -1))
724+
p->pack_fd = open(p->pack_name, O_RDONLY);
723725
if (p->pack_fd < 0 || fstat(p->pack_fd, &st))
724726
return -1;
725727

@@ -937,6 +939,8 @@ static void prepare_packed_git_one(char *objdir, int local)
937939
sprintf(path, "%s/pack", objdir);
938940
len = strlen(path);
939941
dir = opendir(path);
942+
while (!dir && errno == EMFILE && unuse_one_window(packed_git, -1))
943+
dir = opendir(path);
940944
if (!dir) {
941945
if (errno != ENOENT)
942946
error("unable to open object pack directory: %s: %s",
@@ -2339,6 +2343,8 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
23392343

23402344
filename = sha1_file_name(sha1);
23412345
fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
2346+
while (fd < 0 && errno == EMFILE && unuse_one_window(packed_git, -1))
2347+
fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
23422348
if (fd < 0) {
23432349
if (errno == EACCES)
23442350
return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());

0 commit comments

Comments
 (0)