NetBSD Problem Report #48844

From jarmo.jaakkola@roskakori.fi  Wed May 28 23:57:23 2014
Return-Path: <jarmo.jaakkola@roskakori.fi>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 01508A5851
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 28 May 2014 23:57:22 +0000 (UTC)
Message-Id: <20140528235720.71381530F@roskakori.fi>
Date: Thu, 29 May 2014 02:57:20 +0300 (EEST)
From: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
Reply-To: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
To: gnats-bugs@gnats.NetBSD.org
Subject: git-rebase does not work
X-Send-Pr-Version: 3.95

>Number:         48844
>Category:       pkg
>Synopsis:       git rebase is broken because dot commands are broken in sh(1)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 29 00:00:00 +0000 2014
>Closed-Date:    Mon Oct 31 05:32:40 +0000 2016
>Last-Modified:  Mon Oct 31 05:32:40 +0000 2016
>Originator:     Jarmo Jaakkola
>Release:        NetBSD 6.1.2_PATCH
>Organization:
>Environment:
System: NetBSD kotoisa.roskakori.fi 6.1.2_PATCH NetBSD 6.1.2_PATCH (KOTOISA) #5: Mon Jan 20 17:01:44 EET 2014 jammuli@kotoisa.roskakori.fi:/usr/src/sys/arch/amd64/compile/KOTOISA amd64
Architecture: x86_64
Machine: amd64
git: git-base-1.8.5.1nb1
>Description:
After git rebase -i, HEAD is left in the wrong place, seemingly losing
commits.  The commits can be seen in reflog and the branch can be reset.

This is caused by sh(1) misbehaving when a dot command is executed in
a function and the dot command contains a return that is supposed
to return from the dot command.  See PR bin/48843.

To be exact:
    1) Line 181,
          . git-rebase--$type
       is executed in git-rebase's run_specific_rebase_internal().
    2) Line 860,
          return 0 
       is executed in a case statement in git-rebase--interactive
       because $action is continue.
    3) Bug #48843 steps in, effectively nullifying the return.
       Instead of returning from git-rebase--interactive, evaluation
       continues after the case, evaluating some of the commands.
    4) Evaluation ends up to line 181 in git-rebase--interactive,
       where
          shortupstream=$(git rev-parse --short $upstream)
       results in an error, because $upstream is not set (as it
       shouldn't be).
    5) And then things get worse some time later (I didn't debug
       further)

>How-To-Repeat:
$ mkdir example; cd example; git init
$ touch a; git commit -m a a
$ touch b; git commit -m b b
$ git rebase -i HEAD~1    # choose to edit the commit
$ git rebase --continue   # make no changes

This is where you get a rebase-todo to edit with the contents "noop".
After exiting the editor, this is seen:

    Successfully rebased and updated refs/heads/master.
    fatal: Needed a single revision
    Successfully rebased and updated refs/heads/master.

$ git log
commit 64b402544f30b020b388a834ca8728628de71328
Author: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
Date:   Thu May 29 02:10:07 2014 +0300

    a

The b commit is nowhere to be seen.

>Fix:
To fix the root of the problem, apply the patch in PR bin/48843 to sh(1).
How to fix git(1) instead of sh, that I do not know.  Patch git to use
another shell?

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 31 Oct 2016 05:32:40 +0000
State-Changed-Why:
Duplicate of 48843.

Git should probably also be fixed to not use undefined shell constructs
in its scripts, but that's an upstream issue.

"don't use git" is a fine workaround :^)


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.