Re: [PATCH/RFC] fast-import: allow "reset" without "from" to delete a branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eyvind Bernhardsen <eyvind-git@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxx>
Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux