git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fast-import: Allow "reset" to delete a new branch without error

From
Eyvind Bernhardsen <eyvind-git@orakel.ntnu.no>
Date
Mar 16, 2008, 19:49 UTC
Message-ID
<283B81B0-4493-41DC-A575-F72910B1EFFA@orakel.ntnu.no>
In-Reply-To
<20080316041240.GH8410@spearce.org>

Creating a branch in fast-import and then resetting it without making any further commits to it currently causes an error message at the end of the import.

This error is triggered by cvs2svn's git backend, which uses a temporary fixup branch when it creates tags, because the fixup branch is reset after each tag.

This patch prevents the error, allowing "reset" to be used to delete temporary branches.

Signed-off-by: Eyvind Bernhardsen <eyvind-git@orakel.ntnu.no>
---
On 16. mars. 2008, at 05.12, Shawn O. Pearce wrote:
> 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.

Yes, that's a much better patch, and since you pointed out that existing branches won't be deleted, here it is again with a better commit message. Thanks!

  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.608.gc20d.dirty
Previous: Shawn O. PearceNext: Junio C Hamano
Message 3 of 4 in “fast-import: allow "reset" without "from" to delete a branch”
  1. fast-import: allow "reset" without "from" to delete a branchEyvind Bernhardsen, Mar 15, 2008
  2. Shawn O. PearceMar 16, 2008
  3. fast-import: Allow "reset" to delete a new branch without errorEyvind Bernhardsen, Mar 16, 2008
  4. Junio C HamanoMar 16, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.