From a02d423ea80b29b368ee452585b49e5e15a38a4a Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 10 May 2010 04:55:04 -0400 Subject: [PATCH] fix off-by-one on parent selection Originally, we use "git rev-list -1 --parents" to get the list of parents, and therefore the 0th slot was the commit in question, the 1st slot was the 1st parent, and so forth. Commit 0a46941 switched this to use --pretty=format:%P, so that the menu-selection code could be easily used (which counts items starting from 0). However, we only use the menu code in the case of multiple parents. For a single parent, this introduced an off-by-one where we look just past the parent we want. This patch fixes it by explicitly selecting the 0th parent for the single parent case. Signed-off-by: Jeff King Signed-off-by: Jonas Fonseca --- tig.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tig.c b/tig.c index 074e414..60932d4 100644 --- a/tig.c +++ b/tig.c @@ -4012,7 +4012,9 @@ select_commit_parent(const char *id, char rev[SIZEOF_REV], const char *path) return FALSE; } - if (parents > 1 && !open_commit_parent_menu(buf, &parents)) + if (parents == 1) + parents = 0; + else if (!open_commit_parent_menu(buf, &parents)) return FALSE; string_copy_rev(rev, &buf[41 * parents]); -- 2.30.2