git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Eyvind Bernhardsen <eyvind-git@orakel.ntnu.no>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH/RFC] fast-import: allow "reset" without "from" to delete a branch
Date: Sun, 16 Mar 2008 00:12:40 -0400	[thread overview]
Message-ID: <20080316041240.GH8410@spearce.org> (raw)
In-Reply-To: <7AFA021C-062D-4FC2-85EB-1DD6C054BEA4@orakel.ntnu.no>

Eyvind Bernhardsen <eyvind-git@orakel.ntnu.no> wrote:
> It's a small change and the test suite passes, but I'm not sure if  
> using reset to delete a branch is desired behaviour, so I would  
> appreciate it if someone who actually knows what they are doing could  
> take a look at it :)

I think this is a slightly better patch, as it avoids creating a
lock file around the ref if we aren't going to actually alter it.

At present fast-import does not allow an application to delete a
branch that existed when fast-import started, but if the branch
was strictly transient within the fast-import process (like the
cvs2svn TAG.FIXUP) then there is no problem.

Is this patch acceptable?  Note it is from you, I carried in your
commit message, SBO, etc.
 
--8>--
From: Eyvind Bernhardsen <eyvind-git@orakel.ntnu.no>
Subject: [PATCH] fast-import: allow "reset" without "from" to delete temporary branch

Resetting a branch without "from" and not making any further commits
to it currently causes fast-import to fail with an error message.

This patch prevents the error, allowing "reset" to be used to delete
a branch.

Signed-off-by: Eyvind Bernhardsen <eyvind-git@orakel.ntnu.no>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 fast-import.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index 655913d..73e5439 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1516,6 +1516,8 @@ static int update_branch(struct branch *b)
 	struct ref_lock *lock;
 	unsigned char old_sha1[20];
 
+	if (is_null_sha1(b->sha1))
+		return 0;
 	if (read_ref(b->name, old_sha1))
 		hashclr(old_sha1);
 	lock = lock_any_ref_for_update(b->name, old_sha1, 0);
-- 
1.5.4.4.640.g8ae62

-- 
Shawn.

  reply	other threads:[~2008-03-16  4:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-15 14:59 [PATCH/RFC] fast-import: allow "reset" without "from" to delete a branch Eyvind Bernhardsen
2008-03-16  4:12 ` Shawn O. Pearce [this message]
2008-03-16 19:49   ` [PATCH] fast-import: Allow "reset" to delete a new branch without error Eyvind Bernhardsen
2008-03-16 21:17     ` 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=20080316041240.GH8410@spearce.org \
    --to=spearce@spearce.org \
    --cc=eyvind-git@orakel.ntnu.no \
    --cc=git@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).