summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-01-15 09:46:50 -0800
committerRussell Belfer <rb@github.com>2013-01-15 09:46:50 -0800
commit230010d19b20764b5f73636c900bd3ff84295100 (patch)
treee4961e5c86a084b9212a5578a63345db563c0260 /src
parent848d77dc8314895d6ad1a9b36f30a36fc505e230 (diff)
parent5b524d6902b50dc2eebcce760de614edc2ab4cf4 (diff)
downloadlibgit2-230010d19b20764b5f73636c900bd3ff84295100.tar.gz
Merge pull request #1238 from nulltoken/fix/checkout-index
checkout: Teach checkout to cope with orphaned Head
Diffstat (limited to 'src')
-rw-r--r--src/checkout.c9
-rw-r--r--src/diff_output.c4
2 files changed, 9 insertions, 4 deletions
diff --git a/src/checkout.c b/src/checkout.c
index b58ef9f44..d5a471d0c 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -1173,7 +1173,14 @@ static int checkout_data_init(
if (!data->opts.baseline) {
data->opts_free_baseline = true;
- if ((error = checkout_lookup_head_tree(&data->opts.baseline, repo)) < 0)
+ error = checkout_lookup_head_tree(&data->opts.baseline, repo);
+
+ if (error == GIT_EORPHANEDHEAD) {
+ error = 0;
+ giterr_clear();
+ }
+
+ if (error < 0)
goto cleanup;
}
diff --git a/src/diff_output.c b/src/diff_output.c
index 933d44ee5..e79bf30d2 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -842,7 +842,7 @@ static int diff_patch_line_cb(
{
git_diff_patch *patch = payload;
diff_patch_hunk *hunk;
- diff_patch_line *last, *line;
+ diff_patch_line *line;
GIT_UNUSED(delta);
GIT_UNUSED(range);
@@ -872,8 +872,6 @@ static int diff_patch_line_cb(
patch->lines_asize = new_size;
}
- last = (patch->lines_size > 0) ?
- &patch->lines[patch->lines_size - 1] : NULL;
line = &patch->lines[patch->lines_size++];
line->ptr = content;