Fossil SCM

Make "fossil commit" work on a repository which doesn't have any commits yet: An initial commit will be created then.

jan.nijtmans 2013-10-25 07:41 UTC trunk
Commit ebe92f5cfb96dae73836968ee56200503b84e29f
1 file changed +15 -8
+15 -8
--- src/checkin.c
+++ src/checkin.c
@@ -990,16 +990,18 @@
990990
const char *zColor; /* Modified value of p->zColor */
991991
992992
assert( pBaseline==0 || pBaseline->zBaseline==0 );
993993
assert( pBaseline==0 || zBaselineUuid!=0 );
994994
blob_zero(pOut);
995
- zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d AND "
996
- "EXISTS(SELECT 1 FROM event WHERE event.type='ci' and event.objid=%d)",
997
- vid, vid);
998
- if( !zParentUuid ){
999
- fossil_fatal("Could not find a valid check-in for RID %d. "
1000
- "Possible checkout/repo mismatch.", vid);
995
+ if( vid ){
996
+ zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d AND "
997
+ "EXISTS(SELECT 1 FROM event WHERE event.type='ci' and event.objid=%d)",
998
+ vid, vid);
999
+ if( !zParentUuid ){
1000
+ fossil_fatal("Could not find valid manifest for RID %d. "
1001
+ "Possible checkout/repo mismatch.", vid);
1002
+ }
10011003
}
10021004
if( pBaseline ){
10031005
blob_appendf(pOut, "B %s\n", zBaselineUuid);
10041006
manifest_file_rewind(pBaseline);
10051007
pFile = manifest_file_next(pBaseline, 0);
@@ -1091,11 +1093,11 @@
10911093
nFBcard++;
10921094
}
10931095
if( p->zMimetype && p->zMimetype[0] ){
10941096
blob_appendf(pOut, "N %F\n", p->zMimetype);
10951097
}
1096
- if( zParentUuid ){
1098
+ if( vid ){
10971099
blob_appendf(pOut, "P %s", zParentUuid);
10981100
if( p->verifyDate ) checkin_verify_younger(vid, zParentUuid, zDate);
10991101
free(zParentUuid);
11001102
db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0 OR id<-2");
11011103
while( db_step(&q)==SQLITE_ROW ){
@@ -1610,12 +1612,17 @@
16101612
}
16111613
16121614
/*
16131615
** Do not allow a commit that will cause a fork unless the --allow-fork
16141616
** or --force flags is used, or unless this is a private check-in.
1617
+ ** The initial commit MUST have tags "trunk" and "sym-trunk".
16151618
*/
1616
- if( sCiInfo.zBranch==0 && allowFork==0 && forceFlag==0
1619
+ if( !vid ){
1620
+ if( sCiInfo.zBranch==0 ){
1621
+ sCiInfo.zBranch = db_get("main-branch", "trunk");
1622
+ }
1623
+ }else if( sCiInfo.zBranch==0 && allowFork==0 && forceFlag==0
16171624
&& g.markPrivate==0 && !is_a_leaf(vid)
16181625
){
16191626
fossil_fatal("would fork. \"update\" first or use --allow-fork.");
16201627
}
16211628
16221629
--- src/checkin.c
+++ src/checkin.c
@@ -990,16 +990,18 @@
990 const char *zColor; /* Modified value of p->zColor */
991
992 assert( pBaseline==0 || pBaseline->zBaseline==0 );
993 assert( pBaseline==0 || zBaselineUuid!=0 );
994 blob_zero(pOut);
995 zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d AND "
996 "EXISTS(SELECT 1 FROM event WHERE event.type='ci' and event.objid=%d)",
997 vid, vid);
998 if( !zParentUuid ){
999 fossil_fatal("Could not find a valid check-in for RID %d. "
1000 "Possible checkout/repo mismatch.", vid);
 
 
1001 }
1002 if( pBaseline ){
1003 blob_appendf(pOut, "B %s\n", zBaselineUuid);
1004 manifest_file_rewind(pBaseline);
1005 pFile = manifest_file_next(pBaseline, 0);
@@ -1091,11 +1093,11 @@
1091 nFBcard++;
1092 }
1093 if( p->zMimetype && p->zMimetype[0] ){
1094 blob_appendf(pOut, "N %F\n", p->zMimetype);
1095 }
1096 if( zParentUuid ){
1097 blob_appendf(pOut, "P %s", zParentUuid);
1098 if( p->verifyDate ) checkin_verify_younger(vid, zParentUuid, zDate);
1099 free(zParentUuid);
1100 db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0 OR id<-2");
1101 while( db_step(&q)==SQLITE_ROW ){
@@ -1610,12 +1612,17 @@
1610 }
1611
1612 /*
1613 ** Do not allow a commit that will cause a fork unless the --allow-fork
1614 ** or --force flags is used, or unless this is a private check-in.
 
1615 */
1616 if( sCiInfo.zBranch==0 && allowFork==0 && forceFlag==0
 
 
 
 
1617 && g.markPrivate==0 && !is_a_leaf(vid)
1618 ){
1619 fossil_fatal("would fork. \"update\" first or use --allow-fork.");
1620 }
1621
1622
--- src/checkin.c
+++ src/checkin.c
@@ -990,16 +990,18 @@
990 const char *zColor; /* Modified value of p->zColor */
991
992 assert( pBaseline==0 || pBaseline->zBaseline==0 );
993 assert( pBaseline==0 || zBaselineUuid!=0 );
994 blob_zero(pOut);
995 if( vid ){
996 zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d AND "
997 "EXISTS(SELECT 1 FROM event WHERE event.type='ci' and event.objid=%d)",
998 vid, vid);
999 if( !zParentUuid ){
1000 fossil_fatal("Could not find valid manifest for RID %d. "
1001 "Possible checkout/repo mismatch.", vid);
1002 }
1003 }
1004 if( pBaseline ){
1005 blob_appendf(pOut, "B %s\n", zBaselineUuid);
1006 manifest_file_rewind(pBaseline);
1007 pFile = manifest_file_next(pBaseline, 0);
@@ -1091,11 +1093,11 @@
1093 nFBcard++;
1094 }
1095 if( p->zMimetype && p->zMimetype[0] ){
1096 blob_appendf(pOut, "N %F\n", p->zMimetype);
1097 }
1098 if( vid ){
1099 blob_appendf(pOut, "P %s", zParentUuid);
1100 if( p->verifyDate ) checkin_verify_younger(vid, zParentUuid, zDate);
1101 free(zParentUuid);
1102 db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0 OR id<-2");
1103 while( db_step(&q)==SQLITE_ROW ){
@@ -1610,12 +1612,17 @@
1612 }
1613
1614 /*
1615 ** Do not allow a commit that will cause a fork unless the --allow-fork
1616 ** or --force flags is used, or unless this is a private check-in.
1617 ** The initial commit MUST have tags "trunk" and "sym-trunk".
1618 */
1619 if( !vid ){
1620 if( sCiInfo.zBranch==0 ){
1621 sCiInfo.zBranch = db_get("main-branch", "trunk");
1622 }
1623 }else if( sCiInfo.zBranch==0 && allowFork==0 && forceFlag==0
1624 && g.markPrivate==0 && !is_a_leaf(vid)
1625 ){
1626 fossil_fatal("would fork. \"update\" first or use --allow-fork.");
1627 }
1628
1629

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button