Fossil User Forum

Possibility of creating an empty branch
Login

Possibility of creating an empty branch

Possibility of creating an empty branch

(1) By anonymous on 2021-10-04 08:44:55 [link] [source]

Is it possible to create an empty branch using Fossil?

In git you can create an empty branch like this:

git checkout --orphan empty-branch

Is there an equivalent in Fossil? As far as I can tell after consulting the manual and this forum, there is no such option.

(2) By Warren Young (wyoung) on 2021-10-04 08:52:33 in reply to 1 [link] [source]

$ fossil branch new NAME

?

(3) By anonymous on 2021-10-04 08:56:18 in reply to 2 [link] [source]

Yes I tried that already, and the command returned status 1 and did nothing. It requires the BASIS argument which cannot be omitted.

% fossil branch new empty
Usage: fossil branch new BRANCH-NAME BASIS ?OPTIONS?
%

Fossil version for reference

% fossil version
This is fossil version 2.16 [7aedd56758] 2021-07-02 12:46:01 UTC

(4) By Warren Young (wyoung) on 2021-10-04 09:05:04 in reply to 3 [link] [source]

Try “current”.

(5) By anonymous on 2021-10-04 09:15:14 in reply to 4 [link] [source]

Do you mean I should run fossil branch current or use "current" as the BASIS argument?

I'm new to fossil so I'm sorry if I'm asking very basic questions.

% fossil branch current
trunk
% fossil branch new current
Usage: fossil branch new BRANCH-NAME BASIS ?OPTIONS
% fossil branch new empty current
New branch: ...
Autosync:  https://...
Round-trips: 1   Artifacts sent: 1  received: 0
Push done, sent: 2573  received: 326  ip: ...

The last command just creates a new branch called empty from the current checkout (which was just the tip of trunk), so it is not empty. The empty I'm referring to is the absence of all files and checkins, similar to the git command with --orphan.

(6) By Andy Bradford (andybradford) on 2021-10-04 13:21:17 in reply to 5 [link] [source]

> The empty I'm  referring to is the absence of  all files and checkins,
> similar to the git command with --orphan.

I've never heard of such a feature  in git. What exactly is it's purpose
and why would one want to even use it?

Andy

(8) By hanche on 2021-10-04 15:16:00 in reply to 6 [link] [source]

One stated purpose is to be able to export a source tree without any history, or at least without any history before a certain point in time. An example is if the history contains bits of source code that is proprietary or otherwise encumbered. (Of course, you may also find part of the old history embarassing.)

Personally, I think I would prefer to just start a new repository in this case. It would cost a bit more disk space, but that is cheap these days.

Come to think of it, I think all my personal Fossil repositories start with an empty commit. So it should be no problem to base a new branch off of that.

(9) By Andy Bradford (andybradford) on 2021-10-04 23:49:25 in reply to 8 [link] [source]

> One stated purpose is  to be able to export a  source tree without any
> history

Have you looked at:

https://www.fossil-scm.org/home/help//zip

Or  do  you really  intend  on  shipping the  source  code  as a  Fossil
repository?

Thanks,

Andy

(10) By Marcelo Huerta (richieadler) on 2021-10-04 23:52:42 in reply to 9 [link] [source]

https://www.fossil-scm.org/home/help//zip

Curiously (?), the help for the zip command has mentions to the sqlar command.

(11) By Andy Bradford (andybradford) on 2021-10-05 03:04:09 in reply to 10 [source]

> the zip command has mentions to the sqlar command.

That's probably  because it also says  "Generate a ZIP or  SQL archive".
The command-line tool is slightly different in usage:

https://www.fossil-scm.org/home/help/zip

Andy

(12) By hanche on 2021-10-05 09:53:23 in reply to 9 [link] [source]

I assume the question was directed at the original anonymous poster, not at me. I was merely making an observation from the sidelines.

(13) By Andy Bradford (andybradford) on 2021-10-05 19:23:28 in reply to 12 [link] [source]

> I assume the question was directed at the original anonymous poster

Yes  and no.  Since the  original anonymous  poster has  not provided  a
response,  then my  question  is directed  both at  you  and the  poster
(indirectly) since you did offer one potential end for the request.

I've never heard of such functionality in git, nor used it. I was simply
trying to figure out what the intended purpose of such functionality is.

As I said, if one is merely trying  to export a copy of the source code,
then "fossil  zip" should suffice.  Otherwise, what's the case  that the
anonymous poster  is trying to achieve  in plain English terms,  not git
terms?

Thanks,

Andy

(7) By Kees Nuyt (knu) on 2021-10-04 13:40:59 in reply to 5 [link] [source]

If the checkin in the new branch has to be empty, it makes sense to

  1. Remove all managed files from the repository
  2. Remove all files from the checkout directory
  3. Commit / check in that status

So, you can try:

fossil rm --hard $(fossil ls)
fossil commit --branch empty --allow-empty --comment "initial empty checkin"

(untested)

-- 
Kind regards,
Kees Nuyt

(14) By anonymous on 2021-10-05 19:55:22 in reply to 1 [link] [source]

Fossil open . . . —empty