summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-12-15 23:06:13 -0800
committerJunio C Hamano <gitster@pobox.com>2008-12-15 23:06:13 -0800
commit90c3302173c5a02189f5fe9091c0d07f7b7ebe89 (patch)
tree3488c30e5932a751c344083bfd289c0c48de2ba9
parent8befc50c49e8a271fd3cd7fb34258fe88d1dfcad (diff)
parent87c8a56e4f71cc7e22c16caa4adc2ae17f6aa93d (diff)
downloadgit-90c3302173c5a02189f5fe9091c0d07f7b7ebe89.tar.gz
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
-rw-r--r--builtin-log.c8
-rw-r--r--fast-import.c4
-rw-r--r--pager.c3
-rwxr-xr-xt/t7007-show.sh20
4 files changed, 32 insertions, 3 deletions
diff --git a/builtin-log.c b/builtin-log.c
index 840daf9078..99d1137b08 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -340,7 +340,13 @@ int cmd_show(int argc, const char **argv, const char *prefix)
t->tag,
diff_get_color_opt(&rev.diffopt, DIFF_RESET));
ret = show_object(o->sha1, 1, &rev);
- objects[i].item = parse_object(t->tagged->sha1);
+ if (ret)
+ break;
+ o = parse_object(t->tagged->sha1);
+ if (!o)
+ ret = error("Could not read object %s",
+ sha1_to_hex(t->tagged->sha1));
+ objects[i].item = o;
i--;
break;
}
diff --git a/fast-import.c b/fast-import.c
index 3276d5d7aa..201d4ffa13 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -983,8 +983,10 @@ static void end_packfile(void)
pack_id++;
}
- else
+ else {
+ close(old_p->pack_fd);
unlink(old_p->pack_name);
+ }
free(old_p);
/* We can't carry a delta across packfiles. */
diff --git a/pager.c b/pager.c
index aa0966c9c5..f19ddbc87d 100644
--- a/pager.c
+++ b/pager.c
@@ -70,7 +70,8 @@ void setup_pager(void)
/* original process continues, but writes to the pipe */
dup2(pager_process.in, 1);
- dup2(pager_process.in, 2);
+ if (isatty(2))
+ dup2(pager_process.in, 2);
close(pager_process.in);
/* this makes sure that the parent terminates after the pager */
diff --git a/t/t7007-show.sh b/t/t7007-show.sh
new file mode 100755
index 0000000000..cce222f052
--- /dev/null
+++ b/t/t7007-show.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+test_description='git show'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ echo hello world >foo &&
+ H=$(git hash-object -w foo) &&
+ git tag -a foo-tag -m "Tags $H" $H &&
+ HH=$(expr "$H" : "\(..\)") &&
+ H38=$(expr "$H" : "..\(.*\)") &&
+ rm -f .git/objects/$HH/$H38
+'
+
+test_expect_success 'showing a tag that point at a missing object' '
+ test_must_fail git --no-pager show foo-tag
+'
+
+test_done