@@ -368,13 +368,15 @@ static void add_var(struct strbuf *buf, const char *name, const char *value)
368
368
369
369
#define RESET_HEAD_DETACH (1<<0)
370
370
#define RESET_HEAD_HARD (1<<1)
371
+ #define RESET_HEAD_REFS_ONLY (1<<2)
371
372
372
373
static int reset_head (struct object_id * oid , const char * action ,
373
374
const char * switch_to_branch , unsigned flags ,
374
375
const char * reflog_orig_head , const char * reflog_head )
375
376
{
376
377
unsigned detach_head = flags & RESET_HEAD_DETACH ;
377
378
unsigned reset_hard = flags & RESET_HEAD_HARD ;
379
+ unsigned refs_only = flags & RESET_HEAD_REFS_ONLY ;
378
380
struct object_id head_oid ;
379
381
struct tree_desc desc [2 ] = { { NULL }, { NULL } };
380
382
struct lock_file lock = LOCK_INIT ;
@@ -390,7 +392,7 @@ static int reset_head(struct object_id *oid, const char *action,
390
392
if (switch_to_branch && !starts_with (switch_to_branch , "refs/" ))
391
393
BUG ("Not a fully qualified branch: '%s'" , switch_to_branch );
392
394
393
- if (hold_locked_index (& lock , LOCK_REPORT_ON_ERROR ) < 0 ) {
395
+ if (! refs_only && hold_locked_index (& lock , LOCK_REPORT_ON_ERROR ) < 0 ) {
394
396
ret = -1 ;
395
397
goto leave_reset_head ;
396
398
}
@@ -403,6 +405,9 @@ static int reset_head(struct object_id *oid, const char *action,
403
405
if (!oid )
404
406
oid = & head_oid ;
405
407
408
+ if (flags & RESET_HEAD_REFS_ONLY )
409
+ goto reset_head_refs ;
410
+
406
411
memset (& unpack_tree_opts , 0 , sizeof (unpack_tree_opts ));
407
412
setup_unpack_trees_porcelain (& unpack_tree_opts , action );
408
413
unpack_tree_opts .head_idx = 1 ;
@@ -443,6 +448,7 @@ static int reset_head(struct object_id *oid, const char *action,
443
448
goto leave_reset_head ;
444
449
}
445
450
451
+ reset_head_refs :
446
452
reflog_action = getenv (GIT_REFLOG_ACTION_ENVIRONMENT );
447
453
strbuf_addf (& msg , "%s: " , reflog_action ? reflog_action : "rebase" );
448
454
prefix_len = msg .len ;
0 commit comments