All of lore.kernel.org
 help / color / mirror / Atom feed
From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [PATCH 2/2] sh-setup: make require_clean_work_tree() work on orphan branches
Date: Mon, 30 Nov 2015 13:24:24 +0100	[thread overview]
Message-ID: <20151130132424.Horde.2BMsKJ5eWOY71RtsJbP8UQw@webmail.informatik.kit.edu> (raw)
In-Reply-To: <56555A5B.20504@kdbg.org>


Quoting Johannes Sixt <j6t@kdbg.org>:

>> --- a/git-sh-setup.sh
>> +++ b/git-sh-setup.sh
>> @@ -200,7 +200,19 @@ require_work_tree () {
>> }
>>
>> require_clean_work_tree () {
>> -	git rev-parse --verify HEAD >/dev/null || exit 1
>> +	if git rev-parse --verify HEAD >/dev/null 2>/dev/null
>> +	then
>> +		compare_to=HEAD
>> +	else
>> +		if [ -z "$ORPHAN_OK" ]
>> +		then
>> +			echo >&2 "Cannot $1: Your current branch does not have any commits yet."
>> +			exit 1
>> +		else
>> +			# SHA1 of an empty tree
>> +			compare_to=4b825dc642cb6eb9a060e54bf8d69288fbee4904
>> +		fi
>> +	fi
>
> It is worrysome that this now throws away any error message of
> rev-parse. A more conservative approach would be to test for -z
> "$ORPHAN_OK" first and entail new behavior only for the "$ORPHAN_OK"
> case.

Those error messages didn't seem to be helpful and in some cases they
were even misleading, e.g.:

    $ git checkout --orphan orphan
    $ git rm -rf .
    $ git script valid-branch
    fatal: Needed a single revision
    $ # Huh?  Didn't I just gave you one?!

Gábor

  reply	other threads:[~2015-11-30 12:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-24 14:45 [PATCH 1/2] Add tests for git-sh-setup's require_clean_work_tree() SZEDER Gábor
2015-11-24 14:45 ` [PATCH 2/2] sh-setup: make require_clean_work_tree() work on orphan branches SZEDER Gábor
2015-11-24 20:50   ` Jeff King
2015-11-30 12:37     ` SZEDER Gábor
2015-12-02 23:07     ` Junio C Hamano
2015-11-25  6:51   ` Johannes Sixt
2015-11-30 12:24     ` SZEDER Gábor [this message]
2016-01-21  0:06   ` Junio C Hamano
2016-01-20 23:59 ` [PATCH 1/2] Add tests for git-sh-setup's require_clean_work_tree() Junio C Hamano
2016-01-21  1:27   ` SZEDER Gábor
2016-01-21  4:52     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151130132424.Horde.2BMsKJ5eWOY71RtsJbP8UQw@webmail.informatik.kit.edu \
    --to=szeder@ira.uka.de \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.