Skip to content

Commit 90c3302

Browse files
committed
Merge branch 'maint'
* maint: fast-import: close pack before unlinking it pager: do not dup2 stderr if it is already redirected git-show: do not segfault when showing a bad tag
2 parents 8befc50 + 87c8a56 commit 90c3302

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

builtin-log.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,13 @@ int cmd_show(int argc, const char **argv, const char *prefix)
340340
t->tag,
341341
diff_get_color_opt(&rev.diffopt, DIFF_RESET));
342342
ret = show_object(o->sha1, 1, &rev);
343-
objects[i].item = parse_object(t->tagged->sha1);
343+
if (ret)
344+
break;
345+
o = parse_object(t->tagged->sha1);
346+
if (!o)
347+
ret = error("Could not read object %s",
348+
sha1_to_hex(t->tagged->sha1));
349+
objects[i].item = o;
344350
i--;
345351
break;
346352
}

fast-import.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,10 @@ static void end_packfile(void)
983983

984984
pack_id++;
985985
}
986-
else
986+
else {
987+
close(old_p->pack_fd);
987988
unlink(old_p->pack_name);
989+
}
988990
free(old_p);
989991

990992
/* We can't carry a delta across packfiles. */

pager.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ void setup_pager(void)
7070

7171
/* original process continues, but writes to the pipe */
7272
dup2(pager_process.in, 1);
73-
dup2(pager_process.in, 2);
73+
if (isatty(2))
74+
dup2(pager_process.in, 2);
7475
close(pager_process.in);
7576

7677
/* this makes sure that the parent terminates after the pager */

t/t7007-show.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
test_description='git show'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success setup '
8+
echo hello world >foo &&
9+
H=$(git hash-object -w foo) &&
10+
git tag -a foo-tag -m "Tags $H" $H &&
11+
HH=$(expr "$H" : "\(..\)") &&
12+
H38=$(expr "$H" : "..\(.*\)") &&
13+
rm -f .git/objects/$HH/$H38
14+
'
15+
16+
test_expect_success 'showing a tag that point at a missing object' '
17+
test_must_fail git --no-pager show foo-tag
18+
'
19+
20+
test_done

0 commit comments

Comments
 (0)