branch: segfault fixes and validation
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 23 Feb 2013 12:22:27 +0000 (19:22 +0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 23 Feb 2013 19:53:21 +0000 (11:53 -0800)
commit8efb8899cfe866dddb3659b9e0a94232161db65e
treeddd5923a81c5050afc629b45ce02b09fad51dfec
parentd040350813986e0f4bb3aeb977077975c1552606
branch: segfault fixes and validation

branch_get() can return NULL (so far on detached HEAD only) but some
code paths in builtin/branch.c cannot deal with that and cause
segfaults.

While at there, make sure to bail out when the user gives 2 or more
branches with --set-upstream-to or --unset-upstream, where only the
first branch is processed and the rest silently dropped.

Reported-by: Per Cederqvist <cederp@opera.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/branch.c
t/t3200-branch.sh