run_add_p() is capable of handling HEAD in any form (e.g. hex, 'HEAD', '@' etc.), not just string 'HEAD'. Therefore, special casing of HEAD does not have any effect. Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@xxxxxxxxx> --- builtin/checkout.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index a6e30931b5..6b74e5fa4e 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -539,12 +539,11 @@ static int checkout_paths(const struct checkout_opts *opts, * recognized by diff-index), we will always replace the name * with the hex of the commit (whether it's in `...` form or * not) for the run_add_interactive() machinery to work - * properly. However, there is special logic for the HEAD case - * so we mustn't replace that. Also, when we were given a - * tree-object, new_branch_info->commit would be NULL, but we - * do not have to do any replacement, either. + * properly. Also, when we were given a tree-object, + * new_branch_info->commit would be NULL, but we do not + * have to do any replacement. */ - if (rev && new_branch_info->commit && strcmp(rev, "HEAD")) + if (rev && new_branch_info->commit) rev = oid_to_hex_r(rev_oid, &new_branch_info->commit->object.oid); if (opts->checkout_index && opts->checkout_worktree) -- 2.43.0