Fossil

Check-in [761a6a9d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change the "branch list" command to provide output more like Git.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 761a6a9dcfd808ff576c1851d79ce95b1f4a4a78
User & Date: drh 2010-11-13 23:45:15
References
2010-11-14
19:34 New ticket [de35b174] defect in command line parser: -- is not a valid comment. artifact: b20cee63 user: wolfgang
Context
2010-11-15
19:50
Fix graph display for file history. Tickets [5c7565d157b13fe0c30b7] and [a734fe24da8f75758cf4]. check-in: bb045dbd user: drh tags: trunk
2010-11-13
23:45
Change the "branch list" command to provide output more like Git. check-in: 761a6a9d user: drh tags: trunk
23:29
Disable automatic pull of shun records for the time being. check-in: 3c2500c7 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/branch.c.

185
186
187
188
189
190
191

192
193
194
195

196
197
198
199
200









201
202
203
204


205
206
207
208





209
210
211
212
213
214
215
**    %fossil branch list
**
**        List all branches
**
*/
void branch_cmd(void){
  int n;

  db_find_and_open_repository(1);
  if( g.argc<3 ){
    usage("new|list ...");
  }

  n = strlen(g.argv[2]);
  if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
    branch_new();
  }else if( n>=2 && strncmp(g.argv[2],"list",n)==0 ){
    Stmt q;









    db_prepare(&q,
      "%s"
      "   AND blob.rid IN (SELECT rid FROM tagxref"
      "                     WHERE tagid=%d AND tagtype==2 AND srcid!=0)"


      " ORDER BY event.mtime DESC",
      timeline_query_for_tty(), TAG_BRANCH
    );
    print_timeline(&q, 2000);





    db_finalize(&q);
  }else{
    fossil_panic("branch subcommand should be one of: "
                 "new list");
  }
}








>

|


>
|
|

|

>
>
>
>
>
>
>
>
>

<
<
<
>
>
|
|

<
>
>
>
>
>







185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212



213
214
215
216
217

218
219
220
221
222
223
224
225
226
227
228
229
**    %fossil branch list
**
**        List all branches
**
*/
void branch_cmd(void){
  int n;
  const char *zCmd = "list";
  db_find_and_open_repository(1);
  if( g.argc<2 ){
    usage("new|list ...");
  }
  if( g.argc>=3 ) zCmd = g.argv[2];
  n = strlen(zCmd);
  if( strncmp(zCmd,"new",n)==0 ){
    branch_new();
  }else if( strncmp(zCmd,"list",n)==0 ){
    Stmt q;
    int vid;
    char *zCurrent = 0;

    if( g.localOpen ){
      vid = db_lget_int("checkout", 0);
      zCurrent = db_text(0, "SELECT value FROM tagxref"
                            " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
    }
    compute_leaves(0, 1);
    db_prepare(&q,



      "SELECT DISTINCT value FROM tagxref"
      " WHERE tagid=%d AND value NOT NULL AND rid IN leaves"
      " ORDER BY value /*sort*/",
      TAG_BRANCH
    );

    while( db_step(&q)==SQLITE_ROW ){
      const char *zBr = db_column_text(&q, 0);
      int isCur = zCurrent!=0 && strcmp(zCurrent,zBr)==0;
      printf("%s%s\n", (isCur ? "* " : "  "), zBr);
    }
    db_finalize(&q);
  }else{
    fossil_panic("branch subcommand should be one of: "
                 "new list");
  }
}